From: Alejandro Colomar Date: Fri, 31 Oct 2025 10:05:37 +0000 (+0100) Subject: */: s/STRNEQ/strneq_a/ X-Git-Tag: 4.19.0-rc1~64 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0b75eb75e517912b0f6e2abaa51e3d195af38e22;p=thirdparty%2Fshadow.git */: s/STRNEQ/strneq_a/ Signed-off-by: Alejandro Colomar --- diff --git a/lib/string/README b/lib/string/README index 192b7eb3a..8072e85f7 100644 --- a/lib/string/README +++ b/lib/string/README @@ -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 diff --git a/lib/string/strcmp/strneq.h b/lib/string/strcmp/strneq.h index de8958bae..a8783fed8 100644 --- a/lib/string/strcmp/strneq.h +++ b/lib/string/strcmp/strneq.h @@ -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) diff --git a/lib/user_busy.c b/lib/user_busy.c index 09bf8c811..8dcbd9389 100644 --- a/lib/user_busy.c +++ b/lib/user_busy.c @@ -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) { diff --git a/lib/utmp.c b/lib/utmp.c index baf29764b..297ca5c7f 100644 --- a/lib/utmp.c +++ b/lib/utmp.c @@ -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++; diff --git a/src/login.c b/src/login.c index 4ccbc1224..03d1c92b4 100644 --- a/src/login.c +++ b/src/login.c @@ -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); } diff --git a/src/logoutd.c b/src/logoutd.c index 8e03f65a9..05404bbab 100644 --- a/src/logoutd.c +++ b/src/logoutd.c @@ -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)) {