simplified uid() and fixed username()
Ali H. Fardan raiz@firemail.cc
Thu, 01 Sep 2016 21:35:32 +0300
1 files changed,
6 insertions(+),
25 deletions(-)
jump to
M
slstatus.c
→
slstatus.c
@@ -474,40 +474,21 @@
static char * username(void) { - /* FIXME: WHY USE REGISTER MODIFIER? */ - register struct passwd *pw; - register uid_t uid; - - uid = geteuid(); - pw = getpwuid(uid); + uid_t uid = geteuid(); + struct passwd *pw = getpwuid(uid); - if (pw) + if (pw == NULL) return smprintf("%s", pw->pw_name); - else { - fprintf(stderr, "Could not get username: %s\n", + + fprintf(stderr, "Could not get username: %s\n", strerror(errno)); - return smprintf(UNKNOWN_STR); - } - return smprintf(UNKNOWN_STR); } static char * uid(void) { - /* FIXME: WHY USE register modifier? */ - register uid_t uid; - - uid = geteuid(); - - if (uid) - return smprintf("%d", uid); - else { - fprintf(stderr, "Could not get uid.\n"); - return smprintf(UNKNOWN_STR); - } - - return smprintf(UNKNOWN_STR); + return smprintf("%d", geteuid()); }