From 7b43dd4504e1a3764cda2cca23ab77fa0f50b9b9 Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Wed, 10 Jun 2026 13:44:38 -0500 Subject: [PATCH] fix: guard HAVE_MAT_LIVEEVENTINSPECTOR/PRIVACYGUARD against redefinition Under -Werror on Linux/macOS, the modules-repo CI (build-posix-latest-exp) has been failing for ~2 weeks with: config-default.h:36: error: 'HAVE_MAT_LIVEEVENTINSPECTOR' macro redefined [-Werror,-Wmacro-redefined] config-default.h:37: error: 'HAVE_MAT_PRIVACYGUARD' macro redefined tests/functests/CMakeLists.txt and tests/unittests/CMakeLists.txt add -DHAVE_MAT_LIVEEVENTINSPECTOR / -DHAVE_MAT_PRIVACYGUARD on the command line when BUILD_LIVEEVENTINSPECTOR / BUILD_PRIVACYGUARD (default YES) and the respective module dir exists. The three config-default headers then redefined them unconditionally, which is fatal under -Werror (added by #1415). Wrapping the two defines in #ifndef in all three config-default*.h headers preserves all existing behavior: - Without command-line -D: macros get defined here as before. - With command-line -D: header skips the redefinition, no warning. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- lib/include/mat/config-default-cs4.h | 8 ++++++++ lib/include/mat/config-default-exp.h | 8 ++++++++ lib/include/mat/config-default.h | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/lib/include/mat/config-default-cs4.h b/lib/include/mat/config-default-cs4.h index 7aae9fc7e..71a79c10f 100644 --- a/lib/include/mat/config-default-cs4.h +++ b/lib/include/mat/config-default-cs4.h @@ -27,8 +27,16 @@ /* #define HAVE_MAT_EVT_TRACEID */ #define HAVE_MAT_STORAGE #define HAVE_MAT_DEFAULT_HTTP_CLIENT +// The two macros below are also added on the command line by +// tests/{functests,unittests}/CMakeLists.txt when BUILD_LIVEEVENTINSPECTOR +// / BUILD_PRIVACYGUARD are ON. Guard against -Wmacro-redefined under +// -Werror on Linux/macOS. +#ifndef HAVE_MAT_LIVEEVENTINSPECTOR #define HAVE_MAT_LIVEEVENTINSPECTOR +#endif +#ifndef HAVE_MAT_PRIVACYGUARD #define HAVE_MAT_PRIVACYGUARD +#endif //#define HAVE_MAT_DEFAULT_FILTER #if defined(_WIN32) && !defined(_WINRT_DLL) #define HAVE_MAT_NETDETECT diff --git a/lib/include/mat/config-default-exp.h b/lib/include/mat/config-default-exp.h index 609692a01..256dfe615 100644 --- a/lib/include/mat/config-default-exp.h +++ b/lib/include/mat/config-default-exp.h @@ -25,8 +25,16 @@ /* #define HAVE_MAT_EVT_TRACEID */ #define HAVE_MAT_STORAGE #define HAVE_MAT_DEFAULT_HTTP_CLIENT +// The two macros below are also added on the command line by +// tests/{functests,unittests}/CMakeLists.txt when BUILD_LIVEEVENTINSPECTOR +// / BUILD_PRIVACYGUARD are ON. Guard against -Wmacro-redefined under +// -Werror on Linux/macOS. +#ifndef HAVE_MAT_LIVEEVENTINSPECTOR #define HAVE_MAT_LIVEEVENTINSPECTOR +#endif +#ifndef HAVE_MAT_PRIVACYGUARD #define HAVE_MAT_PRIVACYGUARD +#endif //#define HAVE_MAT_DEFAULT_FILTER #if defined(_WIN32) && !defined(_WINRT_DLL) #define HAVE_MAT_NETDETECT diff --git a/lib/include/mat/config-default.h b/lib/include/mat/config-default.h index 9617611c9..2ddce7dfc 100644 --- a/lib/include/mat/config-default.h +++ b/lib/include/mat/config-default.h @@ -33,8 +33,16 @@ /* #define HAVE_MAT_EVT_TRACEID */ #define HAVE_MAT_STORAGE #define HAVE_MAT_DEFAULT_HTTP_CLIENT +// The two macros below are also added on the command line by +// tests/{functests,unittests}/CMakeLists.txt when BUILD_LIVEEVENTINSPECTOR +// / BUILD_PRIVACYGUARD are ON. Guard against -Wmacro-redefined under +// -Werror on Linux/macOS. +#ifndef HAVE_MAT_LIVEEVENTINSPECTOR #define HAVE_MAT_LIVEEVENTINSPECTOR +#endif +#ifndef HAVE_MAT_PRIVACYGUARD #define HAVE_MAT_PRIVACYGUARD +#endif //#define HAVE_MAT_DEFAULT_FILTER #if defined(_WIN32) && !defined(_WINRT_DLL) #define HAVE_MAT_NETDETECT