linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Wieczor-Retman, Maciej" <maciej.wieczor-retman@intel.com>
To: linux-kernel@vger.kernel.org, Christian Brauner <brauner@kernel.org>
Cc: kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-mm@kvack.org, keescook@chromium.org,
	ndesaulniers@google.com, coltonlewis@google.com,
	dmatlack@google.com, vipinsh@google.com, seanjc@google.com,
	pbonzini@redhat.com, shuah@kernel.org, hannes@cmpxchg.org,
	nphamcs@gmail.com, reinette.chatre@intel.com,
	ilpo.jarvinen@linux.intel.com, "Wieczor-Retman,
	Maciej" <maciej.wieczor-retman@intel.com>
Subject: [PATCH 0/6] Add printf attribute to kselftest functions
Date: Mon, 28 Aug 2023 12:48:24 +0200	[thread overview]
Message-ID: <cover.1693216959.git.maciej.wieczor-retman@intel.com> (raw)

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



             reply	other threads:[~2023-08-28 10:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-28 10:48 Wieczor-Retman, Maciej [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1693216959.git.maciej.wieczor-retman@intel.com \
    --to=maciej.wieczor-retman@intel.com \
    --cc=brauner@kernel.org \
    --cc=coltonlewis@google.com \
    --cc=dmatlack@google.com \
    --cc=hannes@cmpxchg.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=keescook@chromium.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ndesaulniers@google.com \
    --cc=nphamcs@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=reinette.chatre@intel.com \
    --cc=seanjc@google.com \
    --cc=shuah@kernel.org \
    --cc=vipinsh@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).