All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>, Shuah Khan <shuah@kernel.org>
Cc: ilpo.jarvinen@linux.intel.com, kvm@vger.kernel.org,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v6 6/8] selftests/kvm: Replace attribute with macro
Date: Fri, 13 Oct 2023 13:36:30 +0200	[thread overview]
Message-ID: <e05d7b658c4685957152074d4090e8527da718e1.1697196663.git.maciej.wieczor-retman@intel.com> (raw)
In-Reply-To: <cover.1697196663.git.maciej.wieczor-retman@intel.com>

The __printf() macro is used in many tools in the linux kernel to
validate the format specifiers in functions that use printf. The kvm
selftest uses it without putting it in a macro definition while it
also imports the kselftests.h header where the macro attribute is
defined.

Use __printf() from kselftests.h instead of the full attribute.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
---
Changelog v6:
- Make the motivation behind the patch more explicit in the patch
  message.

Changelog v2:
- Reword patch message.
- Use __printf() on test_assert().

 tools/testing/selftests/kvm/include/test_util.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/kvm/include/test_util.h b/tools/testing/selftests/kvm/include/test_util.h
index 7e614adc6cf4..8e5f413a593d 100644
--- a/tools/testing/selftests/kvm/include/test_util.h
+++ b/tools/testing/selftests/kvm/include/test_util.h
@@ -33,7 +33,7 @@ static inline int _no_printf(const char *format, ...) { return 0; }
 #define pr_info(...) _no_printf(__VA_ARGS__)
 #endif
 
-void print_skip(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
+void __printf(1, 2) print_skip(const char *fmt, ...);
 #define __TEST_REQUIRE(f, fmt, ...)				\
 do {								\
 	if (!(f))						\
@@ -46,9 +46,9 @@ ssize_t test_write(int fd, const void *buf, size_t count);
 ssize_t test_read(int fd, void *buf, size_t count);
 int test_seq_read(const char *path, char **bufp, size_t *sizep);
 
-void test_assert(bool exp, const char *exp_str,
-		 const char *file, unsigned int line, const char *fmt, ...)
-		__attribute__((format(printf, 5, 6)));
+void __printf(5, 6) test_assert(bool exp, const char *exp_str,
+				const char *file, unsigned int line,
+				const char *fmt, ...);
 
 #define TEST_ASSERT(e, fmt, ...) \
 	test_assert((e), #e, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
-- 
2.42.0


  parent reply	other threads:[~2023-10-13 11:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-13 11:36 [PATCH v6 0/8] Add printf attribute to kselftest functions Maciej Wieczor-Retman
2023-10-13 11:36 ` [PATCH v6 1/8] selftests: Add printf attribute to kselftest prints Maciej Wieczor-Retman
2023-10-13 11:36 ` [PATCH v6 2/8] selftests/cachestat: Fix print_cachestat format Maciej Wieczor-Retman
2023-10-13 11:36 ` [PATCH v6 3/8] selftests/openat2: Fix wrong format specifier Maciej Wieczor-Retman
2023-10-13 11:36 ` [PATCH v6 4/8] selftests/pidfd: Fix ksft print formats Maciej Wieczor-Retman
2023-10-13 11:36 ` [PATCH v6 5/8] selftests/sigaltstack: Fix wrong format specifier Maciej Wieczor-Retman
2023-10-13 11:36 ` Maciej Wieczor-Retman [this message]
2023-10-13 11:36 ` [PATCH v6 7/8] selftests/mm: Substitute attribute with a macro Maciej Wieczor-Retman
2023-10-13 11:36 ` [PATCH v6 8/8] selftests/resctrl: Fix wrong format specifier Maciej Wieczor-Retman
2023-10-13 21:03 ` [PATCH v6 0/8] Add printf attribute to kselftest functions Shuah
2023-10-13 21:08   ` Reinette Chatre
2023-10-16  5:28   ` Maciej Wieczór-Retman

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=e05d7b658c4685957152074d4090e8527da718e1.1697196663.git.maciej.wieczor-retman@intel.com \
    --to=maciej.wieczor-retman@intel.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=shuah@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.