From c8c105938480d0e2c531049292923f1c969d1332 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Mon, 4 Nov 2024 16:37:48 +0100 Subject: [PATCH] src/: Transform do-while into while list cannot be NULL in the first iteration, so we don't need a do-while. Just in case it's not obvious: we know it's not NULL in the first iteration because right above, in line 772, we've already dereferenced it. Signed-off-by: Alejandro Colomar --- src/useradd.c | 4 ++-- src/usermod.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/useradd.c b/src/useradd.c index 058b09d92..891fd1420 100644 --- a/src/useradd.c +++ b/src/useradd.c @@ -784,7 +784,7 @@ static int get_groups (char *list) * each name and look it up. A mix of numerical and string * values for group identifiers is permitted. */ - do { + while (NULL != list) { char *g; /* @@ -832,7 +832,7 @@ static int get_groups (char *list) */ user_groups[ngroups++] = xstrdup (grp->gr_name); gr_free (grp); - } while (NULL != list); + } close_group_files (); unlock_group_files (); diff --git a/src/usermod.c b/src/usermod.c index 8cff1d67f..f33aec31e 100644 --- a/src/usermod.c +++ b/src/usermod.c @@ -236,7 +236,7 @@ static int get_groups (char *list) * name and look it up. A mix of numerical and string values for * group identifiers is permitted. */ - do { + while (NULL != list) { char *g; /* @@ -281,7 +281,7 @@ static int get_groups (char *list) */ user_groups[ngroups++] = xstrdup (grp->gr_name); gr_free (grp); - } while (NULL != list); + } user_groups[ngroups] = NULL; -- 2.47.2