sbase

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

commit 8e8d8ff2428879fa055f6ec044ddd305533cd26d
parent 7872986dd214ae3b591b3d21437958feb8e7a7dc
Author: sin <sin@2f30.org>
Date:   Wed,  9 Jul 2014 14:48:59 +0100

Only check errno if getpw*() fails

Diffstat:
Mchown.c | 20++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/chown.c b/chown.c @@ -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\n", owner); + if (!pw) { + if(errno != 0) + eprintf("getpwnam %s:", owner); + else + eprintf("getpwnam %s: no such user\n", 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\n", group); + if (!gr) { + if(errno != 0) + eprintf("getgrnam %s:", group); + else + eprintf("getgrnam %s: no such group\n", group); + } } for(; argc > 0; argc--, argv++) chownpwgr(argv[0]);