From: Dan Gohman Date: Thu, 11 Apr 2019 22:39:30 +0000 (-0700) Subject: Fix miscellaneous lint warnings. X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=7ba6adfc61ce58bcc2bd4490606d3f91859b770b;p=wasi-libc.git Fix miscellaneous lint warnings. --- diff --git a/dlmalloc/src/dlmalloc.c b/dlmalloc/src/dlmalloc.c index 9fd23a4..c842056 100644 --- a/dlmalloc/src/dlmalloc.c +++ b/dlmalloc/src/dlmalloc.c @@ -4,6 +4,7 @@ */ #include +#include /* Define configuration macros for dlmalloc. */ @@ -54,7 +55,7 @@ void *malloc(size_t size) { } void free(void *ptr) { - return dlfree(ptr); + dlfree(ptr); } void *calloc(size_t nmemb, size_t size) { diff --git a/expected/wasm32-wasi/predefined-macros.txt b/expected/wasm32-wasi/predefined-macros.txt index 984cae1..676e916 100644 --- a/expected/wasm32-wasi/predefined-macros.txt +++ b/expected/wasm32-wasi/predefined-macros.txt @@ -2820,7 +2820,6 @@ #define _SIGNAL_H #define _SIZE_T #define _STDALIGN_H -#define _STDARG_H #define _STDBOOL_H #define _STDC_PREDEF_H #define _STDDEF_H diff --git a/libc-bottom-half/cloudlibc/src/libc/unistd/__wasilibc_rmdirat.c b/libc-bottom-half/cloudlibc/src/libc/unistd/__wasilibc_rmdirat.c index 2a6e346..713b628 100644 --- a/libc-bottom-half/cloudlibc/src/libc/unistd/__wasilibc_rmdirat.c +++ b/libc-bottom-half/cloudlibc/src/libc/unistd/__wasilibc_rmdirat.c @@ -1,5 +1,6 @@ #include #include +#include #include #include diff --git a/libc-bottom-half/cloudlibc/src/libc/unistd/__wasilibc_rmfileat.c b/libc-bottom-half/cloudlibc/src/libc/unistd/__wasilibc_rmfileat.c index c2f58c3..aece605 100644 --- a/libc-bottom-half/cloudlibc/src/libc/unistd/__wasilibc_rmfileat.c +++ b/libc-bottom-half/cloudlibc/src/libc/unistd/__wasilibc_rmfileat.c @@ -1,5 +1,6 @@ #include #include +#include #include #include diff --git a/libc-bottom-half/headers/public/__header_stdlib.h b/libc-bottom-half/headers/public/__header_stdlib.h index d5048b3..99be458 100644 --- a/libc-bottom-half/headers/public/__header_stdlib.h +++ b/libc-bottom-half/headers/public/__header_stdlib.h @@ -12,6 +12,7 @@ extern "C" { void abort(void) __attribute__((__noreturn__)); void qsort(void *, size_t, size_t, int (*)(const void *, const void *)); +void _Exit(int) __attribute__((__noreturn__)); #ifdef __cplusplus } diff --git a/libc-bottom-half/sources/__wasilibc_fd_renumber.c b/libc-bottom-half/sources/__wasilibc_fd_renumber.c index 1c3c8d9..a7d33c5 100644 --- a/libc-bottom-half/sources/__wasilibc_fd_renumber.c +++ b/libc-bottom-half/sources/__wasilibc_fd_renumber.c @@ -1,4 +1,5 @@ #include +#include #include #include diff --git a/libc-bottom-half/sources/abort.c b/libc-bottom-half/sources/abort.c index 36a4dc7..bb1c7dd 100644 --- a/libc-bottom-half/sources/abort.c +++ b/libc-bottom-half/sources/abort.c @@ -1,3 +1,5 @@ +#include + void abort(void) { // WASI doesn't yet support signals, so just trap to halt the program. __builtin_trap(); diff --git a/libc-bottom-half/sources/getentropy.c b/libc-bottom-half/sources/getentropy.c index 4d9e2ae..83bee6e 100644 --- a/libc-bottom-half/sources/getentropy.c +++ b/libc-bottom-half/sources/getentropy.c @@ -1,5 +1,6 @@ #include #include +#include #ifdef _REENTRANT #error With threads support, getentropy is not intended to be a cancellation point. diff --git a/libc-bottom-half/sources/pause.c b/libc-bottom-half/sources/pause.c index 652b783..aa64428 100644 --- a/libc-bottom-half/sources/pause.c +++ b/libc-bottom-half/sources/pause.c @@ -1,6 +1,7 @@ #include #include #include +#include int pause(void) { size_t n; diff --git a/libc-top-half/musl/include/malloc.h b/libc-top-half/musl/include/malloc.h index 35f8b19..25f0f2b 100644 --- a/libc-top-half/musl/include/malloc.h +++ b/libc-top-half/musl/include/malloc.h @@ -1,6 +1,10 @@ #ifndef _MALLOC_H #define _MALLOC_H +#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ +#else +#include <__functions_malloc.h> +#endif #ifdef __cplusplus extern "C" { #endif @@ -9,10 +13,12 @@ extern "C" { #include +#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ void *malloc (size_t); void *calloc (size_t, size_t); void *realloc (void *, size_t); void free (void *); +#endif void *valloc (size_t); void *memalign(size_t, size_t); diff --git a/libc-top-half/musl/include/stdarg.h b/libc-top-half/musl/include/stdarg.h index 410a4f9..0c69316 100644 --- a/libc-top-half/musl/include/stdarg.h +++ b/libc-top-half/musl/include/stdarg.h @@ -1,7 +1,7 @@ +#ifdef __wasilibc_unmodified_upstream /* Use the compiler's stdarg.h */ #ifndef _STDARG_H #define _STDARG_H -#ifdef __wasilibc_unmodified_upstream /* Use the compiler's stdarg.h */ #ifdef __cplusplus extern "C" { #endif @@ -17,10 +17,10 @@ extern "C" { #ifdef __cplusplus } +#endif + #endif #else /* Just use the compiler's stdarg.h. */ #include_next #endif - -#endif diff --git a/libc-top-half/musl/include/stdlib.h b/libc-top-half/musl/include/stdlib.h index a09183a..d2e3526 100644 --- a/libc-top-half/musl/include/stdlib.h +++ b/libc-top-half/musl/include/stdlib.h @@ -1,6 +1,11 @@ #ifndef _STDLIB_H #define _STDLIB_H +#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ +#else +#include <__functions_malloc.h> +#include <__header_stdlib.h> +#endif #ifdef __cplusplus extern "C" { #endif @@ -14,7 +19,6 @@ extern "C" { #define NULL ((void*)0) #endif #else -#include <__header_stdlib.h> #define __need_NULL #include #endif @@ -41,10 +45,12 @@ unsigned long long strtoull (const char *__restrict, char **__restrict, int); int rand (void); void srand (unsigned); +#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ void *malloc (size_t); void *calloc (size_t, size_t); void *realloc (void *, size_t); void free (void *); +#endif void *aligned_alloc(size_t, size_t); _Noreturn void abort (void); diff --git a/libc-top-half/musl/include/string.h b/libc-top-half/musl/include/string.h index a6e7633..c2d464c 100644 --- a/libc-top-half/musl/include/string.h +++ b/libc-top-half/musl/include/string.h @@ -1,6 +1,10 @@ #ifndef _STRING_H #define _STRING_H +#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ +#else +#include <__header_string.h> +#endif #ifdef __cplusplus extern "C" { #endif @@ -27,11 +31,15 @@ extern "C" { #include +#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ void *memcpy (void *__restrict, const void *__restrict, size_t); void *memmove (void *, const void *, size_t); void *memset (void *, int, size_t); +#endif int memcmp (const void *, const void *, size_t); +#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ void *memchr (const void *, int, size_t); +#endif char *strcpy (char *__restrict, const char *__restrict); char *strncpy (char *__restrict, const char *__restrict, size_t); @@ -39,7 +47,9 @@ char *strncpy (char *__restrict, const char *__restrict, size_t); char *strcat (char *__restrict, const char *__restrict); char *strncat (char *__restrict, const char *__restrict, size_t); +#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ int strcmp (const char *, const char *); +#endif int strncmp (const char *, const char *, size_t); int strcoll (const char *, const char *); @@ -54,7 +64,9 @@ char *strpbrk (const char *, const char *); char *strstr (const char *, const char *); char *strtok (char *__restrict, const char *__restrict); +#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ size_t strlen (const char *); +#endif char *strerror (int); @@ -70,7 +82,9 @@ int strerror_r (int, char *, size_t); char *stpcpy(char *__restrict, const char *__restrict); char *stpncpy(char *__restrict, const char *__restrict, size_t); size_t strnlen (const char *, size_t); +#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ char *strdup (const char *); +#endif char *strndup (const char *, size_t); char *strsignal(int); char *strerror_l (int, locale_t); diff --git a/libc-top-half/musl/include/sys/un.h b/libc-top-half/musl/include/sys/un.h index df14421..7116956 100644 --- a/libc-top-half/musl/include/sys/un.h +++ b/libc-top-half/musl/include/sys/un.h @@ -24,7 +24,11 @@ struct sockaddr_un { #endif #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#ifdef __wasilibc_unmodified_upstream /* Declare strlen with the same attributes as uses */ size_t strlen(const char *); +#else +size_t strlen(const char *) __attribute__((__nothrow__, __leaf__, __pure__, __nonnull__(1))); +#endif #define SUN_LEN(s) (2+strlen((s)->sun_path)) #endif diff --git a/libc-top-half/musl/src/stdio/getc.h b/libc-top-half/musl/src/stdio/getc.h index 393bd5e..c61dd64 100644 --- a/libc-top-half/musl/src/stdio/getc.h +++ b/libc-top-half/musl/src/stdio/getc.h @@ -17,8 +17,8 @@ static int locking_getc(FILE *f) static inline int do_getc(FILE *f) { - int l = f->lock; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) + int l = f->lock; if (l < 0 || l && (l & ~MAYBE_WAITERS) == __pthread_self()->tid) return getc_unlocked(f); return locking_getc(f); diff --git a/libc-top-half/musl/src/stdio/putc.h b/libc-top-half/musl/src/stdio/putc.h index 7ebeeb6..6173fd4 100644 --- a/libc-top-half/musl/src/stdio/putc.h +++ b/libc-top-half/musl/src/stdio/putc.h @@ -17,8 +17,8 @@ static int locking_putc(int c, FILE *f) static inline int do_putc(int c, FILE *f) { - int l = f->lock; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) + int l = f->lock; if (l < 0 || l && (l & ~MAYBE_WAITERS) == __pthread_self()->tid) return putc_unlocked(c, f); return locking_putc(c, f); diff --git a/libc-top-half/sources/arc4random.c b/libc-top-half/sources/arc4random.c index 52186e4..eb7c5a6 100644 --- a/libc-top-half/sources/arc4random.c +++ b/libc-top-half/sources/arc4random.c @@ -2,6 +2,7 @@ #include #include #include +#include #define RNG_RESERVE_LEN 512 @@ -95,7 +96,6 @@ void arc4random_buf(void* buffer, size_t len) size_t off; size_t remaining; size_t partial; - int ret; if (!rng_state.initialized) { if (getentropy(rng_state.key, sizeof rng_state.key) != 0) {