diff options
author | Alejandro Colomar <alx@kernel.org> | 2023-05-27 03:24:49 +0200 |
---|---|---|
committer | Serge Hallyn <serge@hallyn.com> | 2023-05-30 13:56:55 -0500 |
commit | 89c9427087f029cad177eb8fee6884d1b218a3ab (patch) | |
tree | 338c33f5f4a5829d9ebcc16c3a9bfb3f5ae48485 | |
parent | c8741a400d6a6208c334c5228b9f2db28401b578 (diff) |
xgetXXbyYY: Centralize error handling
Signed-off-by: Alejandro Colomar <alx@kernel.org>
-rw-r--r-- | libmisc/xgetXXbyYY.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/libmisc/xgetXXbyYY.c b/libmisc/xgetXXbyYY.c index 78034bc0..36b9a150 100644 --- a/libmisc/xgetXXbyYY.c +++ b/libmisc/xgetXXbyYY.c @@ -54,9 +54,7 @@ result = MALLOC(LOOKUP_TYPE); if (NULL == result) { - fprintf (log_get_logfd(), _("%s: out of memory\n"), - "x" STRINGIZE(FUNCTION_NAME)); - exit (13); + goto oom; } while (true) { @@ -70,10 +68,7 @@ * the shadow *_free functions. */ LOOKUP_TYPE *ret_result = DUP_FUNCTION(result); if (NULL == ret_result) { - fprintf (log_get_logfd(), - _("%s: out of memory\n"), - "x" STRINGIZE(FUNCTION_NAME)); - exit (13); + goto oom; } free(buffer); free(result); @@ -110,13 +105,16 @@ if (result) { result = DUP_FUNCTION(result); if (NULL == result) { - fprintf (log_get_logfd(), _("%s: out of memory\n"), - "x" STRINGIZE(FUNCTION_NAME)); - exit (13); + goto oom; } } return result; #endif + +oom: + fprintf (log_get_logfd(), _("%s: out of memory\n"), + "x" STRINGIZE(FUNCTION_NAME)); + exit (13); } |