Improve LLVM compatibility a little bit

This commit is contained in:
Justine Tunney 2021-05-16 20:34:46 -07:00
parent 3057315a1b
commit 1a3d22b2fd
7 changed files with 14 additions and 12 deletions

View file

@ -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

View file

@ -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);
}

View file

@ -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+");
}

View file

@ -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, //

View file

@ -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};

View file

@ -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;

View file

@ -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"));
}