mirror of git://git.musl-libc.org/musl
convert execvp error handling to switch statement
this is more extensible if we need to consider additional errors, and
more efficient as long as the compiler does not know it can cache the
result of __errno_location (a surprisingly complex issue detailed in
commit a603a75a72
).
This commit is contained in:
parent
8e0b38060d
commit
6d6102427d
|
@ -39,8 +39,15 @@ int __execvpe(const char *file, char *const argv[], char *const envp[])
|
|||
b[z-p] = '/';
|
||||
memcpy(b+(z-p)+(z>p), file, k+1);
|
||||
execve(b, argv, envp);
|
||||
if (errno == EACCES) seen_eacces = 1;
|
||||
else if (errno != ENOENT && errno != ENOTDIR) return -1;
|
||||
switch (errno) {
|
||||
case EACCES:
|
||||
seen_eacces = 1;
|
||||
case ENOENT:
|
||||
case ENOTDIR:
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
if (!*z++) break;
|
||||
}
|
||||
if (seen_eacces) errno = EACCES;
|
||||
|
|
Loading…
Reference in New Issue