netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/9] kunit: Fix printf format specifier issues in KUnit assertions
@ 2024-02-21  9:27 David Gow
  2024-02-21  9:27 ` [PATCH 1/9] kunit: test: Log the correct filter string in executor_test David Gow
                   ` (10 more replies)
  0 siblings, 11 replies; 43+ messages in thread
From: David Gow @ 2024-02-21  9:27 UTC (permalink / raw)
  To: Linus Torvalds, Shuah Khan, Guenter Roeck, Rae Moar,
	Matthew Auld, Arunpravin Paneer Selvam, Christian König,
	Kees Cook, Maíra Canal, Rodrigo Vivi, Matthew Brost,
	Willem de Bruijn, Florian Westphal, Cassio Neri,
	Javier Martinez Canillas, Arthur Grillo
  Cc: David Gow, Brendan Higgins, Daniel Latypov, Stephen Boyd,
	David Airlie, Maxime Ripard, David S . Miller, dri-devel,
	linux-kernel, intel-xe, linux-rtc, linux-kselftest, kunit-dev,
	linux-hardening, netdev

KUnit has several macros which accept a log message, which can contain
printf format specifiers. Some of these (the explicit log macros)
already use the __printf() gcc attribute to ensure the format specifiers
are valid, but those which could fail the test, and hence used
__kunit_do_failed_assertion() behind the scenes, did not.

These include:
- KUNIT_EXPECT_*_MSG()
- KUNIT_ASSERT_*_MSG()
- KUNIT_FAIL()

This series adds the __printf() attribute, and fixes all of the issues
uncovered. (Or, at least, all of those I could find with an x86_64
allyesconfig, and the default KUnit config on a number of other
architectures. Please test!)

The issues in question basically take the following forms:
- int / long / long long confusion: typically a type being updated, but
  the format string not.
- Use of integer format specifiers (%d/%u/%li/etc) for types like size_t
  or pointer differences (technically ptrdiff_t), which would only work
  on some architectures.
- Use of integer format specifiers in combination with PTR_ERR(), where
  %pe would make more sense.
- Use of empty messages which, whilst technically not incorrect, are not
  useful and trigger a gcc warning.

We'd like to get these (or equivalent) in for 6.9 if possible, so please
do take a look if possible.

Thanks,
-- David

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Closes: https://lore.kernel.org/linux-kselftest/CAHk-=wgJMOquDO5f8ShH1f4rzZwzApNVCw643m5-Yj+BfsFstA@mail.gmail.com/

David Gow (9):
  kunit: test: Log the correct filter string in executor_test
  lib/cmdline: Fix an invalid format specifier in an assertion msg
  lib: memcpy_kunit: Fix an invalid format specifier in an assertion msg
  time: test: Fix incorrect format specifier
  rtc: test: Fix invalid format specifier.
  net: test: Fix printf format specifier in skb_segment kunit test
  drm: tests: Fix invalid printf format specifiers in KUnit tests
  drm/xe/tests: Fix printf format specifiers in xe_migrate test
  kunit: Annotate _MSG assertion variants with gnu printf specifiers

 drivers/gpu/drm/tests/drm_buddy_test.c | 14 +++++++-------
 drivers/gpu/drm/tests/drm_mm_test.c    |  6 +++---
 drivers/gpu/drm/xe/tests/xe_migrate.c  |  8 ++++----
 drivers/rtc/lib_test.c                 |  2 +-
 include/kunit/test.h                   | 12 ++++++------
 kernel/time/time_test.c                |  2 +-
 lib/cmdline_kunit.c                    |  2 +-
 lib/kunit/executor_test.c              |  2 +-
 lib/memcpy_kunit.c                     |  4 ++--
 net/core/gso_test.c                    |  2 +-
 10 files changed, 27 insertions(+), 27 deletions(-)

-- 
2.44.0.rc0.258.g7320e95886-goog


^ permalink raw reply	[flat|nested] 43+ messages in thread

end of thread, other threads:[~2024-02-27 23:32 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-21  9:27 [PATCH 0/9] kunit: Fix printf format specifier issues in KUnit assertions David Gow
2024-02-21  9:27 ` [PATCH 1/9] kunit: test: Log the correct filter string in executor_test David Gow
2024-02-21 13:25   ` Guenter Roeck
2024-02-21 20:04   ` Justin Stitt
2024-02-21 20:29   ` Daniel Latypov
2024-02-22 20:58   ` Rae Moar
2024-02-21  9:27 ` [PATCH 2/9] lib/cmdline: Fix an invalid format specifier in an assertion msg David Gow
2024-02-21 13:25   ` Guenter Roeck
2024-02-21 20:10   ` Justin Stitt
2024-02-22  6:22     ` David Gow
2024-02-22 17:36       ` Daniel Latypov
2024-02-22 17:56         ` Linus Torvalds
2024-02-21  9:27 ` [PATCH 3/9] lib: memcpy_kunit: " David Gow
2024-02-21 13:25   ` Guenter Roeck
2024-02-21 21:05   ` Justin Stitt
2024-02-21  9:27 ` [PATCH 4/9] time: test: Fix incorrect format specifier David Gow
2024-02-21 13:25   ` Guenter Roeck
2024-02-21 21:06   ` Justin Stitt
2024-02-21  9:27 ` [PATCH 5/9] rtc: test: Fix invalid " David Gow
2024-02-21 13:26   ` Guenter Roeck
2024-02-21 21:06   ` Justin Stitt
2024-02-27 20:32   ` Alexandre Belloni
2024-02-27 21:23     ` Shuah Khan
2024-02-27 22:48       ` Alexandre Belloni
2024-02-21  9:27 ` [PATCH 6/9] net: test: Fix printf format specifier in skb_segment kunit test David Gow
2024-02-21 13:26   ` Guenter Roeck
2024-02-21 21:26   ` Justin Stitt
2024-02-21  9:27 ` [PATCH 7/9] drm: tests: Fix invalid printf format specifiers in KUnit tests David Gow
2024-02-21 10:21   ` Matthew Auld
2024-02-21 10:45   ` Christian König
2024-02-21 13:26   ` Guenter Roeck
2024-02-21 21:29   ` Justin Stitt
2024-02-27 23:24     ` Shuah Khan
2024-02-21  9:27 ` [PATCH 8/9] drm/xe/tests: Fix printf format specifiers in xe_migrate test David Gow
2024-02-21 13:26   ` Guenter Roeck
2024-02-22  5:05   ` Lucas De Marchi
2024-02-22  5:59     ` Linus Torvalds
2024-02-22  9:52   ` Thomas Hellström
2024-02-21  9:27 ` [PATCH 9/9] kunit: Annotate _MSG assertion variants with gnu printf specifiers David Gow
2024-02-21 13:26   ` Guenter Roeck
2024-02-21 20:02   ` Justin Stitt
2024-02-22 14:23 ` [PATCH 0/9] kunit: Fix printf format specifier issues in KUnit assertions Shuah Khan
2024-02-27 23:32 ` Shuah Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).