ls: getpwuid, getgrgid, use return code of NULL is an error, not errno
This commit is contained in:
parent
3d8d796a95
commit
32651cb2da
12
ls.c
12
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";
|
||||
|
Loading…
Reference in New Issue
Block a user