]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lslogins: simplify if clause and move definition and comments [oclint]
authorSami Kerola <kerolasa@iki.fi>
Mon, 4 Jul 2016 21:16:54 +0000 (22:16 +0100)
committerSami Kerola <kerolasa@iki.fi>
Thu, 21 Jul 2016 20:14:33 +0000 (21:14 +0100)
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>
login-utils/lslogins.c

index 3ff772515dba9b4592028267de703e9d08071370..60a1b500f236816ca0a5d0476080978684c5cf9d 100644 (file)
@@ -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;
 }