Skip to contentSkip to conversation

kunit: fix -Wunused-function warning for __kunit_fail_current_test

PATCH In review Daniel Latypov 3 participants 3 messages Apr 6, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kunit: fix -Wunused-function warning for __kunit_fail_current_test

When CONFIG_KUNIT is not enabled, __kunit_fail_current_test() an empty static function.

But GCC complains about unused static functions, *unless* they're static inline. So add inline to make GCC happy.

Fixes 359a376081d4 ("kunit: support failure from dynamic analysis tools")
---
 include/kunit/test-bug.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/kunit/test-bug.h +2 -2
index ce6f6edc7801..5fc58081d511 100644
@@ -19,8 +19,8 @@ extern __printf(3, 4) void __kunit_fail_current_test(const char *file, int line,
 
 #else
 
-static __printf(3, 4) void __kunit_fail_current_test(const char *file, int line,
-						    const char *fmt, ...)
+static inline __printf(3, 4) void __kunit_fail_current_test(const char *file, int line,
+							    const char *fmt, ...)
 {
 }
 

base-commit: 359a376081d4fadfb073e3ddeb6bd6dc94d98341

Signature · 1 line
2.31.0.208.g409f899ff0-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Daniel Latypov

When CONFIG_KUNIT is not enabled, __kunit_fail_current_test() an empty static function.

But GCC complains about unused static functions, *unless* they're static inline. So add inline to make GCC happy.

Fixes 359a376081d4 ("kunit: support failure from dynamic analysis tools")
maintainer
#2 lore raw
Quoted 11 lines · Brendan Higgins
Quoted 9 lines · Daniel Latypov

When CONFIG_KUNIT is not enabled, __kunit_fail_current_test() an empty static function.

But GCC complains about unused static functions, *unless* they're static inline. So add inline to make GCC happy.

Fixes 359a376081d4 ("kunit: support failure from dynamic analysis tools")

Signed-off-by comes after Fixes. Also good to add Reported-by for Stephen acknowledging the reporter.

I will fix this up when I apply - for future reference.

Quoted 2 lines

thanks,
-- Shuah