From 01e6b621e4671eba42164405cbcdd5b5c7e9c352 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Mon, 4 Jul 2016 22:16:54 +0100 Subject: lslogins: simplify if clause and move definition and comments [oclint] The if clause change is pretty trivial. Moving the macro near to where it is used makes sense to people who want to read the code. And finally the comment about user list was at wrong spot. Signed-off-by: Sami Kerola --- login-utils/lslogins.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'login-utils/lslogins.c') diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c index 3ff772515..60a1b500f 100644 --- a/login-utils/lslogins.c +++ b/login-utils/lslogins.c @@ -766,14 +766,6 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c return user; } -/* some UNIX implementations set errno iff a passwd/grp/... - * entry was not found. The original UNIX logins(1) utility always - * ignores invalid login/group names, so we're going to as well.*/ -#define IS_REAL_ERRNO(e) !((e) == ENOENT || (e) == ESRCH || \ - (e) == EBADF || (e) == EPERM || (e) == EAGAIN) - -/* get a definitive list of users we want info about... */ - static int str_to_uint(char *s, unsigned int *ul) { char *end; @@ -785,6 +777,7 @@ static int str_to_uint(char *s, unsigned int *ul) return 1; } +/* get a definitive list of users we want info about... */ static int get_ulist(struct lslogins_control *ctl, char *logins, char *groups) { char *u, *g; @@ -878,13 +871,18 @@ static struct lslogins_user *get_next_user(struct lslogins_control *ctl) return u; } +/* some UNIX implementations set errno iff a passwd/grp/... + * entry was not found. The original UNIX logins(1) utility always + * ignores invalid login/group names, so we're going to as well.*/ +#define IS_REAL_ERRNO(e) !((e) == ENOENT || (e) == ESRCH || \ + (e) == EBADF || (e) == EPERM || (e) == EAGAIN) + static int get_user(struct lslogins_control *ctl, struct lslogins_user **user, const char *username) { *user = get_user_info(ctl, username); - if (!*user) - if (IS_REAL_ERRNO(errno)) - return -1; + if (!*user && IS_REAL_ERRNO(errno)) + return -1; return 0; } -- cgit v1.2.3-55-g7522