summaryrefslogtreecommitdiffstats
path: root/login-utils/lslogins.c
diff options
context:
space:
mode:
authorSami Kerola2016-07-04 23:16:54 +0200
committerSami Kerola2016-07-21 22:14:33 +0200
commit01e6b621e4671eba42164405cbcdd5b5c7e9c352 (patch)
tree29ff8566f068e44b4bf39b001fc5d1715daba03f /login-utils/lslogins.c
parentswitch_root: simplify code and reduce indentation [oclint] (diff)
downloadkernel-qcow2-util-linux-01e6b621e4671eba42164405cbcdd5b5c7e9c352.tar.gz
kernel-qcow2-util-linux-01e6b621e4671eba42164405cbcdd5b5c7e9c352.tar.xz
kernel-qcow2-util-linux-01e6b621e4671eba42164405cbcdd5b5c7e9c352.zip
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 <kerolasa@iki.fi>
Diffstat (limited to 'login-utils/lslogins.c')
-rw-r--r--login-utils/lslogins.c20
1 files changed, 9 insertions, 11 deletions
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;
}