[hackers] [sbase] Only check errno if getpw*() fails || sin

From: <git_AT_suckless.org>
Date: Wed, 09 Jul 2014 16:09:17 +0200

commit 8e8d8ff2428879fa055f6ec044ddd305533cd26d
Author: sin <sin_AT_2f30.org>
Date: Wed Jul 9 14:48:59 2014 +0100

    Only check errno if getpw*() fails

diff --git a/chown.c b/chown.c
index bf37e65..85ee5b9 100644
--- a/chown.c
+++ b/chown.c
_AT_@ -47,18 +47,22 @@ main(int argc, char *argv[])
         if(owner && *owner) {
                 errno = 0;
                 pw = getpwnam(owner);
- if(errno != 0)
- eprintf("getpwnam %s:", owner);
- else if(!pw)
- eprintf("getpwnam %s: no such user
", owner);
+ if (!pw) {
+ if(errno != 0)
+ eprintf("getpwnam %s:", owner);
+ else
+ eprintf("getpwnam %s: no such user
", owner);
+ }
         }
         if(group && *group) {
                 errno = 0;
                 gr = getgrnam(group);
- if(errno != 0)
- eprintf("getgrnam %s:", group);
- else if(!gr)
- eprintf("getgrnam %s: no such group
", group);
+ if (!gr) {
+ if(errno != 0)
+ eprintf("getgrnam %s:", group);
+ else
+ eprintf("getgrnam %s: no such group
", group);
+ }
         }
         for(; argc > 0; argc--, argv++)
                 chownpwgr(argv[0]);
Received on Wed Jul 09 2014 - 16:09:17 CEST

This archive was generated by hypermail 2.3.0 : Wed Jul 09 2014 - 16:12:12 CEST