linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lockdep: address clang -Wformat warning printing for %hd
@ 2021-03-22 11:55 Arnd Bergmann
  2021-03-22 21:11 ` [tip: perf/urgent] lockdep: Address " tip-bot2 for Arnd Bergmann
  2021-03-29 18:25 ` [PATCH] lockdep: address " Nick Desaulniers
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2021-03-22 11:55 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Will Deacon, Nathan Chancellor,
	Nick Desaulniers, Thomas Gleixner, Sebastian Andrzej Siewior
  Cc: Arnd Bergmann, Waiman Long, Boqun Feng, Steven Rostedt (VMware),
	linux-kernel, clang-built-linux

From: Arnd Bergmann <arnd@arndb.de>

Clang doesn't like format strings that truncate a 32-bit
value to something shorter:

kernel/locking/lockdep.c:709:4: error: format specifies type 'short' but the argument has type 'int' [-Werror,-Wformat]

In this case, the warning is a slightly questionable, as it could realize
that both class->wait_type_outer and class->wait_type_inner are in fact
8-bit struct members, even though the result of the ?: operator becomes an
'int'.

However, there is really no point in printing the number as a 16-bit
'short' rather than either an 8-bit or 32-bit number, so just change
it to a normal %d.

Fixes: de8f5e4f2dc1 ("lockdep: Introduce wait-type checks")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 kernel/locking/lockdep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 70bf3e48eae3..bb3b0bc6ee17 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -705,7 +705,7 @@ static void print_lock_name(struct lock_class *class)
 
 	printk(KERN_CONT " (");
 	__print_lock_name(class);
-	printk(KERN_CONT "){%s}-{%hd:%hd}", usage,
+	printk(KERN_CONT "){%s}-{%d:%d}", usage,
 			class->wait_type_outer ?: class->wait_type_inner,
 			class->wait_type_inner);
 }
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [tip: perf/urgent] lockdep: Address clang -Wformat warning printing for %hd
  2021-03-22 11:55 [PATCH] lockdep: address clang -Wformat warning printing for %hd Arnd Bergmann
@ 2021-03-22 21:11 ` tip-bot2 for Arnd Bergmann
  2021-03-29 18:25 ` [PATCH] lockdep: address " Nick Desaulniers
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Arnd Bergmann @ 2021-03-22 21:11 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Arnd Bergmann, Ingo Molnar, x86, linux-kernel

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     6d48b7912cc72275dc7c59ff961c8bac7ef66a92
Gitweb:        https://git.kernel.org/tip/6d48b7912cc72275dc7c59ff961c8bac7ef66a92
Author:        Arnd Bergmann <arnd@arndb.de>
AuthorDate:    Mon, 22 Mar 2021 12:55:25 +01:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Mon, 22 Mar 2021 22:07:09 +01:00

lockdep: Address clang -Wformat warning printing for %hd

Clang doesn't like format strings that truncate a 32-bit
value to something shorter:

  kernel/locking/lockdep.c:709:4: error: format specifies type 'short' but the argument has type 'int' [-Werror,-Wformat]

In this case, the warning is a slightly questionable, as it could realize
that both class->wait_type_outer and class->wait_type_inner are in fact
8-bit struct members, even though the result of the ?: operator becomes an
'int'.

However, there is really no point in printing the number as a 16-bit
'short' rather than either an 8-bit or 32-bit number, so just change
it to a normal %d.

Fixes: de8f5e4f2dc1 ("lockdep: Introduce wait-type checks")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20210322115531.3987555-1-arnd@kernel.org
---
 kernel/locking/lockdep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index c30eb88..f160f1c 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -705,7 +705,7 @@ static void print_lock_name(struct lock_class *class)
 
 	printk(KERN_CONT " (");
 	__print_lock_name(class);
-	printk(KERN_CONT "){%s}-{%hd:%hd}", usage,
+	printk(KERN_CONT "){%s}-{%d:%d}", usage,
 			class->wait_type_outer ?: class->wait_type_inner,
 			class->wait_type_inner);
 }

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] lockdep: address clang -Wformat warning printing for %hd
  2021-03-22 11:55 [PATCH] lockdep: address clang -Wformat warning printing for %hd Arnd Bergmann
  2021-03-22 21:11 ` [tip: perf/urgent] lockdep: Address " tip-bot2 for Arnd Bergmann
@ 2021-03-29 18:25 ` Nick Desaulniers
  1 sibling, 0 replies; 3+ messages in thread
From: Nick Desaulniers @ 2021-03-29 18:25 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, Nathan Chancellor,
	Thomas Gleixner, Sebastian Andrzej Siewior, Arnd Bergmann,
	Waiman Long, Boqun Feng, Steven Rostedt (VMware),
	LKML, clang-built-linux

On Mon, Mar 22, 2021 at 4:55 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> Clang doesn't like format strings that truncate a 32-bit
> value to something shorter:
>
> kernel/locking/lockdep.c:709:4: error: format specifies type 'short' but the argument has type 'int' [-Werror,-Wformat]
>
> In this case, the warning is a slightly questionable, as it could realize
> that both class->wait_type_outer and class->wait_type_inner are in fact
> 8-bit struct members, even though the result of the ?: operator becomes an
> 'int'.
>
> However, there is really no point in printing the number as a 16-bit
> 'short' rather than either an 8-bit or 32-bit number, so just change
> it to a normal %d.

Thanks for the patch!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

>
> Fixes: de8f5e4f2dc1 ("lockdep: Introduce wait-type checks")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  kernel/locking/lockdep.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 70bf3e48eae3..bb3b0bc6ee17 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -705,7 +705,7 @@ static void print_lock_name(struct lock_class *class)
>
>         printk(KERN_CONT " (");
>         __print_lock_name(class);
> -       printk(KERN_CONT "){%s}-{%hd:%hd}", usage,
> +       printk(KERN_CONT "){%s}-{%d:%d}", usage,
>                         class->wait_type_outer ?: class->wait_type_inner,
>                         class->wait_type_inner);
>  }
> --
> 2.29.2
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-29 18:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-22 11:55 [PATCH] lockdep: address clang -Wformat warning printing for %hd Arnd Bergmann
2021-03-22 21:11 ` [tip: perf/urgent] lockdep: Address " tip-bot2 for Arnd Bergmann
2021-03-29 18:25 ` [PATCH] lockdep: address " Nick Desaulniers

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).