]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/commonio.c: commonio_open(): MALLOC() and REALLOCF() already set ENOMEM
authorAlejandro Colomar <alx@kernel.org>
Sun, 12 May 2024 21:15:12 +0000 (23:15 +0200)
committerSerge Hallyn <serge@hallyn.com>
Tue, 2 Jul 2024 02:40:11 +0000 (21:40 -0500)
We don't need to set ENOMEM on failure of those functions.

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

index 1a6f1db5b2325ba2df7a784745fedc80c3a41ab4..1d0ba8909cc54fc31076285947dfbe848e4ba966 100644 (file)
@@ -635,9 +635,8 @@ int commonio_open (struct commonio_db *db, int mode)
 
        buflen = BUFLEN;
        buf = MALLOC(buflen, char);
-       if (NULL == buf) {
-               goto cleanup_ENOMEM;
-       }
+       if (NULL == buf)
+               goto cleanup_errno;
 
        while (db->ops->fgets (buf, buflen, db->fp) == buf) {
                char                   *cp;
@@ -649,9 +648,9 @@ int commonio_open (struct commonio_db *db, int mode)
 
                        buflen += BUFLEN;
                        buf = REALLOCF(buf, buflen, char);
-                       if (NULL == buf) {
-                               goto cleanup_ENOMEM;
-                       }
+                       if (NULL == buf)
+                               goto cleanup_errno;
+
                        len = strlen (buf);
                        if (db->ops->fgets (buf + len,
                                            (int) (buflen - len),
@@ -714,7 +713,6 @@ int commonio_open (struct commonio_db *db, int mode)
        free (line);
       cleanup_buf:
        free (buf);
-      cleanup_ENOMEM:
        errno = ENOMEM;
       cleanup_errno:
        saved_errno = errno;