]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/: Rename local variable
authorAlejandro Colomar <alx@kernel.org>
Sat, 7 Dec 2024 12:17:01 +0000 (13:17 +0100)
committerSerge Hallyn <serge@hallyn.com>
Fri, 30 May 2025 21:11:16 +0000 (16:11 -0500)
Call it 'dup', which reminds that it's a strdup(3)d string.

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

index 86559b31a3fd54f526561ed7a61c8c33f4f30277..efb04629918dfd64a2dcc44ffb60b6cf4dc752e6 100644 (file)
@@ -71,25 +71,25 @@ void endsgent (void)
 /*@observer@*//*@null@*/struct sgrp *
 sgetsgent(const char *s)
 {
-       static char *sgrbuf = NULL;
+       static char  *dup = NULL;
 
        char *fields[FIELDS];
        char *cp;
        int i;
 
-       free(sgrbuf);
-       sgrbuf = strdup(s);
-       if (sgrbuf == NULL)
+       free(dup);
+       dup = strdup(s);
+       if (dup == NULL)
                return NULL;
 
-       stpsep(sgrbuf, "\n");
+       stpsep(dup, "\n");
 
        /*
         * There should be exactly 4 colon separated fields.  Find
         * all 4 of them and save the starting addresses in fields[].
         */
 
-       for (cp = sgrbuf, i = 0; (i < FIELDS) && (NULL != cp); i++)
+       for (cp = dup, i = 0; (i < FIELDS) && (NULL != cp); i++)
                fields[i] = strsep(&cp, ":");
 
        /*
index 37608344d3a7883b17a6cc5649a51182f9706de2..da5601ffc5dc0daf2b8c91ac631eed1689ffe86b 100644 (file)
@@ -68,20 +68,20 @@ list(char *s)
 struct group *
 sgetgrent(const char *s)
 {
-       static char *grpbuf = NULL;
+       static char         *dup = NULL;
        static char *grpfields[NFIELDS];
        static struct group grent;
        int i;
        char *cp;
 
-       free(grpbuf);
-       grpbuf = strdup(s);
-       if (grpbuf == NULL)
+       free(dup);
+       dup = strdup(s);
+       if (dup == NULL)
                return NULL;
 
-       stpsep(grpbuf, "\n");
+       stpsep(dup, "\n");
 
-       for (cp = grpbuf, i = 0; (i < NFIELDS) && (NULL != cp); i++)
+       for (cp = dup, i = 0; (i < NFIELDS) && (NULL != cp); i++)
                grpfields[i] = strsep(&cp, ":");
 
        if (i < NFIELDS || streq(grpfields[2], "") || cp != NULL) {
index e155ed0a0ffc72cdc387cb0b1f81b2c509ceb083..61e1e4ed86bd8496c803457467d0a0d765b6d6f0 100644 (file)
 struct passwd *
 sgetpwent(const char *s)
 {
-       static char  *pwdbuf = NULL;
+       static char          *dup = NULL;
        static struct passwd pwent;
        int i;
        char *cp;
        char *fields[NFIELDS];
 
-       free(pwdbuf);
-       pwdbuf = strdup(s);
-       if (pwdbuf == NULL)
+       free(dup);
+       dup = strdup(s);
+       if (dup == NULL)
                return NULL;
 
        /*
@@ -57,7 +57,7 @@ sgetpwent(const char *s)
         * field.  The fields are converted into NUL terminated strings.
         */
 
-       for (cp = pwdbuf, i = 0; (i < NFIELDS) && (NULL != cp); i++)
+       for (cp = dup, i = 0; (i < NFIELDS) && (NULL != cp); i++)
                fields[i] = strsep(&cp, ":");
 
        /* something at the end, columns over shot */
index 8d58f520432dfc014c06fd37848d40dee3a61755..e2d247d82a89434d47943457d8515afe009dd96c 100644 (file)
 struct spwd *
 sgetspent(const char *s)
 {
-       static char  *spwbuf = NULL;
+       static char        *dup = NULL;
        static struct spwd spwd;
        char *fields[FIELDS];
        char *cp;
        int i;
 
-       free(spwbuf);
-       spwbuf = strdup(s);
-       if (spwbuf == NULL)
+       free(dup);
+       dup = strdup(s);
+       if (dup == NULL)
                return NULL;
 
-       stpsep(spwbuf, "\n");
+       stpsep(dup, "\n");
 
        /*
         * Tokenize the string into colon separated fields.  Allow up to
         * FIELDS different fields.
         */
 
-       for (cp = spwbuf, i = 0; cp != NULL && i < FIELDS; i++)
+       for (cp = dup, i = 0; cp != NULL && i < FIELDS; i++)
                fields[i] = strsep(&cp, ":");
 
        if (i == (FIELDS - 1))