Skip to content

Commit ee7fa1d

Browse files
alejandro-colomarhallyn
authored andcommitted
lib/, src/: Reduce scope of local variables
Signed-off-by: Alejandro Colomar <[email protected]>
1 parent 0ff87bf commit ee7fa1d

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

lib/addgrps.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
int
3737
add_groups(const char *list)
3838
{
39-
char *g, *p, *dup;
39+
char *dup;
4040
FILE *shadow_logfd = log_get_logfd();
4141
gid_t *gids;
4242
size_t n;
@@ -49,11 +49,14 @@ add_groups(const char *list)
4949
if (gids == NULL)
5050
return -1;
5151

52-
p = dup = strdup(list);
52+
dup = strdup(list);
5353
if (dup == NULL)
5454
goto free_gids;
5555

5656
if (!streq(dup, "")) {
57+
char *g, *p;
58+
59+
p = dup;
5760
while (NULL != (g = strsep(&p, ",:"))) {
5861
struct group *grp;
5962

src/groupmod.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,6 @@ grp_update(void)
259259
}
260260

261261
if (user_list) {
262-
char *u, *ul;
263-
264262
if (!aflg) {
265263
// requested to replace the existing groups
266264
grp.gr_mem = xmalloc_T(1, char *);
@@ -283,6 +281,8 @@ grp_update(void)
283281
#endif /* SHADOWGRP */
284282

285283
if (!streq(user_list, "")) {
284+
char *u, *ul;
285+
286286
ul = user_list;
287287
while (NULL != (u = strsep(&ul, ","))) {
288288
if (prefix_getpwnam(u) == NULL) {

0 commit comments

Comments
 (0)