Use helper function empty_string() instead of manual checks

For code consistency, substitute boolean expressions:
 s && *s     -> !empty_string(s)
 s && s[0]   -> !empty_string(s)
 !s || !*s   ->  empty_string(s)
 !s || !s[0] ->  empty_string(s)

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-01-07 15:42:28 +01:00 committed by Lubomir I. Ivanov
parent e85ecdd925
commit 6a07ccbad2
8 changed files with 11 additions and 11 deletions

View file

@ -31,12 +31,12 @@ void subsurface_user_info(struct user_info *user)
const char *username = getenv("USER");
if (pwd) {
if (pwd->pw_gecos && *pwd->pw_gecos)
if (!empty_string(pwd->pw_gecos))
user->name = pwd->pw_gecos;
if (!username)
username = pwd->pw_name;
}
if (username && *username) {
if (!empty_string(username)) {
char hostname[64];
struct membuffer mb = {};
gethostname(hostname, sizeof(hostname));