]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/gshadow.c: sgetsgent(): Remove superfluous condition
authorAlejandro Colomar <alx@kernel.org>
Mon, 4 Nov 2024 20:47:42 +0000 (21:47 +0100)
committerSerge Hallyn <serge@hallyn.com>
Fri, 6 Dec 2024 03:20:59 +0000 (21:20 -0600)
If n was 0, it doesn't hurt to set it again to 0;
and the list would be NULL, so it doesn't hurt free(3)ing it
and setting to NULL again either.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/gshadow.c

index f2ce31f2dfeda909a65c8e8cdc3a4d8787e04151..15e1ac977c40dc0dd246fdfb9d83126e6ade6f6d 100644 (file)
@@ -75,7 +75,8 @@ void endsgent (void)
        shadow = NULL;
 }
 
-/*@observer@*//*@null@*/struct sgrp *sgetsgent (const char *string)
+/*@observer@*//*@null@*/struct sgrp *
+sgetsgent(const char *string)
 {
        static char *sgrbuf = NULL;
        static size_t sgrbuflen = 0;
@@ -115,16 +116,14 @@ void endsgent (void)
 
        sgroup.sg_name = fields[0];
        sgroup.sg_passwd = fields[1];
-       if (0 != nadmins) {
-               nadmins = 0;
-               free (admins);
-               admins = NULL;
-       }
-       if (0 != nmembers) {
-               nmembers = 0;
-               free (members);
-               members = NULL;
-       }
+
+       nadmins = 0;
+       free (admins);
+       admins = NULL;
+       nmembers = 0;
+       free (members);
+       members = NULL;
+
        sgroup.sg_adm = build_list (fields[2], &admins, &nadmins);
        sgroup.sg_mem = build_list (fields[3], &members, &nmembers);