linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] Add printf attribute to kselftest functions
@ 2023-08-28 10:48 Wieczor-Retman, Maciej
  2023-08-28 10:49 ` [PATCH 2/6] selftests/cachestat: Fix print_cachestat format Wieczor-Retman, Maciej
  0 siblings, 1 reply; 4+ messages in thread
From: Wieczor-Retman, Maciej @ 2023-08-28 10:48 UTC (permalink / raw)
  To: linux-kernel, Christian Brauner
  Cc: kvm, linux-kselftest, linux-mm, keescook, ndesaulniers,
	coltonlewis, dmatlack, vipinsh, seanjc, pbonzini, shuah, hannes,
	nphamcs, reinette.chatre, ilpo.jarvinen, Wieczor-Retman, Maciej

Kselftest.h declares many variadic functions that can print some
formatted message while also executing selftest logic. These
declarations don't have any compiler mechanism to verify if passed
arguments are valid in comparison with format specifiers used in
printf() calls.

Attribute addition can make debugging easier, the code more consistent
and prevent mismatched or missing variables.

Add a __printf() macro that validates types of variables passed to the
format string. The macro is similiarly used in other tools in the kernel.

Add __printf() attributes to function definitions inside kselftest.h that
use printing.

Adding the __printf() macro exposes some mismatches in format strings
across different selftests.

Fix the mismatched format specifiers in multiple tests.

Wieczor-Retman, Maciej (6):
  selftests: Add printf attribute to ksefltest prints
  selftests/cachestat: Fix print_cachestat format
  selftests/openat2: Fix wrong format specifier
  selftests/pidfd: Fix ksft print formats
  selftests/sigaltstack: Fix wrong format specifier
  selftests/kvm: Replace attribute with macro

 .../selftests/cachestat/test_cachestat.c       |  2 +-
 tools/testing/selftests/kselftest.h            | 18 ++++++++++--------
 .../testing/selftests/kvm/include/test_util.h  |  2 +-
 tools/testing/selftests/openat2/openat2_test.c |  2 +-
 .../selftests/pidfd/pidfd_fdinfo_test.c        |  2 +-
 tools/testing/selftests/pidfd/pidfd_test.c     | 12 ++++++------
 tools/testing/selftests/sigaltstack/sas.c      |  2 +-
 7 files changed, 21 insertions(+), 19 deletions(-)


base-commit: 13eb52f6293dbda02890698d92f3d9913d8d5aeb
-- 
2.42.0



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

end of thread, other threads:[~2023-08-28 14:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-28 10:48 [PATCH 0/6] Add printf attribute to kselftest functions Wieczor-Retman, Maciej
2023-08-28 10:49 ` [PATCH 2/6] selftests/cachestat: Fix print_cachestat format Wieczor-Retman, Maciej
2023-08-28 14:00   ` Nhat Pham
2023-08-28 14:04     ` Nhat Pham

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).