1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00

kunit: Annotate _MSG assertion variants with gnu printf specifiers

KUnit's assertion macros have variants which accept a printf format
string, to allow tests to specify a more detailed message on failure.
These (and the related KUNIT_FAIL() macro) ultimately wrap the
__kunit_do_failed_assertion() function, which accepted a printf format
specifier, but did not have the __printf attribute, so gcc couldn't warn
on incorrect agruments.

It turns out there were quite a few tests with such incorrect arguments.

Add the __printf() specifier now that we've fixed these errors, to
prevent them from recurring.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: David Gow <davidgow@google.com>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Justin Stitt <justinstitt@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
David Gow 2024-02-21 17:27:22 +08:00 committed by Shuah Khan
parent fc9a615200
commit 806cb22702

View file

@ -579,7 +579,7 @@ void __printf(2, 3) kunit_log_append(struct string_stream *log, const char *fmt,
void __noreturn __kunit_abort(struct kunit *test); void __noreturn __kunit_abort(struct kunit *test);
void __kunit_do_failed_assertion(struct kunit *test, void __printf(6, 7) __kunit_do_failed_assertion(struct kunit *test,
const struct kunit_loc *loc, const struct kunit_loc *loc,
enum kunit_assert_type type, enum kunit_assert_type type,
const struct kunit_assert *assert, const struct kunit_assert *assert,