]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
include/c: make err_oom() usable everywhere
authorKarel Zak <kzak@redhat.com>
Thu, 2 Mar 2023 13:07:38 +0000 (14:07 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 2 Mar 2023 13:07:38 +0000 (14:07 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
include/c.h
include/xalloc.h

index 23fff37025d50bf537639ebcb2bdb6ecbad9b050..2b70e8d18b491e9233bcdc9351615464068b2f60 100644 (file)
@@ -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));
index 4f6a9e233ecce50fbc36fa4b2ae703929c8c33f1..1dee5fe9c243941a8a68e9920cf824b596e091a8 100644 (file)
 # 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