From cb48f21ed94bbd7290fda75afef20bac8b87ca03 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 2 Mar 2023 14:07:38 +0100 Subject: [PATCH] include/c: make err_oom() usable everywhere Signed-off-by: Karel Zak --- include/c.h | 10 +++++++++- include/xalloc.h | 9 --------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/include/c.h b/include/c.h index 23fff37025..2b70e8d18b 100644 --- a/include/c.h +++ b/include/c.h @@ -286,6 +286,15 @@ errmsg(char doexit, int excode, char adderr, const char *fmt, ...) #endif /* !HAVE_ERR_H */ +static inline +__attribute__((__noreturn__)) +void __err_oom(const char *file, unsigned int line) +{ + err(EXIT_FAILURE, "%s: %u: cannot allocate memory", file, line); +} +#define err_oom() __err_oom(__FILE__, __LINE__) + + /* Don't use inline function to avoid '#include "nls.h"' in c.h */ #define errtryhelp(eval) __extension__ ({ \ @@ -300,7 +309,6 @@ errmsg(char doexit, int excode, char adderr, const char *fmt, ...) #define errexec(name) err(errno == ENOENT ? EX_EXEC_ENOENT : EX_EXEC_FAILED, \ _("failed to execute %s"), name) - static inline __attribute__((const)) int is_power_of_2(unsigned long num) { return (num != 0 && ((num & (num - 1)) == 0)); diff --git a/include/xalloc.h b/include/xalloc.h index 4f6a9e233e..1dee5fe9c2 100644 --- a/include/xalloc.h +++ b/include/xalloc.h @@ -22,15 +22,6 @@ # define XALLOC_EXIT_CODE EXIT_FAILURE #endif -static inline -__attribute__((__noreturn__)) -void __err_oom(const char *file, unsigned int line) -{ - err(XALLOC_EXIT_CODE, "%s: %u: cannot allocate memory", file, line); -} - -#define err_oom() __err_oom(__FILE__, __LINE__) - static inline __ul_alloc_size(1) __ul_returns_nonnull -- 2.47.2