From 1a3d22b2fde1d8a6bae7929ba729dcb545151207 Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Sun, 16 May 2021 20:34:46 -0700 Subject: [PATCH] Improve LLVM compatibility a little bit --- README.md | 2 +- libc/stdio/spawnf.c | 6 +++--- libc/stdio/tmpfile.c | 2 +- libc/str/iswctype.c | 4 +++- third_party/quickjs/quickjs-libc.c | 4 ++-- third_party/quickjs/quickjs.c | 2 +- third_party/regex/regerror.c | 6 +++--- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 6b8e3839f..8262310f7 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ first run, so it can be fast and efficient for subsequent executions. ```sh ./hello.com -bash -c './hello.com' # zsh/fish workaround (we upstreamed a patch) +bash -c './hello.com' # zsh/fish workaround (we upstreamed patches) ``` So if you intend to copy the binary to Windows or Mac then please do diff --git a/libc/stdio/spawnf.c b/libc/stdio/spawnf.c index 3e893b150..acced624d 100644 --- a/libc/stdio/spawnf.c +++ b/libc/stdio/spawnf.c @@ -59,7 +59,7 @@ static int add_to_file_actions(posix_spawn_file_actions_t *file_actions, int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *file_actions, int fildes) { char temp[100]; - sprintf(temp, "close(%d)", fildes); + (sprintf)(temp, "close(%d)", fildes); return add_to_file_actions(file_actions, temp); } @@ -69,7 +69,7 @@ int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *file_actions, int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *file_actions, int fildes, int newfildes) { char temp[100]; - sprintf(temp, "dup2(%d,%d)", fildes, newfildes); + (sprintf)(temp, "dup2(%d,%d)", fildes, newfildes); return add_to_file_actions(file_actions, temp); } @@ -80,6 +80,6 @@ int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *file_actions, int fildes, const char *path, int oflag, unsigned mode) { char temp[100]; - sprintf(temp, "open(%d,%s*%o,%o)", fildes, path, oflag, mode); + (sprintf)(temp, "open(%d,%s*%o,%o)", fildes, path, oflag, mode); return add_to_file_actions(file_actions, temp); } diff --git a/libc/stdio/tmpfile.c b/libc/stdio/tmpfile.c index b2197e463..1bee40c56 100644 --- a/libc/stdio/tmpfile.c +++ b/libc/stdio/tmpfile.c @@ -35,7 +35,7 @@ FILE *tmpfile(void) { char *tmp, *sep, tpl[PATH_MAX]; tmp = firstnonnull(getenv("TMPDIR"), kTmpPath); sep = !isempty(tmp) && !endswith(tmp, "/") ? "/" : ""; - if (snprintf(tpl, PATH_MAX, "%s%stmp.XXXXXX", tmp, sep) < PATH_MAX) { + if ((snprintf)(tpl, PATH_MAX, "%s%stmp.XXXXXX", tmp, sep) < PATH_MAX) { if ((fd = mkostemps(tpl, 0, 0)) != -1) { return fdopen(fd, "w+"); } diff --git a/libc/str/iswctype.c b/libc/str/iswctype.c index 39bfcf671..a5e0fa401 100644 --- a/libc/str/iswctype.c +++ b/libc/str/iswctype.c @@ -19,7 +19,9 @@ #include "libc/macros.internal.h" #include "libc/str/str.h" -static const int (*const kWcTypeFuncs[])(wint_t) = { +typedef int (*isw_f)(wint_t); + +static const isw_f kWcTypeFuncs[] = { iswalnum, // iswalpha, // iswblank, // diff --git a/third_party/quickjs/quickjs-libc.c b/third_party/quickjs/quickjs-libc.c index cea3b1bad..c9bd6e3c5 100644 --- a/third_party/quickjs/quickjs-libc.c +++ b/third_party/quickjs/quickjs-libc.c @@ -1463,7 +1463,7 @@ static textstartup void js_std_error_props_init() { DEF(EBADF), #undef DEF }; - _Static_assert(sizeof(js_std_error_props) == sizeof(props)); + _Static_assert(sizeof(js_std_error_props) == sizeof(props), ""); memcpy(js_std_error_props, props, sizeof(props)); } const void *const js_std_error_props_ctor[] initarray = {js_std_error_props_init}; @@ -3592,7 +3592,7 @@ static textstartup void js_os_funcs_init() { JS_CFUNC_DEF("dup2", 2, js_os_dup2 ), #endif }; - _Static_assert(sizeof(js_os_funcs) == sizeof(funcs)); + _Static_assert(sizeof(js_os_funcs) == sizeof(funcs), ""); memcpy(js_os_funcs, funcs, sizeof(funcs)); } const void *const js_os_funcs_ctor[] initarray = {js_os_funcs_init}; diff --git a/third_party/quickjs/quickjs.c b/third_party/quickjs/quickjs.c index 1935e0cec..7a0cc47d9 100644 --- a/third_party/quickjs/quickjs.c +++ b/third_party/quickjs/quickjs.c @@ -10731,7 +10731,7 @@ static int JS_ToInt64SatFree(JSContext *ctx, int64_t *pres, JSValue val) } else { if (d < INT64_MIN) *pres = INT64_MIN; - else if (d > INT64_MAX) + else if (d > (double)INT64_MAX) *pres = INT64_MAX; else *pres = (int64_t)d; diff --git a/third_party/regex/regerror.c b/third_party/regex/regerror.c index b9762b1c1..152fb630d 100644 --- a/third_party/regex/regerror.c +++ b/third_party/regex/regerror.c @@ -47,7 +47,7 @@ static const char kRegexErrors[] = * @return number of bytes needed to hold entire string */ size_t regerror(int e, const regex_t *preg, char *buf, size_t size) { - return 1 + snprintf(buf, size, "%s", - firstnonnull(IndexDoubleNulString(kRegexErrors, e), - "Unknown error")); + return 1 + (snprintf)(buf, size, "%s", + firstnonnull(IndexDoubleNulString(kRegexErrors, e), + "Unknown error")); }