selftests: Add printf attribute to kselftest prints
authorMaciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
Fri, 13 Oct 2023 11:36:25 +0000 (13:36 +0200)
committerShuah Khan <skhan@linuxfoundation.org>
Fri, 13 Oct 2023 20:08:04 +0000 (14:08 -0600)
commite33a02ed6a4fbadfa7813831f1f52874c991d324
treedc90dea74ae96b4a15681cb7265d97fecf03988c
parent2531f374f922e77ba51f24d1aa6fa11c7f4c36b8
selftests: Add printf attribute to kselftest prints

Kselftest header defines multiple variadic functions that use printf
along with other logic.

There is no format checking for the variadic functions that use
printing inside kselftest.h. Because of this the compiler won't
be able to catch instances of mismatched printf formats and debugging
tests might be more difficult.

Add the common __printf() attribute macro to kselftest.h.

Add __printf() attribute to every function using formatted printing
with variadic arguments.

Adding the attribute and compiling all selftests exposes a number of
-Wformat warnings which were previously unnoticed due to a lack of
format specifiers checking by the compiler.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/kselftest.h