Skip to content

Commit 308a3b8

Browse files
committed
thanks tyfkda
1 parent 3432551 commit 308a3b8

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

forktest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define N 1000
99

1010
void
11-
printf(int fd, char *s, ...)
11+
printf(int fd, const char *s, ...)
1212
{
1313
write(fd, s, strlen(s));
1414
}

printf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ printint(int fd, int xx, int base, int sgn)
3737

3838
// Print to the given fd. Only understands %d, %x, %p, %s.
3939
void
40-
printf(int fd, char *fmt, ...)
40+
printf(int fd, const char *fmt, ...)
4141
{
4242
char *s;
4343
int c, i, state;

ulib.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "x86.h"
66

77
char*
8-
strcpy(char *s, char *t)
8+
strcpy(char *s, const char *t)
99
{
1010
char *os;
1111

@@ -24,7 +24,7 @@ strcmp(const char *p, const char *q)
2424
}
2525

2626
uint
27-
strlen(char *s)
27+
strlen(const char *s)
2828
{
2929
int n;
3030

@@ -68,7 +68,7 @@ gets(char *buf, int max)
6868
}
6969

7070
int
71-
stat(char *n, struct stat *st)
71+
stat(const char *n, struct stat *st)
7272
{
7373
int fd;
7474
int r;
@@ -93,9 +93,10 @@ atoi(const char *s)
9393
}
9494

9595
void*
96-
memmove(void *vdst, void *vsrc, int n)
96+
memmove(void *vdst, const void *vsrc, int n)
9797
{
98-
char *dst, *src;
98+
char *dst;
99+
const char *src;
99100

100101
dst = vdst;
101102
src = vsrc;

user.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,33 @@ int fork(void);
66
int exit(void) __attribute__((noreturn));
77
int wait(void);
88
int pipe(int*);
9-
int write(int, void*, int);
9+
int write(int, const void*, int);
1010
int read(int, void*, int);
1111
int close(int);
1212
int kill(int);
1313
int exec(char*, char**);
14-
int open(char*, int);
15-
int mknod(char*, short, short);
16-
int unlink(char*);
14+
int open(const char*, int);
15+
int mknod(const char*, short, short);
16+
int unlink(const char*);
1717
int fstat(int fd, struct stat*);
18-
int link(char*, char*);
19-
int mkdir(char*);
20-
int chdir(char*);
18+
int link(const char*, const char*);
19+
int mkdir(const char*);
20+
int chdir(const char*);
2121
int dup(int);
2222
int getpid(void);
2323
char* sbrk(int);
2424
int sleep(int);
2525
int uptime(void);
2626

2727
// ulib.c
28-
int stat(char*, struct stat*);
29-
char* strcpy(char*, char*);
30-
void *memmove(void*, void*, int);
28+
int stat(const char*, struct stat*);
29+
char* strcpy(char*, const char*);
30+
void *memmove(void*, const void*, int);
3131
char* strchr(const char*, char c);
3232
int strcmp(const char*, const char*);
33-
void printf(int, char*, ...);
33+
void printf(int, const char*, ...);
3434
char* gets(char*, int max);
35-
uint strlen(char*);
35+
uint strlen(const char*);
3636
void* memset(void*, int, uint);
3737
void* malloc(uint);
3838
void free(void*);

0 commit comments

Comments
 (0)