]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/, src/: Reduce scope of local variables
authorAlejandro Colomar <alx@kernel.org>
Sat, 13 Dec 2025 23:57:19 +0000 (00:57 +0100)
committerSerge Hallyn <serge@hallyn.com>
Mon, 29 Dec 2025 03:19:22 +0000 (21:19 -0600)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/addgrps.c
src/groupmod.c

index 7768f1325fc050d02335104e2ad816cf24384d53..b90828e1e2e6f28b2494b127307bb2c6acd9df1e 100644 (file)
@@ -36,7 +36,7 @@
 int
 add_groups(const char *list)
 {
-       char    *g, *p, *dup;
+       char    *dup;
        FILE *shadow_logfd = log_get_logfd();
        gid_t   *gids;
        size_t  n;
@@ -49,11 +49,14 @@ add_groups(const char *list)
        if (gids == NULL)
                return -1;
 
-       p = dup = strdup(list);
+       dup = strdup(list);
        if (dup == NULL)
                goto free_gids;
 
        if (!streq(dup, "")) {
+               char  *g, *p;
+
+               p = dup;
                while (NULL != (g = strsep(&p, ",:"))) {
                        struct group  *grp;
 
index 5b90c2342c6fd1e1a624f08e1e8fe8b4f8a0f9bb..c29f905088293ce670179b808b522166d8c0f3d4 100644 (file)
@@ -259,8 +259,6 @@ grp_update(void)
        }
 
        if (user_list) {
-               char  *u, *ul;
-
                if (!aflg) {
                        // requested to replace the existing groups
                        grp.gr_mem = xmalloc_T(1, char *);
@@ -283,6 +281,8 @@ grp_update(void)
 #endif                         /* SHADOWGRP */
 
                if (!streq(user_list, "")) {
+                       char  *u, *ul;
+
                        ul = user_list;
                        while (NULL != (u = strsep(&ul, ","))) {
                                if (prefix_getpwnam(u) == NULL) {