a8bae35914
GCC 8.0+ <https://gcc.gnu.org/gcc-8/changes.html> introduces a new warning about unsafe macros expanding to multiple statements used as a body of a statement such as if, else, while, switch, or for. In combination with -Werror this can cause the compilation to fail: |In file included from xmalloc.c:37: |xmalloc.c: In function 'xmalloc': |system.h:39:2: error: macro expands to multiple statements [-Werror=multistatement-macros] | fflush(stdout); \ | ^~~~~~ |xmalloc.c:52:5: note: in expansion of macro 'error' | error (EXIT_FAILURE, 0, _("memory exhausted")); | ^~~~~ |xmalloc.c:51:3: note: some parts of macro expansion are not guarded by this 'if' clause | if (p == NULL) | ^~ Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
65 lines
1.5 KiB
Diff
65 lines
1.5 KiB
Diff
https://sourceware.org/bugzilla/show_bug.cgi?id=21002
|
|
|
|
--- a/lib/system.h
|
|
+++ b/lib/system.h
|
|
@@ -30,7 +30,18 @@
|
|
#define LIB_SYSTEM_H 1
|
|
|
|
#include <errno.h>
|
|
-#include <error.h>
|
|
+#ifdef HAVE_ERROR_H
|
|
+#include "error.h"
|
|
+#else
|
|
+#include "err.h"
|
|
+#include <stdio.h>
|
|
+#define error(status, errno, ...) \
|
|
+ do { \
|
|
+ fflush(stdout); \
|
|
+ warn(__VA_ARGS__); \
|
|
+ if (status) exit(status); \
|
|
+ } while(0)
|
|
+#endif
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <sys/param.h>
|
|
@@ -38,6 +49,10 @@
|
|
#include <byteswap.h>
|
|
#include <unistd.h>
|
|
|
|
+#ifndef __GLIBC__
|
|
+#define canonicalize_file_name(name) realpath(name,NULL)
|
|
+#endif
|
|
+
|
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
|
# define LE32(n) (n)
|
|
# define LE64(n) (n)
|
|
--- a/libdw/libdw_alloc.c
|
|
+++ b/libdw/libdw_alloc.c
|
|
@@ -73,5 +73,5 @@ __attribute ((noreturn)) attribute_hidde
|
|
__libdw_oom (void)
|
|
{
|
|
while (1)
|
|
- error (EXIT_FAILURE, ENOMEM, "libdw");
|
|
+ error (EXIT_FAILURE, errno, gettext ("cannot allocate memory"));
|
|
}
|
|
--- a/libdwfl/dwfl_error.c
|
|
+++ b/libdwfl/dwfl_error.c
|
|
@@ -140,6 +140,7 @@ __libdwfl_seterrno (Dwfl_Error error)
|
|
const char *
|
|
dwfl_errmsg (int error)
|
|
{
|
|
+ static __thread char s[64] = "";
|
|
if (error == 0 || error == -1)
|
|
{
|
|
int last_error = global_error;
|
|
@@ -154,7 +155,8 @@ dwfl_errmsg (int error)
|
|
switch (error &~ 0xffff)
|
|
{
|
|
case OTHER_ERROR (ERRNO):
|
|
- return strerror_r (error & 0xffff, "bad", 0);
|
|
+ strerror_r (error & 0xffff, s, sizeof(s));
|
|
+ return s;
|
|
case OTHER_ERROR (LIBELF):
|
|
return elf_errmsg (error & 0xffff);
|
|
case OTHER_ERROR (LIBDW):
|