James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | From: PJ Reiniger <pj.reiniger@gmail.com> |
| 3 | Date: Tue, 26 Apr 2022 15:09:43 -0400 |
| 4 | Subject: [PATCH 03/10] Fix warnings |
| 5 | |
| 6 | --- |
| 7 | include/uv/win.h | 5 +++++ |
| 8 | src/idna.c | 2 +- |
| 9 | src/inet.c | 4 ++++ |
| 10 | src/threadpool.c | 4 ++++ |
| 11 | src/unix/core.c | 12 ++++++++++-- |
| 12 | src/unix/internal.h | 4 ++-- |
| 13 | src/unix/linux.c | 15 ++++++++++++--- |
| 14 | src/unix/thread.c | 6 ------ |
| 15 | src/uv-common.c | 8 ++++++++ |
| 16 | src/win/fs-event.c | 2 ++ |
| 17 | src/win/fs.c | 2 ++ |
| 18 | src/win/pipe.c | 2 ++ |
| 19 | src/win/process.c | 2 ++ |
| 20 | src/win/thread.c | 4 ++-- |
| 21 | src/win/tty.c | 2 ++ |
| 22 | 15 files changed, 58 insertions(+), 16 deletions(-) |
| 23 | |
| 24 | diff --git a/include/uv/win.h b/include/uv/win.h |
| 25 | index eb74776978340a4910194bae35a9da6493e8c0a6..6d0afe69e7dd4caf4c9459e548fe75cf0c51b501 100644 |
| 26 | --- a/include/uv/win.h |
| 27 | +++ b/include/uv/win.h |
| 28 | @@ -201,11 +201,16 @@ typedef int (WSAAPI* LPFN_WSARECVFROM) |
| 29 | LPWSAOVERLAPPED overlapped, |
| 30 | LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); |
| 31 | |
| 32 | +#pragma warning(push) |
| 33 | +#pragma warning(disable : 28251) |
| 34 | + |
| 35 | #ifndef _NTDEF_ |
| 36 | typedef LONG NTSTATUS; |
| 37 | typedef NTSTATUS *PNTSTATUS; |
| 38 | #endif |
| 39 | |
| 40 | +#pragma warning(pop) |
| 41 | + |
| 42 | #ifndef RTL_CONDITION_VARIABLE_INIT |
| 43 | typedef PVOID CONDITION_VARIABLE, *PCONDITION_VARIABLE; |
| 44 | #endif |
| 45 | diff --git a/src/idna.c b/src/idna.c |
| 46 | index 93d982ca018f2d39d9c0ffab07998c2c637029eb..36a39a089019fb4c2a35ec84516658c392eec0a3 100644 |
| 47 | --- a/src/idna.c |
| 48 | +++ b/src/idna.c |
| 49 | @@ -106,7 +106,7 @@ static int uv__idna_toascii_label(const char* s, const char* se, |
| 50 | char** d, char* de) { |
| 51 | static const char alphabet[] = "abcdefghijklmnopqrstuvwxyz0123456789"; |
| 52 | const char* ss; |
| 53 | - unsigned c; |
| 54 | + unsigned c = 0; |
| 55 | unsigned h; |
| 56 | unsigned k; |
| 57 | unsigned n; |
| 58 | diff --git a/src/inet.c b/src/inet.c |
| 59 | index dd94bea3886ca37945fcad7909d765e3700e3c21..71c9e5b774d64d505e6c6d6ed2637178b8532d4d 100644 |
| 60 | --- a/src/inet.c |
| 61 | +++ b/src/inet.c |
| 62 | @@ -22,6 +22,10 @@ |
| 63 | #include "uv.h" |
| 64 | #include "uv-common.h" |
| 65 | |
| 66 | +#ifdef _WIN32 |
| 67 | +#pragma warning(disable : 6001) |
| 68 | +#endif |
| 69 | + |
| 70 | #define UV__INET_ADDRSTRLEN 16 |
| 71 | #define UV__INET6_ADDRSTRLEN 46 |
| 72 | |
| 73 | diff --git a/src/threadpool.c b/src/threadpool.c |
| 74 | index f572de5aaf1a1b150e58c7b989949441cac279c4..aa282af468935b680140295a175e503ca82d8fa4 100644 |
| 75 | --- a/src/threadpool.c |
| 76 | +++ b/src/threadpool.c |
| 77 | @@ -27,6 +27,10 @@ |
| 78 | |
| 79 | #include <stdlib.h> |
| 80 | |
| 81 | +#ifdef _WIN32 |
| 82 | +#pragma warning(disable: 6001 6011) |
| 83 | +#endif |
| 84 | + |
| 85 | #define MAX_THREADPOOL_SIZE 1024 |
| 86 | |
| 87 | static uv_once_t once = UV_ONCE_INIT; |
| 88 | diff --git a/src/unix/core.c b/src/unix/core.c |
| 89 | index 28c036f94f3e76717afa651451969f128c5a573c..268fc9652f437eb0d0cda2a9e0b06b9e91eb9742 100644 |
| 90 | --- a/src/unix/core.c |
| 91 | +++ b/src/unix/core.c |
| 92 | @@ -575,6 +575,16 @@ int uv__accept(int sockfd) { |
| 93 | return peerfd; |
| 94 | } |
| 95 | |
| 96 | +#if defined(__APPLE__) |
| 97 | +#pragma GCC diagnostic push |
| 98 | +#pragma GCC diagnostic ignored "-Wdollar-in-identifier-extension" |
| 99 | +#if defined(__LP64__) |
| 100 | + extern "C" int close$NOCANCEL(int); |
| 101 | +#else |
| 102 | + extern "C" int close$NOCANCEL$UNIX2003(int); |
| 103 | +#endif |
| 104 | +#pragma GCC diagnostic pop |
| 105 | +#endif |
| 106 | |
| 107 | /* close() on macos has the "interesting" quirk that it fails with EINTR |
| 108 | * without closing the file descriptor when a thread is in the cancel state. |
| 109 | @@ -589,10 +599,8 @@ int uv__close_nocancel(int fd) { |
| 110 | #pragma GCC diagnostic push |
| 111 | #pragma GCC diagnostic ignored "-Wdollar-in-identifier-extension" |
| 112 | #if defined(__LP64__) || TARGET_OS_IPHONE |
| 113 | - extern int close$NOCANCEL(int); |
| 114 | return close$NOCANCEL(fd); |
| 115 | #else |
| 116 | - extern int close$NOCANCEL$UNIX2003(int); |
| 117 | return close$NOCANCEL$UNIX2003(fd); |
| 118 | #endif |
| 119 | #pragma GCC diagnostic pop |
| 120 | diff --git a/src/unix/internal.h b/src/unix/internal.h |
| 121 | index fe5885136039d5332623467b86bf52cd4b32ca0f..98c437dcadec5b5106d697e82d5394d459f55e47 100644 |
| 122 | --- a/src/unix/internal.h |
| 123 | +++ b/src/unix/internal.h |
| 124 | @@ -384,8 +384,8 @@ UV_UNUSED(static void uv__update_time(uv_loop_t* loop)) { |
| 125 | loop->time = uv__hrtime(UV_CLOCK_FAST) / 1000000; |
| 126 | } |
| 127 | |
| 128 | -UV_UNUSED(static char* uv__basename_r(const char* path)) { |
| 129 | - char* s; |
| 130 | +UV_UNUSED(static const char* uv__basename_r(const char* path)) { |
| 131 | + const char* s; |
| 132 | |
| 133 | s = strrchr(path, '/'); |
| 134 | if (s == NULL) |
| 135 | diff --git a/src/unix/linux.c b/src/unix/linux.c |
| 136 | index 9173850bd158eaf9c41deca38f9ba84762a027a1..157443792f1216c83b4221c3810d17c81c5913c4 100644 |
| 137 | --- a/src/unix/linux.c |
| 138 | +++ b/src/unix/linux.c |
| 139 | @@ -1718,7 +1718,11 @@ int uv_cpu_info(uv_cpu_info_t** ci, int* count) { |
| 140 | return UV__ERR(errno); |
| 141 | } |
| 142 | |
| 143 | - fgets(buf, sizeof(buf), fp); /* Skip first line. */ |
| 144 | + /* Skip first line. */ |
| 145 | + if (!fgets(buf, sizeof(buf), fp)) { |
| 146 | + uv__free(cpus); |
| 147 | + return UV__ERR(errno); |
| 148 | + } |
| 149 | |
| 150 | for (;;) { |
| 151 | memset(&t, 0, sizeof(t)); |
| 152 | @@ -1729,7 +1733,10 @@ int uv_cpu_info(uv_cpu_info_t** ci, int* count) { |
| 153 | if (n != 7) |
| 154 | break; |
| 155 | |
| 156 | - fgets(buf, sizeof(buf), fp); /* Skip rest of line. */ |
| 157 | + /* Skip rest of line. */ |
| 158 | + if (!fgets(buf, sizeof(buf), fp)) { |
| 159 | + break; |
| 160 | + } |
| 161 | |
| 162 | if (cpu >= ARRAY_SIZE(*cpus)) |
| 163 | continue; |
| 164 | @@ -1809,7 +1816,9 @@ nocpuinfo: |
| 165 | if (fp == NULL) |
| 166 | continue; |
| 167 | |
| 168 | - fscanf(fp, "%llu", &(*cpus)[cpu].freq); |
| 169 | + if (0 > fscanf(fp, "%llu", &(*cpus)[cpu].freq)) { |
| 170 | + (*cpus)[cpu].freq = 0llu; |
| 171 | + } |
| 172 | fclose(fp); |
| 173 | fp = NULL; |
| 174 | } |
| 175 | diff --git a/src/unix/thread.c b/src/unix/thread.c |
| 176 | index 531c6211bb4321e5f11031a0644b4e3ab9174396..f8600947e3e7df015c4302af4feee740707b2c46 100644 |
| 177 | --- a/src/unix/thread.c |
| 178 | +++ b/src/unix/thread.c |
| 179 | @@ -137,12 +137,6 @@ int uv_thread_create_ex(uv_thread_t* tid, |
| 180 | size_t stack_size; |
| 181 | size_t min_stack_size; |
| 182 | |
| 183 | - /* Used to squelch a -Wcast-function-type warning. */ |
| 184 | - union { |
| 185 | - void (*in)(void*); |
| 186 | - void* (*out)(void*); |
| 187 | - } f; |
| 188 | - |
| 189 | stack_size = |
| 190 | params->flags & UV_THREAD_HAS_STACK_SIZE ? params->stack_size : 0; |
| 191 | |
| 192 | diff --git a/src/uv-common.c b/src/uv-common.c |
| 193 | index c04f93596ab1f730576256d86e216ccb7f258b72..cd10b36b4a393e325ea03b93eb9897193ca9800b 100644 |
| 194 | --- a/src/uv-common.c |
| 195 | +++ b/src/uv-common.c |
| 196 | @@ -799,6 +799,10 @@ void uv__fs_readdir_cleanup(uv_fs_t* req) { |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | +#ifdef __clang__ |
| 201 | +# pragma clang diagnostic push |
| 202 | +# pragma clang diagnostic ignored "-Wvarargs" |
| 203 | +#endif |
| 204 | |
| 205 | int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...) { |
| 206 | va_list ap; |
| 207 | @@ -812,6 +816,10 @@ int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...) { |
| 208 | return err; |
| 209 | } |
| 210 | |
| 211 | +#ifdef __clang__ |
| 212 | +# pragma clang diagnostic pop |
| 213 | +#endif |
| 214 | + |
| 215 | |
| 216 | static uv_loop_t default_loop_struct; |
| 217 | static uv_loop_t* default_loop_ptr; |
| 218 | diff --git a/src/win/fs-event.c b/src/win/fs-event.c |
| 219 | index 150467313d576bfe2966b55f3d8cffa23cbb8ea3..3244a4e4320d7ce98f226b49b2634c65de89c213 100644 |
| 220 | --- a/src/win/fs-event.c |
| 221 | +++ b/src/win/fs-event.c |
| 222 | @@ -19,6 +19,8 @@ |
| 223 | * IN THE SOFTWARE. |
| 224 | */ |
| 225 | |
| 226 | +#define _CRT_NONSTDC_NO_WARNINGS |
| 227 | + |
| 228 | #include <assert.h> |
| 229 | #include <errno.h> |
| 230 | #include <stdio.h> |
| 231 | diff --git a/src/win/fs.c b/src/win/fs.c |
| 232 | index 328c8f2e0513562b53c948ffea59d0841e14b264..565c05fff13c2e6e74091c1da7b31636d7fd370d 100644 |
| 233 | --- a/src/win/fs.c |
| 234 | +++ b/src/win/fs.c |
| 235 | @@ -19,6 +19,8 @@ |
| 236 | * IN THE SOFTWARE. |
| 237 | */ |
| 238 | |
| 239 | +#define _CRT_NONSTDC_NO_WARNINGS |
| 240 | + |
| 241 | #include <assert.h> |
| 242 | #include <stdlib.h> |
| 243 | #include <direct.h> |
| 244 | diff --git a/src/win/pipe.c b/src/win/pipe.c |
| 245 | index c1739efe82b8755999145860b4da6b50c73518a2..258d6a684c67f154096a25e7226f1a7d08b93d5b 100644 |
| 246 | --- a/src/win/pipe.c |
| 247 | +++ b/src/win/pipe.c |
| 248 | @@ -19,6 +19,8 @@ |
| 249 | * IN THE SOFTWARE. |
| 250 | */ |
| 251 | |
| 252 | +#define _CRT_NONSTDC_NO_WARNINGS |
| 253 | + |
| 254 | #include <assert.h> |
| 255 | #include <io.h> |
| 256 | #include <stdio.h> |
| 257 | diff --git a/src/win/process.c b/src/win/process.c |
| 258 | index b383e8b405db56d413985b38df216d09c58ec4a0..2b1b46259959867482079962d0ea44246a42e7cb 100644 |
| 259 | --- a/src/win/process.c |
| 260 | +++ b/src/win/process.c |
| 261 | @@ -19,6 +19,8 @@ |
| 262 | * IN THE SOFTWARE. |
| 263 | */ |
| 264 | |
| 265 | +#define _CRT_NONSTDC_NO_WARNINGS |
| 266 | + |
| 267 | #include <assert.h> |
| 268 | #include <io.h> |
| 269 | #include <stdio.h> |
| 270 | diff --git a/src/win/thread.c b/src/win/thread.c |
| 271 | index 57f1698f595e2410a51044f7f228b5a235206819..03b33e9b4de6fe2532095d717a8639e8df454cce 100644 |
| 272 | --- a/src/win/thread.c |
| 273 | +++ b/src/win/thread.c |
| 274 | @@ -204,8 +204,8 @@ int uv_thread_setaffinity(uv_thread_t* tid, |
| 275 | threadmask = 0; |
| 276 | for (i = 0; i < cpumasksize; i++) { |
| 277 | if (cpumask[i]) { |
| 278 | - if (procmask & (1 << i)) |
| 279 | - threadmask |= 1 << i; |
| 280 | + if (procmask & (1LL << i)) |
| 281 | + threadmask |= 1LL << i; |
| 282 | else |
| 283 | return UV_EINVAL; |
| 284 | } |
| 285 | diff --git a/src/win/tty.c b/src/win/tty.c |
| 286 | index 7e1f15544b177382a774300f832bc982d85bd62b..abbe1315883257d6825b794344dcd4cba9514097 100644 |
| 287 | --- a/src/win/tty.c |
| 288 | +++ b/src/win/tty.c |
| 289 | @@ -19,6 +19,8 @@ |
| 290 | * IN THE SOFTWARE. |
| 291 | */ |
| 292 | |
| 293 | +#define _CRT_NONSTDC_NO_WARNINGS |
| 294 | + |
| 295 | #include <assert.h> |
| 296 | #include <io.h> |
| 297 | #include <string.h> |