From: Aaron Marcher Date: Fri, 9 Sep 2016 17:19:46 +0000 (+0200) Subject: fixed username function (wtf happened here?) X-Git-Url: https://git.xinqibao.xyz/slstatus.git/commitdiff_plain/545f1560e6b019a49f9df7f7f16e861b58ce51f4?ds=inline;hp=--cc fixed username function (wtf happened here?) --- 545f1560e6b019a49f9df7f7f16e861b58ce51f4 diff --git a/slstatus.c b/slstatus.c index 7b85a23..3675660 100644 --- a/slstatus.c +++ b/slstatus.c @@ -455,11 +455,12 @@ username(void) uid_t uid = geteuid(); struct passwd *pw = getpwuid(uid); - if (pw == NULL) - return smprintf("%s", pw->pw_name); + if (pw == NULL) { + warn("Could not get username"); + return smprintf(UNKNOWN_STR); + } - warn("Could not get username"); - return smprintf(UNKNOWN_STR); + return smprintf("%s", pw->pw_name); } static char *