diff options
author | Anton Kling <anton@kling.gg> | 2023-11-23 00:52:35 +0100 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2023-11-23 00:52:35 +0100 |
commit | 81819f711e6d1f9216f688da8ecbbc682d106d9c (patch) | |
tree | 0f0df7c43cc5bc956c2c067e55766bfa90823a7f /userland/libc/stdio | |
parent | ec91e81a4fcfd7ee6bc4150f06d8740e82f808da (diff) |
LibC: Reduce warnings in code
Diffstat (limited to 'userland/libc/stdio')
-rw-r--r-- | userland/libc/stdio/fopen.c | 5 | ||||
-rw-r--r-- | userland/libc/stdio/open_memstream.c | 3 | ||||
-rw-r--r-- | userland/libc/stdio/remove.c | 1 | ||||
-rw-r--r-- | userland/libc/stdio/rename.c | 9 | ||||
-rw-r--r-- | userland/libc/stdio/stdin.c | 5 | ||||
-rw-r--r-- | userland/libc/stdio/tmpnam.c | 2 | ||||
-rw-r--r-- | userland/libc/stdio/vfprintf.c | 1 |
7 files changed, 18 insertions, 8 deletions
diff --git a/userland/libc/stdio/fopen.c b/userland/libc/stdio/fopen.c index 6a3f374..d31082d 100644 --- a/userland/libc/stdio/fopen.c +++ b/userland/libc/stdio/fopen.c @@ -1,6 +1,7 @@ #include <fcntl.h> #include <stdint.h> #include <stdio.h> +#include <stdlib.h> #include <sys/stat.h> // FIXME: All modes not implemented @@ -8,7 +9,7 @@ FILE *fopen(const char *pathname, const char *mode) { uint8_t read = 0; uint8_t write = 0; - uint8_t append = 0; +// uint8_t append = 0; // FIXME: Not parsed correctly for (; *mode; mode++) { // r or rb @@ -26,7 +27,7 @@ FILE *fopen(const char *pathname, const char *mode) { write = 1; break; case 'a': - append = 1; +// append = 1; break; } } diff --git a/userland/libc/stdio/open_memstream.c b/userland/libc/stdio/open_memstream.c index 8f359b9..0d3df86 100644 --- a/userland/libc/stdio/open_memstream.c +++ b/userland/libc/stdio/open_memstream.c @@ -1,4 +1,5 @@ #include <assert.h> +#include <math.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> @@ -34,7 +35,7 @@ size_t memstream_write(FILE *fp, const unsigned char *buf, size_t n) { memcpy(c->buffer + fp->offset_in_file, buf, n); fp->offset_in_file += n; - if (fp->offset_in_file > c->buffer_usage) + if (fp->offset_in_file > (long)c->buffer_usage) c->buffer_usage = fp->offset_in_file; return n; } diff --git a/userland/libc/stdio/remove.c b/userland/libc/stdio/remove.c index 35b41ad..39f8af2 100644 --- a/userland/libc/stdio/remove.c +++ b/userland/libc/stdio/remove.c @@ -3,6 +3,7 @@ extern int errno; int remove(const char *path) { + (void)path; // FIXME errno = ENAMETOOLONG; return -1; diff --git a/userland/libc/stdio/rename.c b/userland/libc/stdio/rename.c index 15d4bf5..a02cacb 100644 --- a/userland/libc/stdio/rename.c +++ b/userland/libc/stdio/rename.c @@ -1,8 +1,9 @@ -#include <stdio.h> #include <assert.h> +#include <stdio.h> int rename(const char *old, const char *new) { - (void)old; - (void)new; + (void)old; + (void)new; assert(0); // TODO: Implement - } + return 0; +} diff --git a/userland/libc/stdio/stdin.c b/userland/libc/stdio/stdin.c index c424cc5..bc5c6f2 100644 --- a/userland/libc/stdio/stdin.c +++ b/userland/libc/stdio/stdin.c @@ -1,9 +1,11 @@ #include <assert.h> +#include <math.h> #include <stdio.h> +#include <stdlib.h> #include <unistd.h> size_t raw_write_fd(FILE *f, const unsigned char *s, size_t l) { - int rc = pwrite(f->fd, s, l, f->offset_in_file); + int rc = pwrite(f->fd, (char *)s, l, f->offset_in_file); if (rc == -1) { f->has_error = 1; return 0; @@ -84,6 +86,7 @@ size_t read_fd(FILE *f, unsigned char *s, size_t l) { return read_fd(f, s, l); } assert(0); + return 0; } int seek_fd(FILE *stream, long offset, int whence) { diff --git a/userland/libc/stdio/tmpnam.c b/userland/libc/stdio/tmpnam.c index aafe67d..3fe93fa 100644 --- a/userland/libc/stdio/tmpnam.c +++ b/userland/libc/stdio/tmpnam.c @@ -1,5 +1,7 @@ #include <assert.h> #include <stdio.h> +#include <stdlib.h> +#include <string.h> char *tmpnam(char *s) { assert(!s); diff --git a/userland/libc/stdio/vfprintf.c b/userland/libc/stdio/vfprintf.c index b2d4902..c3a8de7 100644 --- a/userland/libc/stdio/vfprintf.c +++ b/userland/libc/stdio/vfprintf.c @@ -2,6 +2,7 @@ #include <stddef.h> #include <stdint.h> #include <stdio.h> +#include <string.h> const char HEX_SET[0x10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; |