]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
*/: s/STRNEQ/strneq_a/
authorAlejandro Colomar <alx@kernel.org>
Fri, 31 Oct 2025 10:05:37 +0000 (11:05 +0100)
committerSerge Hallyn <serge@hallyn.com>
Fri, 28 Nov 2025 02:50:48 +0000 (20:50 -0600)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/string/README
lib/string/strcmp/strneq.h
lib/user_busy.c
lib/utmp.c
src/login.c
src/logoutd.c

index 192b7eb3abdc7345b577e0eba962eb4136e46da6..8072e85f7fddd35941e13422e24bb6495f59574f 100644 (file)
@@ -34,7 +34,8 @@ Don't use some libc functions without Really Good Reasons:
        strcmp(3) would be legitimate for sorting strings.
 
     strncmp(3)
-       Use STRNEQ(), or strpfx(), or else, depending on what you want.
+       Use strneq_a(), or strpfx(), or else,
+       depending on what you want.
        The return value of strncmp(3) is confusing,
        and it is unclear the purpose of its use when you read it.
 
@@ -138,7 +139,7 @@ strcmp/ - String comparison
   n/
     strneq()
        Return true if a [[gnu::nonstring]] is equal to a string.
-    STRNEQ()
+    strneq_a()
        Like strneq(), but takes an array.
 
     strnpfx()  // Unimplemented
index de8958baefe7ffa15017ff3c80f02b75763a0e56..a8783fed8c4e6b07c22ad8ccc5a3d74b2da67c2e 100644 (file)
@@ -15,7 +15,7 @@
 #include "sizeof.h"
 
 
-#define STRNEQ(strn, s)  strneq(strn, s, countof(strn))
+#define strneq_a(strn, s)  strneq(strn, s, countof(strn))
 
 
 ATTR_STRING(2)
index 09bf8c8116864ab6d06f3865f829e74d4249ae96..8dcbd9389b9ba3d1c40855522cf477817cddb9f8 100644 (file)
@@ -71,7 +71,7 @@ user_busy_utmp(const char *name)
                if (utent->ut_type != USER_PROCESS) {
                        continue;
                }
-               if (!STRNEQ(utent->ut_user, name))
+               if (!strneq_a(utent->ut_user, name))
                        continue;
 
                if (kill (utent->ut_pid, 0) != 0) {
index baf29764b02caf22a509dd2ffb0490c3f4fc7638..297ca5c7f56ae6032807c63fe0ec7f8307f2d0bd 100644 (file)
@@ -207,7 +207,7 @@ get_session_host(char **out, pid_t main_pid)
        ut = get_current_utmp(main_pid);
 
 #if defined(HAVE_STRUCT_UTMPX_UT_HOST)
-       if ((ut != NULL) && !STRNEQ(ut->ut_host, "")) {
+       if ((ut != NULL) && !strneq_a(ut->ut_host, "")) {
                *out = xstrndup_a(ut->ut_host);
        } else {
                *out = NULL;
@@ -278,7 +278,7 @@ prepare_utmp(const char *name, const char *line, const char *host,
        if (NULL != host && !streq(host, ""))
                hostname = xstrdup(host);
 #if defined(HAVE_STRUCT_UTMPX_UT_HOST)
-       else if (NULL != ut && !STRNEQ(ut->ut_host, ""))
+       else if (NULL != ut && !strneq_a(ut->ut_host, ""))
                hostname = xstrndup_a(ut->ut_host);
 #endif
 
@@ -433,10 +433,10 @@ active_sessions_count(const char *name, unsigned long limit)
                if (USER_PROCESS != ut->ut_type) {
                        continue;
                }
-               if (STRNEQ(ut->ut_user, ""))
+               if (strneq_a(ut->ut_user, ""))
                        continue;
 
-               if (!STRNEQ(ut->ut_user, name))
+               if (!strneq_a(ut->ut_user, name))
                        continue;
 
                count++;
index 4ccbc1224d026c591c60c238731249b5ebdeefa2..03d1c92b411e9687d197a685faaabbe1d2182c57 100644 (file)
@@ -1201,7 +1201,7 @@ int main (int argc, char **argv)
                        printf (_("Last login: %s on %s"),
                                ptime, ll.ll_line);
 #ifdef HAVE_LL_HOST            /* __linux__ || SUN4 */
-                       if (!STRNEQ(ll.ll_host, "")) {
+                       if (!strneq_a(ll.ll_host, "")) {
                                printf (_(" from %.*s"),
                                        (int) sizeof ll.ll_host, ll.ll_host);
                        }
index 8e03f65a997d13a65b39cbe5f0c7987e9dba49a5..05404bbabe9ae5ffdaf99f6f8188f746659e2856 100644 (file)
@@ -180,7 +180,7 @@ main(int argc, char **argv)
                        if (ut->ut_type != USER_PROCESS) {
                                continue;
                        }
-                       if (STRNEQ(ut->ut_user, ""))
+                       if (strneq_a(ut->ut_user, ""))
                                continue;
 
                        if (check_login (ut)) {