]> git.proxmox.com Git - wasi-libc.git/commitdiff
Fix miscellaneous lint warnings.
authorDan Gohman <sunfish@mozilla.com>
Thu, 11 Apr 2019 22:39:30 +0000 (15:39 -0700)
committerDan Gohman <sunfish@mozilla.com>
Mon, 15 Apr 2019 16:47:16 +0000 (09:47 -0700)
17 files changed:
dlmalloc/src/dlmalloc.c
expected/wasm32-wasi/predefined-macros.txt
libc-bottom-half/cloudlibc/src/libc/unistd/__wasilibc_rmdirat.c
libc-bottom-half/cloudlibc/src/libc/unistd/__wasilibc_rmfileat.c
libc-bottom-half/headers/public/__header_stdlib.h
libc-bottom-half/sources/__wasilibc_fd_renumber.c
libc-bottom-half/sources/abort.c
libc-bottom-half/sources/getentropy.c
libc-bottom-half/sources/pause.c
libc-top-half/musl/include/malloc.h
libc-top-half/musl/include/stdarg.h
libc-top-half/musl/include/stdlib.h
libc-top-half/musl/include/string.h
libc-top-half/musl/include/sys/un.h
libc-top-half/musl/src/stdio/getc.h
libc-top-half/musl/src/stdio/putc.h
libc-top-half/sources/arc4random.c

index 9fd23a4b7e8e4236cf201eea3f4dabfb4e8cbc25..c84205689c8f31604cedae0042f96fa99fade842 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 #include <stddef.h>
+#include <malloc.h>
 
 /* 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) {
index 984cae11c32821aa25a7e482d9cb746a6235236d..676e91689dc58d958920e7dd2b2105e6d43aa5dd 100644 (file)
 #define _SIGNAL_H 
 #define _SIZE_T 
 #define _STDALIGN_H 
-#define _STDARG_H 
 #define _STDBOOL_H 
 #define _STDC_PREDEF_H 
 #define _STDDEF_H 
index 2a6e346dbe0d423340e0624c582017e587ccc882..713b6289af84ff1cecd77d9aed867db4a427a603 100644 (file)
@@ -1,5 +1,6 @@
 #include <common/errno.h>
 #include <wasi/core.h>
+#include <wasi/libc.h>
 #include <errno.h>
 #include <string.h>
 
index c2f58c3f5e0cbf0bcf70c9939ca384ba2964b394..aece605bfee5b9343c28c9b560f7da3fe8950389 100644 (file)
@@ -1,5 +1,6 @@
 #include <common/errno.h>
 #include <wasi/core.h>
+#include <wasi/libc.h>
 #include <errno.h>
 #include <string.h>
 
index d5048b3ca459b317ffaf6e5cb271872f5d89ec7f..99be45832473f98f7a69242d9d972bcda90c9efe 100644 (file)
@@ -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
 }
index 1c3c8d9730a85d0699a8ae92d1789df48313de70..a7d33c53c76599a544cefe7f922dc8ae1708a350 100644 (file)
@@ -1,4 +1,5 @@
 #include <wasi/core.h>
+#include <wasi/libc.h>
 #include <errno.h>
 #include <unistd.h>
 
index 36a4dc7956ede86d5670211ccc09971a6bc72a6d..bb1c7dd49d111ee959558f4c228d1c47e7178819 100644 (file)
@@ -1,3 +1,5 @@
+#include <stdlib.h>
+
 void abort(void) {
     // WASI doesn't yet support signals, so just trap to halt the program.
     __builtin_trap();
index 4d9e2ae4ab2d39f7e6313f95e207f4106e60915b..83bee6eae4d05c907cb910029552e2833171791d 100644 (file)
@@ -1,5 +1,6 @@
 #include <wasi/core.h>
 #include <errno.h>
+#include <unistd.h>
 
 #ifdef _REENTRANT
 #error With threads support, getentropy is not intended to be a cancellation point.
index 652b783c60f5085d52428c3231b91d28c614c96a..aa64428f631c76a005a5be1acc8dbd827328fc35 100644 (file)
@@ -1,6 +1,7 @@
 #include <stddef.h>
 #include <errno.h>
 #include <wasi/core.h>
+#include <unistd.h>
 
 int pause(void) {
     size_t n;
index 35f8b19c2c340d510c7aeaf4a5401b54acbc1d0b..25f0f2bf158d04b5e296961517b8079820289633 100644 (file)
@@ -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 <bits/alltypes.h>
 
+#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);
 
index 410a4f90b89abc807fa88fb7c052946178511cbb..0c69316d0b43c909d534fd4014c2b4bc3b106fd7 100644 (file)
@@ -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 <stdarg.h>
 #endif
-
-#endif
index a09183a06fce7c86e5acc5c3676373f00f6b38e4..d2e3526483b15bebeb1a8855fa7f6dbc3bc8f7d7 100644 (file)
@@ -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 <stddef.h>
 #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);
index a6e7633251df882fd38366eb249dc90baedde3b3..c2d464c8897cc7e797ee947240e1a8dc489ec548 100644 (file)
@@ -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 <bits/alltypes.h>
 
+#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);
index df144216979838a5014dd8f6a7a463374721956a..71169567172c40860b513b93deeee40ab4d7bde7 100644 (file)
@@ -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 <string.h> 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
 
index 393bd5e1df9d03bf08dc0c5322f4bef7ab826ab5..c61dd64230df5fee6a2f70890106622030428874 100644 (file)
@@ -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);
index 7ebeeb6144298e3b60f6454a033a70499648bc29..6173fd48e1c0ed6e3217bb6efc79e4c4c946acea 100644 (file)
@@ -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);
index 52186e485b0f90f6e3abf968b7b6ae89c01265bd..eb7c5a66397197eea11882677209c452b7df997d 100644 (file)
@@ -2,6 +2,7 @@
 #include <stdint.h>
 #include <string.h>
 #include <unistd.h>
+#include <stdlib.h>
 
 #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) {