lockdep: Address clang -Wformat warning printing for %hd
authorArnd Bergmann <arnd@arndb.de>
Mon, 22 Mar 2021 11:55:25 +0000 (12:55 +0100)
committerIngo Molnar <mingo@kernel.org>
Mon, 22 Mar 2021 21:07:09 +0000 (22:07 +0100)
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

index c30eb887ca7d5c72c2457963e08966130fddae06..f160f1c97ca1ea39f48417ce937720b0d8ac2a39 100644 (file)
@@ -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);
 }