sbase

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

commit 32651cb2da5b04e2fef1eef075374ef79e622ade
parent 3d8d796a952fdc0e6d5beb66d354c5386f0fd594
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sun, 21 Dec 2014 22:58:09 +0100

ls: getpwuid, getgrgid, use return code of NULL is an error, not errno

Diffstat:
Mls.c | 12++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/ls.c b/ls.c @@ -275,17 +275,17 @@ output(Entry *ent) errno = 0; pw = getpwuid(ent->uid); - if (errno || !pw) - snprintf(pwname, sizeof(pwname), "%d", ent->uid); - else + if (pw) snprintf(pwname, sizeof(pwname), "%s", pw->pw_name); + else + snprintf(pwname, sizeof(pwname), "%d", ent->uid); errno = 0; gr = getgrgid(ent->gid); - if (errno || !gr) - snprintf(grname, sizeof(grname), "%d", ent->gid); - else + if (gr) snprintf(grname, sizeof(grname), "%s", gr->gr_name); + else + snprintf(grname, sizeof(grname), "%d", ent->gid); if (time(NULL) > ent->mtime + (180*24*60*60)) /* 6 months ago? */ fmt = "%b %d %Y";