]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
islocal: use less ambiguous variable name
authorChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Sun, 29 Mar 2026 18:00:36 +0000 (14:00 -0400)
committerChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Mon, 30 Mar 2026 12:15:14 +0000 (08:15 -0400)
The variable name 'match' naturally implies a binary
state e.g. true or false and is not appropriate for
the indexing of a string literal, it is better to
avoid this ambiguity and use a name that properly
conveys its purpose, in this case 'idx' is a better
choice.

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
login-utils/islocal.c

index 1adddd7cd3540f1011e37e15656baa0451286b00..4012b66179984a09e6eddd0f79150e6ec78ae79a 100644 (file)
@@ -30,7 +30,7 @@
 static int is_local_in_file(const char *user, const char *filename)
 {
        int local = 0;
-       size_t match;
+       size_t idx;
        int chin, skip;
        FILE *f;
 
@@ -38,7 +38,7 @@ static int is_local_in_file(const char *user, const char *filename)
        if (!f)
                return -1;
 
-       match = 0;
+       idx = 0;
        skip = 0;
        while ((chin = fgetc(f)) != EOF) {
                if (skip) {
@@ -46,11 +46,11 @@ static int is_local_in_file(const char *user, const char *filename)
                        if (chin == '\n') {
                                /* Start matching username at the next char. */
                                skip = 0;
-                               match = 0;
+                               idx = 0;
                        }
                } else {
                        if (chin == ':') {
-                               if (user[match] == '\0') {
+                               if (user[idx] == '\0') {
                                        /* Success. */
                                        local = 1;
                                        /* next line has no test coverage,
@@ -66,12 +66,12 @@ static int is_local_in_file(const char *user, const char *filename)
                                /* This line contains no colon; it's
                                 * malformed.  No skip since we are already
                                 * at the start of the next line.  */
-                               match = 0U;
-                       } else if (chin != user[match]) {
+                               idx = 0;
+                       } else if (chin != user[idx]) {
                                /* username does not match. */
                                skip = 1;
                        } else {
-                               ++match;
+                               ++idx;
                        }
                }
        }