]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
lib: Prevent double inclusion of config.h through system.h
authorMark Wielaard <mark@klomp.org>
Fri, 4 Apr 2025 11:50:04 +0000 (13:50 +0200)
committerMark Wielaard <mark@klomp.org>
Sun, 6 Apr 2025 16:31:37 +0000 (18:31 +0200)
Files that include both <config.h> and "system.h" might include
config.h twice. Prevent that by adding a guard check in system.h
before including config.h.

       * lib/crc32.c: Use #ifdef HAVE_CONFIG_H instead of #if.
       * lib/error.h: Check HAVE_CONFIG_H before including config.h.
       * lib/system.h: Check both HAVE_CONFIG_H and whether
       EU_CONFIG_H is defined before including config.h.

Suggested-by: Dmitry V. Levin <ldv@strace.io>
Signed-off-by: Mark Wielaard <mark@klomp.org>
lib/crc32.c
lib/error.c
lib/system.h

index 758602ea02fd210a2ad9da66939df7fc3e086235..eae658225f76a5fdb8f304b651f598640c390ebf 100644 (file)
@@ -25,7 +25,7 @@
    the GNU Lesser General Public License along with this program.  If
    not, see <http://www.gnu.org/licenses/>.  */
 
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
 
index 5186fc15e9d59907dc3e4f67bb8f4a6d09793929..75c9eafb58baebefdf1b97452c8295e32b7bd6c4 100644 (file)
@@ -26,7 +26,9 @@
    the GNU Lesser General Public License along with this program.  If
    not, see <http://www.gnu.org/licenses/>.  */
 
-#include <config.h>
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
 
 #if !defined(HAVE_ERROR_H) && defined(HAVE_ERR_H)
 #include <errno.h>
index 0698e5ffbe2f7896b97ab619576ea5275bbf5ba1..c17e2aa0fea179088f612b034b56de182651c094 100644 (file)
 #ifndef LIB_SYSTEM_H
 #define LIB_SYSTEM_H   1
 
-#include <config.h>
+/* Prevent double inclusion of config.h, config.h includes eu-config.h.  */
+#ifdef HAVE_CONFIG_H
+#ifndef EU_CONFIG_H
+# include <config.h>
+#endif
+#endif
 
 #include <errno.h>
 #include <stdbool.h>