Skip to contentSkip to conversation

kcsan: fix printk format string

PATCH Applied Arnd Bergmann 4 participants 4 messages Apr 21, 2021 – Apr 23, 2021 KCSAN

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kcsan: fix printk format string

From: Arnd Bergmann <[email protected]>

Printing a 'long' variable using the '%d' format string is wrong and causes a warning from gcc:

kernel/kcsan/kcsan_test.c: In function 'nthreads_gen_params':
include/linux/kern_levels.h:5:25: error: format '%d' expects argument of type 'int', but argument 3 has type 'long int' [-Werror=format=]

Use the appropriate format modifier.

Fixes f6a149140321 ("kcsan: Switch to KUNIT_CASE_PARAM for parameterized tests")
---
 kernel/kcsan/kcsan_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/kcsan/kcsan_test.c +1 -1
index 9247009295b5..a29e9b1a30c8 100644
@@ -981,7 +981,7 @@ static const void *nthreads_gen_params(const void *prev, char *desc)
 		const long min_required_cpus = 2 + min_unused_cpus;
 
 		if (num_online_cpus() < min_required_cpus) {
-			pr_err_once("Too few online CPUs (%u < %d) for test\n",
+			pr_err_once("Too few online CPUs (%u < %ld) for test\n",
 				    num_online_cpus(), min_required_cpus);
 			nthreads = 0;
 		} else if (nthreads >= num_online_cpus() - min_unused_cpus) {
Signature · 1 line
2.29.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Printing a 'long' variable using the '%d' format string is wrong and causes a warning from gcc:

Quoted 7 lines

kernel/kcsan/kcsan_test.c: In function 'nthreads_gen_params':
include/linux/kern_levels.h:5:25: error: format '%d' expects argument of type 'int', but argument 3 has type 'long int' [-Werror=format=]

Use the appropriate format modifier.

Fixes f6a149140321 ("kcsan: Switch to KUNIT_CASE_PARAM for parameterized tests")

Thank you!

Normally KCSAN patches go through -rcu, but perhaps in this instance it should be picked up into -tip/locking/core directly, so it goes out with "kcsan: Switch to KUNIT_CASE_PARAM for parameterized tests". Paul, Ingo, do you have a preference?

Thanks,
-- Marco

Quoted 19 lines
---
 kernel/kcsan/kcsan_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/kcsan/kcsan_test.c +1 -2
index 9247009295b5..a29e9b1a30c8 100644
@@ -981,7 +981,7 @@ static const void *nthreads_gen_params(const void *prev, char *desc)
                const long min_required_cpus = 2 + min_unused_cpus;
 
                if (num_online_cpus() < min_required_cpus) {
-                       pr_err_once("Too few online CPUs (%u < %d) for test\n",
+                       pr_err_once("Too few online CPUs (%u < %ld) for test\n",
                                    num_online_cpus(), min_required_cpus);
                        nthreads = 0;
                } else if (nthreads >= num_online_cpus() - min_unused_cpus) {
--

2.29.2

#2 lore raw
Quoted 14 lines · Marco Elver
Quoted 5 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Printing a 'long' variable using the '%d' format string is wrong and causes a warning from gcc:

Quoted 7 lines

kernel/kcsan/kcsan_test.c: In function 'nthreads_gen_params':
include/linux/kern_levels.h:5:25: error: format '%d' expects argument of type 'int', but argument 3 has type 'long int' [-Werror=format=]

Use the appropriate format modifier.

Fixes f6a149140321 ("kcsan: Switch to KUNIT_CASE_PARAM for parameterized tests")
Quoted 8 lines

Thank you!

Normally KCSAN patches go through -rcu, but perhaps in this instance it should be picked up into -tip/locking/core directly, so it goes out with "kcsan: Switch to KUNIT_CASE_PARAM for parameterized tests". Paul, Ingo, do you have a preference?

I am good either way. I have queued it for the moment, but will remove it if Ingo takes it.

Quoted 22 lines

Thanks,
-- Marco

Quoted 19 lines
---
 kernel/kcsan/kcsan_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/kcsan/kcsan_test.c +1 -2
index 9247009295b5..a29e9b1a30c8 100644
@@ -981,7 +981,7 @@ static const void *nthreads_gen_params(const void *prev, char *desc)
                const long min_required_cpus = 2 + min_unused_cpus;
 
                if (num_online_cpus() < min_required_cpus) {
-                       pr_err_once("Too few online CPUs (%u < %d) for test\n",
+                       pr_err_once("Too few online CPUs (%u < %ld) for test\n",
                                    num_online_cpus(), min_required_cpus);
                        nthreads = 0;
                } else if (nthreads >= num_online_cpus() - min_unused_cpus) {
--

2.29.2

merge bot Applied
#3 lore raw

[tip: locking/core] kcsan: Fix printk format string

In reply to Arnd Bergmann
The following commit has been merged into the locking/core branch of tip:

The following commit has been merged into the locking/core branch of tip:

Commit-ID:     f4abe9967c6fdb511ee567e129a014b60945ab93
Gitweb:        https://git.kernel.org/tip/f4abe9967c6fdb511ee567e129a014b60945ab93
Author:        Arnd Bergmann <[email protected]>
AuthorDate:    Wed, 21 Apr 2021 15:50:38 +02:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Thu, 22 Apr 2021 14:36:03 +02:00

kcsan: Fix printk format string

Printing a 'long' variable using the '%d' format string is wrong and causes a warning from gcc:

kernel/kcsan/kcsan_test.c: In function 'nthreads_gen_params':
include/linux/kern_levels.h:5:25: error: format '%d' expects argument of type 'int', but argument 3 has type 'long int' [-Werror=format=]

Use the appropriate format modifier.

Fixes f6a149140321 ("kcsan: Switch to KUNIT_CASE_PARAM for parameterized tests")
---
 kernel/kcsan/kcsan_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/kcsan/kcsan_test.c +1 -1
index b71751f..8bcffbd 100644
@@ -984,7 +984,7 @@ static const void *nthreads_gen_params(const void *prev, char *desc)
 		const long min_required_cpus = 2 + min_unused_cpus;
 
 		if (num_online_cpus() < min_required_cpus) {
-			pr_err_once("Too few online CPUs (%u < %d) for test\n",
+			pr_err_once("Too few online CPUs (%u < %ld) for test\n",
 				    num_online_cpus(), min_required_cpus);
 			nthreads = 0;
 		} else if (nthreads >= num_online_cpus() - min_unused_cpus) {