]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
*/: s/STRNDUP/strndup_a/ s/XSTRNDUP/xstrndup_a/
authorAlejandro Colomar <alx@kernel.org>
Tue, 14 Oct 2025 10:40:46 +0000 (12:40 +0200)
committerSerge Hallyn <serge@hallyn.com>
Fri, 28 Nov 2025 02:50:48 +0000 (20:50 -0600)
This name better reflects that it handles arrays, and doesn't shout.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/string/README
lib/string/strdup/strndup.h
lib/utmp.c

index 3a7e2e32577276085970de770bff93655b05f8da..dfe6465c5b693c73fdac17f495fee41aa60e1655 100644 (file)
@@ -154,7 +154,7 @@ strdup/ - Memory duplication
     strndupa_a()
        Like strndupa(3), but takes an array.
 
-    STRNDUP()
+    strndup_a()
        Like strndup(3), but takes an array.
 
   m/
index 5971220a11e36ac22f1c764e171b850b318067d9..44c0dcfded07412debc99ea2c67ff4257e953c20 100644 (file)
 #include "exit_if_null.h"
 
 
-// Similar to strndup(3), but ensure that 's' is an array.
-#define STRNDUP(s)   strndup(s, countof(s))
+// strndup_a - nonstring duplicate-into-string array
+#define strndup_a(s)   strndup(s, countof(s))
 
-// exit-on-error nonstring duplicate-into-string
-#define XSTRNDUP(s)  exit_if_null(STRNDUP(s))
+// xstrndup_a - exit-on-error nonstring duplicate-into-string array
+#define xstrndup_a(s)  exit_if_null(strndup_a(s))
 
 
 #endif  // include guard
index 6074de3d5ef1dbfd4d959754e2d390558bbe9cb0..8c1af1eef407dcb3d4cd1f624a226c33c11bc5aa 100644 (file)
@@ -208,7 +208,7 @@ get_session_host(char **out, pid_t main_pid)
 
 #if defined(HAVE_STRUCT_UTMPX_UT_HOST)
        if ((ut != NULL) && !STRNEQ(ut->ut_host, "")) {
-               *out = XSTRNDUP(ut->ut_host);
+               *out = xstrndup_a(ut->ut_host);
        } else {
                *out = NULL;
                ret = -2;
@@ -279,7 +279,7 @@ prepare_utmp(const char *name, const char *line, const char *host,
                hostname = xstrdup(host);
 #if defined(HAVE_STRUCT_UTMPX_UT_HOST)
        else if (NULL != ut && !STRNEQ(ut->ut_host, ""))
-               hostname = XSTRNDUP(ut->ut_host);
+               hostname = xstrndup_a(ut->ut_host);
 #endif
 
        line = strprefix(line, "/dev/") ?: line;