Skip to content

Commit 82649c7

Browse files
sulixshuahkh
authored andcommitted
kunit: Add printf attribute to fail_current_test_impl
Add the gnu_printf (__printf()) attribute to the kunit_fail_current_test() implementation in __kunit_fail_current_test_impl(). While it's not actually useful here, as this function is never called directly, it nevertheless was triggering -Wsuggest-attribute=format warnings, so we should add it to reduce the noise. Fixes: cc3ed2f ("kunit: Add "hooks" to call into KUnit when it's built as a module") Reported-by: kernel test robot <[email protected]> Signed-off-by: David Gow <[email protected]> Reviewed-by: Rae Moar <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent 789538c commit 82649c7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/kunit/hooks-impl.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
#include <kunit/test-bug.h>
1616

1717
/* List of declarations. */
18-
void __kunit_fail_current_test_impl(const char *file, int line, const char *fmt, ...);
18+
void __printf(3, 4) __kunit_fail_current_test_impl(const char *file,
19+
int line,
20+
const char *fmt, ...);
1921
void *__kunit_get_static_stub_address_impl(struct kunit *test, void *real_fn_addr);
2022

2123
/* Code to set all of the function pointers. */

lib/kunit/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/*
2525
* Hook to fail the current test and print an error message to the log.
2626
*/
27-
void __kunit_fail_current_test_impl(const char *file, int line, const char *fmt, ...)
27+
void __printf(3, 4) __kunit_fail_current_test_impl(const char *file, int line, const char *fmt, ...)
2828
{
2929
va_list args;
3030
int len;

0 commit comments

Comments
 (0)