]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
*/: s/STRNDUPA/strndupa_a/
authorAlejandro Colomar <alx@kernel.org>
Tue, 14 Oct 2025 10:37:25 +0000 (12:37 +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/strndupa.h
src/logoutd.c

index 147b278fd44afe236ab8bf5c512baf66b9c5f57d..3a7e2e32577276085970de770bff93655b05f8da 100644 (file)
@@ -151,7 +151,7 @@ strdup/ - Memory duplication
   s/
     strndupa(3)
        Create a new string (in stack) from a [[gnu::nonstring]].
-    STRNDUPA()
+    strndupa_a()
        Like strndupa(3), but takes an array.
 
     STRNDUP()
index a093a7e184634ed98803540f6ab3a032c101f9cc..9a5a2dfcc6aca03c5cca2976abf0452ae4061811 100644 (file)
 #include "sizeof.h"
 
 
-// string n-bounded-read duplicate using-alloca(3)
+// strndupa - nonstring duplicate-into-string using-alloca(3)
 #ifndef  strndupa
 # define strndupa(s, n)  strncat(strcpy(alloca(n + 1), ""), s, n)
 #endif
 
 
-#define STRNDUPA(s)  strndupa(s, countof(s))
+// strndupa_a - nonstring duplicate-into-string using-alloca(3) array
+#define strndupa_a(s)  strndupa(s, countof(s))
 
 
 #endif  // include guard
index 27b570a7a4bcb30e581d4648d912eda4f7330134..2d4ec173716d0616621353c46c23258ae060103f 100644 (file)
@@ -56,8 +56,8 @@ check_login(const struct utmpx *ut)
        char    *line;
        time_t  now;
 
-       user = STRNDUPA(ut->ut_user);
-       line = STRNDUPA(ut->ut_line);
+       user = strndupa_a(ut->ut_user);
+       line = strndupa_a(ut->ut_line);
 
        now = time(NULL);
 
@@ -227,7 +227,7 @@ main(int argc, char **argv)
 
                        SYSLOG ((LOG_NOTICE,
                                 "logged off user '%s' on '%s'",
-                                STRNDUPA(ut->ut_user),
+                                strndupa_a(ut->ut_user),
                                 tty_name));
 
                        /*