parsemode: No need to return after eprintf

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).
This commit is contained in:
Michael Forney 2016-11-30 23:27:59 -08:00 committed by Laslo Hunhold
parent aded902891
commit 87f40834a3
2 changed files with 3 additions and 8 deletions

View File

@ -1,3 +1,4 @@
/* See LICENSE file for copyright and license details. */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -23,10 +24,8 @@ parsemode(const char *str, mode_t mode, mode_t mask)
octal = strtol(str, &end, 8); octal = strtol(str, &end, 8);
if (*end == '\0') { if (*end == '\0') {
if (octal < 0 || octal > 07777) { if (octal < 0 || octal > 07777)
eprintf("%s: invalid mode\n", str); eprintf("%s: invalid mode\n", str);
return -1;
}
mode = 0; mode = 0;
if (octal & 04000) mode |= S_ISUID; if (octal & 04000) mode |= S_ISUID;
if (octal & 02000) mode |= S_ISGID; if (octal & 02000) mode |= S_ISGID;
@ -78,7 +77,6 @@ next:
break; break;
default: default:
eprintf("%s: invalid mode\n", str); eprintf("%s: invalid mode\n", str);
return -1;
} }
perm = 0; perm = 0;

View File

@ -215,11 +215,8 @@ main(int argc, char *argv[])
owner = getuid(); owner = getuid();
} }
if (mflag) { if (mflag)
mode = parsemode(mflag, mode, 0); mode = parsemode(mflag, mode, 0);
if (mode < 0)
return 1;
}
if (tflag) { if (tflag) {
memmove(argv - 1, argv, argc); memmove(argv - 1, argv, argc);