[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAKwvOdmNUkS0Hh_9-kvcDoK-UTUOV8hXsQx-R2o_T02fxMhFLQ@mail.gmail.com>
Date: Mon, 29 Mar 2021 11:25:19 -0700
From: Nick Desaulniers <ndesaulniers@...gle.com>
To: Arnd Bergmann <arnd@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>, Will Deacon <will@...nel.org>,
Nathan Chancellor <nathan@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Arnd Bergmann <arnd@...db.de>,
Waiman Long <longman@...hat.com>,
Boqun Feng <boqun.feng@...il.com>,
"Steven Rostedt (VMware)" <rostedt@...dmis.org>,
LKML <linux-kernel@...r.kernel.org>,
clang-built-linux <clang-built-linux@...glegroups.com>
Subject: Re: [PATCH] lockdep: address clang -Wformat warning printing for %hd
On Mon, Mar 22, 2021 at 4:55 AM Arnd Bergmann <arnd@...nel.org> wrote:
>
> From: Arnd Bergmann <arnd@...db.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@...gle.com>
>
> Fixes: de8f5e4f2dc1 ("lockdep: Introduce wait-type checks")
> Signed-off-by: Arnd Bergmann <arnd@...db.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
Powered by blists - more mailing lists