diff options
author | Mark Wielaard <[email protected]> | 2025-04-04 13:50:04 +0200 |
---|---|---|
committer | Mark Wielaard <[email protected]> | 2025-04-06 18:31:37 +0200 |
commit | f33f4c85581045ae493e7f12c6ba1bf5829d8192 (patch) | |
tree | a36fd8c1b6085c8a7e8c0e1434a64698add438d7 | |
parent | 3b71249d4396f742d68e774313c2a2d9caf4d668 (diff) |
lib: Prevent double inclusion of config.h through system.h
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 <[email protected]>
Signed-off-by: Mark Wielaard <[email protected]>
-rw-r--r-- | lib/crc32.c | 2 | ||||
-rw-r--r-- | lib/error.c | 4 | ||||
-rw-r--r-- | lib/system.h | 7 |
3 files changed, 10 insertions, 3 deletions
diff --git a/lib/crc32.c b/lib/crc32.c index 758602ea..eae65822 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 <http://www.gnu.org/licenses/>. */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H #include <config.h> #endif diff --git a/lib/error.c b/lib/error.c index 5186fc15..75c9eafb 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 <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> diff --git a/lib/system.h b/lib/system.h index 0698e5ff..c17e2aa0 100644 --- a/lib/system.h +++ b/lib/system.h @@ -31,7 +31,12 @@ #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> |