From: Alejandro Colomar Date: Sun, 20 Jul 2025 15:02:17 +0000 (+0200) Subject: lib/, src/: Use STRNEQ() instead of their pattern X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8f0fa6ddffcf60499aec34a9fc4a89c3ec9b0106;p=thirdparty%2Fshadow.git lib/, src/: Use STRNEQ() instead of their pattern Signed-off-by: Alejandro Colomar --- diff --git a/lib/user_busy.c b/lib/user_busy.c index a05faef16..51f0a9ea3 100644 --- a/lib/user_busy.c +++ b/lib/user_busy.c @@ -29,6 +29,7 @@ #include "shadowlog.h" #include "string/sprintf/snprintf.h" #include "string/strcmp/streq.h" +#include "string/strcmp/strneq.h" #include "string/strcmp/strprefix.h" @@ -70,9 +71,9 @@ user_busy_utmp(const char *name) if (utent->ut_type != USER_PROCESS) { continue; } - if (strncmp (utent->ut_user, name, sizeof utent->ut_user) != 0) { + if (!STRNEQ(utent->ut_user, name)) continue; - } + if (kill (utent->ut_pid, 0) != 0) { continue; } diff --git a/lib/utmp.c b/lib/utmp.c index 43cd6aac1..9c7466352 100644 --- a/lib/utmp.c +++ b/lib/utmp.c @@ -32,6 +32,7 @@ #include "sizeof.h" #include "string/strchr/strnul.h" #include "string/strcmp/streq.h" +#include "string/strcmp/strneq.h" #include "string/strcmp/strprefix.h" #include "string/strcpy/strncpy.h" #include "string/strcpy/strtcpy.h" @@ -210,7 +211,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) && strncmp(ut->ut_host, "", countof(ut->ut_host)) != 0) { + if ((ut != NULL) && !STRNEQ(ut->ut_host, "")) { *out = XSTRNDUP(ut->ut_host); } else { *out = NULL; @@ -281,7 +282,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 && strncmp(ut->ut_host, "", countof(ut->ut_host)) != 0) + else if (NULL != ut && !STRNEQ(ut->ut_host, "")) hostname = XSTRNDUP(ut->ut_host); #endif @@ -436,10 +437,10 @@ active_sessions_count(const char *name, unsigned long limit) if (USER_PROCESS != ut->ut_type) { continue; } - if (strncmp(ut->ut_user, "", countof(ut->ut_user)) == 0) + if (STRNEQ(ut->ut_user, "")) continue; - if (strncmp(ut->ut_user, name, countof(ut->ut_user)) != 0) + if (!STRNEQ(ut->ut_user, name)) continue; count++; diff --git a/src/login.c b/src/login.c index aff812e2e..f52dbeec7 100644 --- a/src/login.c +++ b/src/login.c @@ -42,6 +42,7 @@ #include "string/memset/memzero.h" #include "string/sprintf/snprintf.h" #include "string/strcmp/streq.h" +#include "string/strcmp/strneq.h" #include "string/strcmp/strprefix.h" #include "string/strcpy/strtcpy.h" #include "string/strdup/xstrdup.h" @@ -1200,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 (strncmp(ll.ll_host, "", countof(ll.ll_host)) != 0) { + if (!STRNEQ(ll.ll_host, "")) { printf (_(" from %.*s"), (int) sizeof ll.ll_host, ll.ll_host); } diff --git a/src/logoutd.c b/src/logoutd.c index fc08fa1fd..27b570a7a 100644 --- a/src/logoutd.c +++ b/src/logoutd.c @@ -22,6 +22,7 @@ #include "prototypes.h" #include "shadowlog.h" #include "sizeof.h" +#include "string/strcmp/strneq.h" #include "string/strcpy/strncat.h" #include "string/strdup/strndupa.h" @@ -179,7 +180,7 @@ main(int argc, char **argv) if (ut->ut_type != USER_PROCESS) { continue; } - if (strncmp(ut->ut_user, "", countof(ut->ut_user)) == 0) + if (STRNEQ(ut->ut_user, "")) continue; if (check_login (ut)) {