lib/commonio.c: commonio_open(): MALLOC() and REALLOCF() already set ENOMEM

We don't need to set ENOMEM on failure of those functions.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2024-05-12 23:15:12 +02:00
committed by Serge Hallyn
parent d611d1a947
commit 077f7b6ade

View 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;