diff --git a/libc/calls/fexecve.c b/libc/calls/fexecve.c index 85e473b3b..0a5791243 100644 --- a/libc/calls/fexecve.c +++ b/libc/calls/fexecve.c @@ -143,9 +143,11 @@ static int fd_to_mem_fd(const int infd, char *path) { bool success = readRc != -1; if (success && (st.st_size > 8) && IsAPEMagic(space)) { int flags = fcntl(fd, F_GETFD); - if(success = (flags != -1) && (fcntl(fd, F_SETFD, flags & (~FD_CLOEXEC)) != -1) && ape_to_elf(space, st.st_size)) { + if (success = (flags != -1) && + (fcntl(fd, F_SETFD, flags & (~FD_CLOEXEC)) != -1) && + ape_to_elf(space, st.st_size)) { const int newfd = fcntl(fd, F_DUPFD, 9001); - if(newfd != -1) { + if (newfd != -1) { close(fd); fd = newfd; } @@ -153,7 +155,7 @@ static int fd_to_mem_fd(const int infd, char *path) { } const int e = errno; if ((_weaken(munmap)(space, st.st_size) != -1) && success) { - if(path) { + if (path) { FormatInt32(stpcpy(path, "COSMOPOLITAN_INIT_ZIPOS="), fd); } _unassert(readRc == st.st_size); @@ -232,16 +234,12 @@ int fexecve(int fd, char *const argv[], char *const envp[]) { for (numenvs = 0; envp[numenvs];) ++numenvs; const size_t desenvs = min(500, max(numenvs + 1, 2)); char *envs[500]; - if (envs) { - memcpy(envs, envp, numenvs * sizeof(char *)); - envs[numenvs] = path; - envs[numenvs+1] = NULL; - fexecve_impl(newfd, argv, envs); - if(!savedErr) { - savedErr = errno; - } - } else if(!savedErr) { - savedErr = ENOMEM; + memcpy(envs, envp, numenvs * sizeof(char *)); + envs[numenvs] = path; + envs[numenvs + 1] = NULL; + fexecve_impl(newfd, argv, envs); + if (!savedErr) { + savedErr = errno; } BEGIN_CANCELLATION_POINT; BLOCK_SIGNALS; @@ -251,7 +249,7 @@ int fexecve(int fd, char *const argv[], char *const envp[]) { ALLOW_SIGNALS; END_CANCELLATION_POINT; } while (0); - if(savedErr) { + if (savedErr) { errno = savedErr; } rc = -1; diff --git a/libc/zipos/get.c b/libc/zipos/get.c index 65dea2176..395fd3b86 100644 --- a/libc/zipos/get.c +++ b/libc/zipos/get.c @@ -69,12 +69,12 @@ struct Zipos *__zipos_get(void) { static struct Zipos zipos; uint8_t *map, *base, *cdir; progpath = getenv("COSMOPOLITAN_INIT_ZIPOS"); - if(progpath) { + if (progpath) { fd = atoi(progpath); } if (!once && ((fd != -1) || PLEDGED(RPATH))) { __zipos_lock(); - if(fd == -1) { + if (fd == -1) { progpath = GetProgramExecutableName(); fd = open(progpath, O_RDONLY); } diff --git a/test/libc/calls/zipread.c b/test/libc/calls/zipread.c index 2ef94bf84..06c911c36 100644 --- a/test/libc/calls/zipread.c +++ b/test/libc/calls/zipread.c @@ -24,11 +24,14 @@ STATIC_YOINK("zip_uri_support"); int main(int argc, char *argv[]) { int fd = open("/zip/life.elf", O_RDONLY); - if (fd != -1 ) { + if (fd != -1) { uint8_t buf[4] = {0}; ssize_t readres = read(fd, buf, sizeof(buf)); if (readres == sizeof(buf)) { - if(memcmp(buf, "\x7F""ELF", sizeof(buf)) == 0) { + if (memcmp(buf, + "\x7F" + "ELF", + sizeof(buf)) == 0) { return 42; } }