Skip to content

Add printf attribute to kselftest functions

Maciej Wieczor-Retman kvm linux-kselftest linux-mm lkml 6 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest8 patches 3 repliesIn review
  2. v58 patches 5 repliesSuperseded
  3. v48 patches 2 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v38 patches2 repliesSuperseded
v28 patches1 replySuperseded
v16 patches9 repliesSuperseded

Changes in v6 from the cover letter

- Add methodology notes to all patches.
- No functional changes in the patches.

Patches in v6 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8selftests: Add printf attribute to kselftest printstools/testing/selftests/kselftest.h+10 -80 replies
2/8selftests/cachestat: Fix print_cachestat formattools/testing/selftests/cachestat/test_cachestat.c+1 -10 replies
3/8selftests/openat2: Fix wrong format specifiertools/testing/selftests/openat2/openat2_test.c+1 -10 replies
4/8selftests/pidfd: Fix ksft print formatstools/testing/selftests/pidfd/pidfd_fdinfo_test.c tools/testing/selftests/pidfd/pidfd_test.c+7 -70 replies
5/8selftests/sigaltstack: Fix wrong format specifiertools/testing/selftests/sigaltstack/sas.c+1 -10 replies
6/8selftests/kvm: Replace attribute with macrotools/testing/selftests/kvm/include/test_util.h+4 -40 replies
7/8selftests/mm: Substitute attribute with a macrotools/testing/selftests/mm/mremap_test.c tools/testing/selftests/mm/pkey-helpers.h+2 -20 replies
8/8selftests/resctrl: Fix wrong format specifiertools/testing/selftests/resctrl/cache.c+1 -10 replies

Reviews trailers per patch

5 of 8 patches have a Reviewed-by or Acked-by.

PatchIlpo JärvinenReinette ChatreNhat Pham
1/8R-b R-b
2/8A-b
3/8R-b
4/8
5/8R-b
6/8
7/8
8/8R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v6 thread

Cover letter [PATCH v6 0/8] Add printf attribute to kselftest functions

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.

The first patch adds __printf() macro and applies it to all functions in kselftest.h that use printf format specifiers. After compiling all selftests using:
make -C tools/testing/selftests
many instances of format specifier mismatching are exposed in the form of -Wformat warnings.

Fix the mismatched format specifiers caught by __printf() attribute in multiple tests.

Series is based on kselftests next branch.

Changelog v6:
- Add methodology notes to all patches.
- No functional changes in the patches.

Changelog v5:
- Mention in the cover letter what methodology was used to find the mismatched format specifiers.
- No functional changes in the patches.

Changelog v4:
- Fix patch 1/8 subject typo.
- Add Reinette's reviewed-by tags.
- Rebase onto new kselftest/next patches.

Changelog v3:
- Changed git signature from Wieczor-Retman Maciej to Maciej Wieczor-Retman.
- Added one review tag.
- Rebased onto updated kselftests next branch.

Changelog v2:
- Add review and fixes tags to patches.
- Add two patches with mismatch fixes.
- Fix missed attribute in selftests/kvm. (Andrew)
- Fix previously missed issues in selftests/mm (Ilpo)

[v5] https://lore.kernel.org/all/[email protected]/
[v4] https://lore.kernel.org/all/[email protected]/
[v3] https://lore.kernel.org/all/[email protected]/
[v2] https://lore.kernel.org/all/[email protected]/
[v1] https://lore.kernel.org/all/[email protected]/

Maciej Wieczor-Retman (8):
selftests: Add printf attribute to kselftest 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/mm: Substitute attribute with a macro selftests/resctrl: Fix wrong format specifier

 .../selftests/cachestat/test_cachestat.c       |  2 +-
 tools/testing/selftests/kselftest.h            | 18 ++++++++++--------
 .../testing/selftests/kvm/include/test_util.h  |  8 ++++----
 tools/testing/selftests/mm/mremap_test.c       |  2 +-
 tools/testing/selftests/mm/pkey-helpers.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/resctrl/cache.c        |  2 +-
 tools/testing/selftests/sigaltstack/sas.c      |  2 +-
 10 files changed, 27 insertions(+), 25 deletions(-)

base-commit: 2531f374f922e77ba51f24d1aa6fa11c7f4c36b8

Signature · 1 line
2.42.0