diff --git a/ChangeLog b/ChangeLog index b6f6a365..81581ea2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-05-25 Nicolas François + + * libmisc/myname.c: Avoid assignments in comparisons. + * libmisc/myname.c: Avoid implicit conversion of pointers / chars + to booleans. + * libmisc/myname.c: Add brackets. + 2008-05-25 Nicolas François * libmisc/utmp.c (checkutmp): Change picky argument's type to diff --git a/libmisc/myname.c b/libmisc/myname.c index ff6d17ba..23464172 100644 --- a/libmisc/myname.c +++ b/libmisc/myname.c @@ -57,8 +57,12 @@ struct passwd *get_my_pwent (void) * XXX - when running from su, will return the current user (not * the original user, like getlogin() does). Does this matter? */ - if (cp && *cp && (pw = xgetpwnam (cp)) && pw->pw_uid == ruid) - return pw; + if ((NULL !=cp) && ('\0' != *cp)) { + pw = xgetpwnam (cp); + if ((NULL != pw) && (pw->pw_uid == ruid)) { + return pw; + } + } return xgetpwuid (ruid); }