From f33f4c85581045ae493e7f12c6ba1bf5829d8192 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 4 Apr 2025 13:50:04 +0200 Subject: [PATCH] lib: Prevent double inclusion of config.h through system.h Files that include both 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 Signed-off-by: Mark Wielaard --- lib/crc32.c | 2 +- lib/error.c | 4 +++- lib/system.h | 7 ++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/crc32.c b/lib/crc32.c index 758602ea0..eae658225 100644 --- a/lib/crc32.c +++ b/lib/crc32.c @@ -25,7 +25,7 @@ the GNU Lesser General Public License along with this program. If not, see . */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H #include #endif diff --git a/lib/error.c b/lib/error.c index 5186fc15e..75c9eafb5 100644 --- a/lib/error.c +++ b/lib/error.c @@ -26,7 +26,9 @@ the GNU Lesser General Public License along with this program. If not, see . */ -#include +#ifdef HAVE_CONFIG_H +# include +#endif #if !defined(HAVE_ERROR_H) && defined(HAVE_ERR_H) #include diff --git a/lib/system.h b/lib/system.h index 0698e5ffb..c17e2aa0f 100644 --- a/lib/system.h +++ b/lib/system.h @@ -31,7 +31,12 @@ #ifndef LIB_SYSTEM_H #define LIB_SYSTEM_H 1 -#include +/* Prevent double inclusion of config.h, config.h includes eu-config.h. */ +#ifdef HAVE_CONFIG_H +#ifndef EU_CONFIG_H +# include +#endif +#endif #include #include -- 2.47.2