Skip to content

Commit 806cb22

Browse files
sulixshuahkh
authored andcommitted
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>
1 parent fc9a615 commit 806cb22

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

include/kunit/test.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -579,12 +579,12 @@ void __printf(2, 3) kunit_log_append(struct string_stream *log, const char *fmt,
579579

580580
void __noreturn __kunit_abort(struct kunit *test);
581581

582-
void __kunit_do_failed_assertion(struct kunit *test,
583-
const struct kunit_loc *loc,
584-
enum kunit_assert_type type,
585-
const struct kunit_assert *assert,
586-
assert_format_t assert_format,
587-
const char *fmt, ...);
582+
void __printf(6, 7) __kunit_do_failed_assertion(struct kunit *test,
583+
const struct kunit_loc *loc,
584+
enum kunit_assert_type type,
585+
const struct kunit_assert *assert,
586+
assert_format_t assert_format,
587+
const char *fmt, ...);
588588

589589
#define _KUNIT_FAILED(test, assert_type, assert_class, assert_format, INITIALIZER, fmt, ...) do { \
590590
static const struct kunit_loc __loc = KUNIT_CURRENT_LOC; \

0 commit comments

Comments
 (0)