diff mbox series

[OpenWrt-Devel,ucert,08/13] usign-exec: remove redundant return statements

Message ID 7ec4bb764e1eb58f5d499d3b47f97bfc9a09eb0a.1589663193.git.mschiffer@universe-factory.net
State Accepted
Delegated to: Matthias Schiffer
Headers show
Series ucert fixes and cleanup | expand

Commit Message

Matthias Schiffer May 16, 2020, 9:13 p.m. UTC
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 <mschiffer@universe-factory.net>
---
 usign-exec.c | 43 +++++++++++++++++--------------------------
 1 file changed, 17 insertions(+), 26 deletions(-)
diff mbox series

Patch

diff --git a/usign-exec.c b/usign-exec.c
index 294c794b1c50..c9aecf99f9c0 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);
 }