[PATCH] trace: define TEST_FAIL and TEST_FAIL_TAG as inline function

Benjamin Berg benjamin at sipsolutions.net
Tue Oct 14 01:09:43 PDT 2025


From: Benjamin Berg <benjamin.berg at intel.com>

While these macros are usually used in conditions, they can also simply
be used as a statement in order to check whether a certain code path was
taken. In that case, using a macro that turns into a constant 0 may
cause a compiler warning.

Avoid that issue by using a static inline function that returns 0. This
fixes a build regression introduced by f5790e97cd64 ("nl80211: Delay
event processing during command handling").

Fixes: f5790e97cd64 ("nl80211: Delay event processing during command handling")
Reported-by: Ben Greear <greearb at candelatech.com>
Signed-off-by: Benjamin Berg <benjamin.berg at intel.com>
---
 src/utils/os.h | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/utils/os.h b/src/utils/os.h
index 1bbaea3a4b..9d6c340966 100644
--- a/src/utils/os.h
+++ b/src/utils/os.h
@@ -685,16 +685,19 @@ int os_exec(const char *program, const char *arg, int wait_completion);
 #define strcpy OS_DO_NOT_USE_strcpy
 #endif /* OS_REJECT_C_LIB_FUNCTIONS */
 
-
-#if defined(WPA_TRACE_BFD) && defined(CONFIG_TESTING_OPTIONS)
 #define TEST_FAIL() testing_test_fail(NULL, false)
 #define TEST_FAIL_TAG(tag) testing_test_fail(tag, false)
+
+#if defined(WPA_TRACE_BFD) && defined(CONFIG_TESTING_OPTIONS)
 int testing_test_fail(const char *tag, bool is_alloc);
 int testing_set_fail_pattern(bool is_alloc, char *patterns);
 int testing_get_fail_pattern(bool is_alloc, char *buf, size_t buflen);
 #else
-#define TEST_FAIL() 0
-#define TEST_FAIL_TAG(tag) 0
+static inline int testing_test_fail(const char *tag, bool is_alloc)
+{
+	return 0;
+}
+
 static inline int testing_set_fail_pattern(bool is_alloc, char *patterns)
 {
 	return -1;
-- 
2.51.0




More information about the Hostap mailing list