Fixed `NO_ENV` passing bad `envp` to `execve()`. Fixed `NO_SEARCH_PATH` compiler warnings.

Fortune for sink's current commit: Future small blessing − 末小吉
master
Avril 3 years ago
parent 6eb20eeb46
commit e1aa693e75
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -36,6 +36,7 @@ static inline int dupall(int from)
return 0; return 0;
} }
#ifndef NO_SEARCH_PATH
inline static int err_not_found(int er) { inline static int err_not_found(int er) {
return er == ENOENT; return er == ENOENT;
} }
@ -69,13 +70,14 @@ static int path_lookup(size_t sz; const char name[restrict static 1], char fullp
free(_tmpfree); free(_tmpfree);
return found; return found;
} }
#endif // !NO_SEARCH_PATH
int main(int argc, char** argv, char** envp) int main(int argc, char** argv, char** envp)
{ {
(void)argc; (void)argc;
#ifdef NO_ENV #ifdef NO_ENV
#define GET_ENV ((char*[]){})
(void)envp; (void)envp;
#define GET_ENV ((char*[]){NULL})
#else #else
#define GET_ENV envp #define GET_ENV envp
#endif #endif
@ -100,7 +102,7 @@ int main(int argc, char** argv, char** envp)
if(argv[1]) { if(argv[1]) {
#if NO_SEARCH_PATH #ifdef NO_SEARCH_PATH
if(UNLIKELY($execve(argv[1]) < 0)) { if(UNLIKELY($execve(argv[1]) < 0)) {
perror("execve() failed"); perror("execve() failed");
return errno; return errno;

Loading…
Cancel
Save