diff mbox series

[6/6] selftests/kvm: Replace attribute with macro

Message ID 82ed62dd7070203701b4ca326e62862404dd5f72.1693216959.git.maciej.wieczor-retman@intel.com (mailing list archive)
State New
Headers show
Series Add printf attribute to kselftest functions | expand

Commit Message

Maciej Wieczor-Retman Aug. 28, 2023, 10:49 a.m. UTC
The __printf() macro is used in many tools in the linux kernel to
validate the format specifiers in functions that use printf. Some
selftests use it without putting it in a macro definition and some tests
import the kselftests.h header.

Use __printf() attribute instead of the full attribute since the macro
is inside kselftests.h and the header is already imported.

Signed-off-by: Wieczor-Retman, Maciej <maciej.wieczor-retman@intel.com>
---
 tools/testing/selftests/kvm/include/test_util.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ilpo Järvinen Aug. 30, 2023, 12:22 p.m. UTC | #1
On Mon, 28 Aug 2023, Wieczor-Retman, Maciej wrote:

> The __printf() macro is used in many tools in the linux kernel to
> validate the format specifiers in functions that use printf. Some
> selftests use it without putting it in a macro definition and some tests
> import the kselftests.h header.

"Some" and yet this only converts one? Please be more precise in the 
wording.

> Use __printf() attribute instead of the full attribute since the macro
> is inside kselftests.h and the header is already imported.

IMO, this would be enough:

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

Was there a reason why you didn't convert mm/pkey-helpers.h one?
Maciej Wieczor-Retman Aug. 30, 2023, 1:40 p.m. UTC | #2
On 2023-08-30 at 15:22:57 +0300, Ilpo Järvinen wrote:
>On Mon, 28 Aug 2023, Wieczor-Retman, Maciej wrote:
>
>> The __printf() macro is used in many tools in the linux kernel to
>> validate the format specifiers in functions that use printf. Some
>> selftests use it without putting it in a macro definition and some tests
>> import the kselftests.h header.
>
>"Some" and yet this only converts one? Please be more precise in the 
>wording.

Okay, I'll mention them by subsystem.

>> Use __printf() attribute instead of the full attribute since the macro
>> is inside kselftests.h and the header is already imported.
>
>IMO, this would be enough:
>
>Use __printf() from kselftests.h instead of the full attribute.

Fair enough, I'll change the paragraph to that.

>Was there a reason why you didn't convert mm/pkey-helpers.h one?

Sorry, must have just missed it somehow. Thank you for pointing it out.
Andrew Jones Aug. 31, 2023, 2:33 p.m. UTC | #3
On Wed, Aug 30, 2023 at 03:40:10PM +0200, Maciej Wieczór-Retman wrote:
> On 2023-08-30 at 15:22:57 +0300, Ilpo Järvinen wrote:
> >On Mon, 28 Aug 2023, Wieczor-Retman, Maciej wrote:
> >
> >> The __printf() macro is used in many tools in the linux kernel to
> >> validate the format specifiers in functions that use printf. Some
> >> selftests use it without putting it in a macro definition and some tests
> >> import the kselftests.h header.
> >
> >"Some" and yet this only converts one? Please be more precise in the 
> >wording.
> 
> Okay, I'll mention them by subsystem.
> 
> >> Use __printf() attribute instead of the full attribute since the macro
> >> is inside kselftests.h and the header is already imported.
> >
> >IMO, this would be enough:
> >
> >Use __printf() from kselftests.h instead of the full attribute.
> 
> Fair enough, I'll change the paragraph to that.

There are two in kvm selftests. test_assert(), a few lines down, also uses
the attribute.

Thanks,
drew

> 
> >Was there a reason why you didn't convert mm/pkey-helpers.h one?
> 
> Sorry, must have just missed it somehow. Thank you for pointing it out.
> 
> -- 
> Kind regards
> Maciej Wieczór-Retman
diff mbox series

Patch

diff --git a/tools/testing/selftests/kvm/include/test_util.h b/tools/testing/selftests/kvm/include/test_util.h
index a6e9f215ce70..710a8a78e8ce 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))						\