From: Matthias Schiffer Date: Sat, 16 May 2020 16:23:22 +0000 (+0200) Subject: usign-exec: remove redundant return statements X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=7ec4bb764e1eb58f5d499d3b47f97bfc9a09eb0a;p=oweals%2Fucert.git usign-exec: remove redundant return statements All switch() cases were already returning value or exiting. Instead, move the default case out of the switch to reduce indentation (only relevant for usign_f()). Signed-off-by: Matthias Schiffer --- diff --git a/usign-exec.c b/usign-exec.c index 294c794..c9aecf9 100644 --- a/usign-exec.c +++ b/usign-exec.c @@ -76,13 +76,10 @@ int usign_s(const char *msgfile, const char *seckeyfile, const char *sigfile, bo if (!quiet) perror("Failed to execute usign"); _exit(1); - - default: - waitpid(pid, &status, 0); - return WEXITSTATUS(status); } - return -1; + waitpid(pid, &status, 0); + return WEXITSTATUS(status); } #else int usign_s(const char *msgfile, const char *seckeyfile, const char *sigfile, bool quiet) { @@ -137,26 +134,23 @@ static int usign_f(char fingerprint[17], const char *pubkeyfile, const char *sec if (!quiet) perror("Failed to execute usign"); _exit(1); + } - default: - waitpid(pid, &status, 0); - status = WEXITSTATUS(status); - if (fingerprint && !WEXITSTATUS(status)) { - ssize_t r; - memset(fingerprint, 0, 17); - r = read(fds[0], fingerprint, 17); - if (r < 16) - status = -1; + waitpid(pid, &status, 0); + status = WEXITSTATUS(status); + if (fingerprint && !WEXITSTATUS(status)) { + ssize_t r; + memset(fingerprint, 0, 17); + r = read(fds[0], fingerprint, 17); + if (r < 16) + status = -1; - fingerprint[16] = '\0'; + fingerprint[16] = '\0'; - } - close(fds[0]); - close(fds[1]); - return status; } - - return -1; + close(fds[0]); + close(fds[1]); + return status; } /* @@ -237,11 +231,8 @@ int usign_v(const char *msgfile, const char *pubkeyfile, if (!quiet) perror("Failed to execute usign"); _exit(1); - - default: - waitpid(pid, &status, 0); - return WEXITSTATUS(status); } - return -1; + waitpid(pid, &status, 0); + return WEXITSTATUS(status); }