sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

commit c5c8c7ff86f08915524bcb4fe767744d0d0a8a83
parent b29fc0b05f579d293043b130aef3338eaf052c8e
Author: Michael Forney <mforney@mforney.org>
Date:   Fri,  1 Nov 2019 19:07:10 -0700

libutil/mode: Remove unnecessary octal-to-mode conversion

The values of the file mode macros are specified explicitly by POSIX,
so we can just use the octal value directly.

Diffstat:
Mlibutil/mode.c | 15+--------------
1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/libutil/mode.c b/libutil/mode.c @@ -26,20 +26,7 @@ parsemode(const char *str, mode_t mode, mode_t mask) if (*end == '\0') { if (octal < 0 || octal > 07777) eprintf("%s: invalid mode\n", str); - mode = 0; - if (octal & 04000) mode |= S_ISUID; - if (octal & 02000) mode |= S_ISGID; - if (octal & 01000) mode |= S_ISVTX; - if (octal & 00400) mode |= S_IRUSR; - if (octal & 00200) mode |= S_IWUSR; - if (octal & 00100) mode |= S_IXUSR; - if (octal & 00040) mode |= S_IRGRP; - if (octal & 00020) mode |= S_IWGRP; - if (octal & 00010) mode |= S_IXGRP; - if (octal & 00004) mode |= S_IROTH; - if (octal & 00002) mode |= S_IWOTH; - if (octal & 00001) mode |= S_IXOTH; - return mode; + return octal; } next: /* first, determine which bits we will be modifying */