From: Alejandro Colomar Date: Sat, 13 Dec 2025 23:57:19 +0000 (+0100) Subject: lib/, src/: Reduce scope of local variables X-Git-Tag: 4.19.0~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee7fa1dfc673809ad029e30877263b2cbc27b726;p=thirdparty%2Fshadow.git lib/, src/: Reduce scope of local variables Signed-off-by: Alejandro Colomar --- diff --git a/lib/addgrps.c b/lib/addgrps.c index 7768f1325..b90828e1e 100644 --- a/lib/addgrps.c +++ b/lib/addgrps.c @@ -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; diff --git a/src/groupmod.c b/src/groupmod.c index 5b90c2342..c29f90508 100644 --- a/src/groupmod.c +++ b/src/groupmod.c @@ -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) {