From: Karel Zak Date: Thu, 2 Mar 2023 13:07:38 +0000 (+0100) Subject: include/c: make err_oom() usable everywhere X-Git-Tag: v2.39-rc1~35 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cb48f21ed94bbd7290fda75afef20bac8b87ca03;p=thirdparty%2Futil-linux.git include/c: make err_oom() usable everywhere Signed-off-by: Karel Zak --- 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