]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
lib: avoid potential problems with `-fno-common`
authorSaleem Abdulrasool <abdulras@google.com>
Fri, 27 Aug 2021 15:51:47 +0000 (15:51 +0000)
committerMark Wielaard <mark@klomp.org>
Fri, 27 Aug 2021 16:34:15 +0000 (18:34 +0200)
This properly homes the fallback function into a translation unit rather
than trying to define an inline common definition for the fallback path.
The intent of the original approach was to actually simply avoid adding
a new source file that is used for the fallback path.  However, that may
cause trouble with multiple definitions if the symbol does not get vague
linkage (which itself is not particularly great).  This simplifies the
behaviour at the cost of an extra inode.

lib/ChangeLog
lib/Makefile.am
lib/system.h

index cf676742f8d8a1e7f6b24defb8bbd80fdced4657..60d320827943cdddd5c6a0c55066bfb4de35354b 100644 (file)
@@ -1,3 +1,12 @@
+2021-08-23  Saleem Abdulrasool  <abdulras@google.com>
+
+       * system.h: Remove inline definition for error and error_message_count
+       in the fallback path.
+       * Makefile.am (libeu_a_SOURCES): Add error.c.
+       * error.c: New file, moves the previous inline definitions to avoid
+       multiple definitions properly rather than relying on -fcommon and vague
+       linkage.
+
 2021-08-21  Saleem Abdulrasool  <abdulras@google.com>
 
        * fixedsizehash.h: Remove unused STROF macro.
index 97bf7329cc4c1eb1b0d4e5cae9bd3323df94d68f..766fbcd73c9ef8eeeb0e276f88c4bcbf3c7a8694 100644 (file)
@@ -35,7 +35,7 @@ noinst_LIBRARIES = libeu.a
 
 libeu_a_SOURCES = xstrdup.c xstrndup.c xmalloc.c next_prime.c \
                  crc32.c crc32_file.c \
-                 color.c printversion.c
+                 color.c error.c printversion.c
 
 noinst_HEADERS = fixedsizehash.h libeu.h system.h dynamicsizehash.h list.h \
                 eu-config.h color.h printversion.h bpf.h \
index b963fd156391f2c1232bffb0a2fe2bb379d31b49..edbc8488508a886d37ec4b70e887258b87f9ad25 100644 (file)
 #if defined(HAVE_ERROR_H)
 #include <error.h>
 #elif defined(HAVE_ERR_H)
-#include <err.h>
-
-static int error_message_count = 0;
-
-static inline void error(int status, int errnum, const char *format, ...) {
-  va_list argp;
-
-  va_start(argp, format);
-  verr(status, format, argp);
-  va_end(argp);
-
-  if (status)
-    exit(status);
-  ++error_message_count;
-}
+extern int error_message_count;
+void error(int status, int errnum, const char *format, ...);
 #else
 #error "err.h or error.h must be available"
 #endif