[hackers] [sbase] [PATCH] parsemode: No need to return after eprintf

From: Michael Forney <mforney_AT_mforney.org>
Date: Wed, 30 Nov 2016 23:27:59 -0800

Also, since parsemode exits on failure, don't bother checking return
value in xinstall (this would never trigger anyway because mode_t can be
unsigned).
---
 libutil/mode.c | 6 ++----
 xinstall.c     | 5 +----
 2 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/libutil/mode.c b/libutil/mode.c
index 365b9ad..187c7a3 100644
--- a/libutil/mode.c
+++ b/libutil/mode.c
_AT_@ -1,3 +1,4 @@
+/* See LICENSE file for copyright and license details. */
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
_AT_@ -23,10 +24,8 @@ parsemode(const char *str, mode_t mode, mode_t mask)
 
 	octal = strtol(str, &end, 8);
 	if (*end == '\0') {
-		if (octal < 0 || octal > 07777) {
+		if (octal < 0 || octal > 07777)
 			eprintf("%s: invalid mode\n", str);
-			return -1;
-		}
 		mode = 0;
 		if (octal & 04000) mode |= S_ISUID;
 		if (octal & 02000) mode |= S_ISGID;
_AT_@ -78,7 +77,6 @@ next:
 			break;
 		default:
 			eprintf("%s: invalid mode\n", str);
-			return -1;
 		}
 
 		perm = 0;
diff --git a/xinstall.c b/xinstall.c
index bf921fb..70d7097 100644
--- a/xinstall.c
+++ b/xinstall.c
_AT_@ -215,11 +215,8 @@ main(int argc, char *argv[])
 		owner = getuid();
 	}
 
-	if (mflag) {
+	if (mflag)
 		mode = parsemode(mflag, mode, 0);
-		if (mode < 0)
-			return 1;
-	}
 
 	if (tflag) {
 		memmove(argv - 1, argv, argc);
-- 
2.10.2
Received on Thu Dec 01 2016 - 08:27:59 CET

This archive was generated by hypermail 2.3.0 : Thu Dec 01 2016 - 08:36:14 CET