aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2018-02-21 11:59:34 -0500
committerRich Felker <dalias@aerifal.cx>2018-02-21 12:01:29 -0500
commit6d6102427d8d5450bd28788c792f97ef90cce274 (patch)
treebb45d9493b530154a8f5a856cc1fcc22527c84ee
parent8e0b38060d7a9916fc2b5de0dd7c166ef60be9c1 (diff)
downloadmusl-6d6102427d8d5450bd28788c792f97ef90cce274.zip
musl-6d6102427d8d5450bd28788c792f97ef90cce274.tar.gz
musl-6d6102427d8d5450bd28788c792f97ef90cce274.tar.bz2
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 a603a75a72bb469c6be4963ed1b55fabe675fe15).
-rw-r--r--src/process/execvp.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/process/execvp.c b/src/process/execvp.c
index 480a85e..2dddedd 100644
--- a/src/process/execvp.c
+++ b/src/process/execvp.c
@@ -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;