From 077f7b6adebc93ef57af4cdb3e21840aaea04fc6 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Sun, 12 May 2024 23:15:12 +0200 Subject: [PATCH] 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 --- lib/commonio.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/commonio.c b/lib/commonio.c index 1a6f1db5..1d0ba890 100644 --- a/lib/commonio.c +++ b/lib/commonio.c @@ -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;