* [PATCH net-next] ipv6: fix clang Wformat warning
@ 2021-03-22 11:56 Arnd Bergmann
2021-03-26 10:28 ` Steffen Klassert
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2021-03-22 11:56 UTC (permalink / raw)
To: netdev, Steffen Klassert, Herbert Xu, David S. Miller,
Hideaki YOSHIFUJI, David Ahern, Jakub Kicinski
Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers,
Zhang Changzhong, Sabrina Dubroca, Willem de Bruijn,
Jiapeng Chong, linux-kernel, clang-built-linux
From: Arnd Bergmann <arnd@arndb.de>
When building with 'make W=1', clang warns about a mismatched
format string:
net/ipv6/ah6.c:710:4: error: format specifies type 'unsigned short' but the argument has type 'int' [-Werror,-Wformat]
aalg_desc->uinfo.auth.icv_fullbits/8);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/printk.h:375:34: note: expanded from macro 'pr_info'
printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
~~~ ^~~~~~~~~~~
net/ipv6/esp6.c:1153:5: error: format specifies type 'unsigned short' but the argument has type 'int' [-Werror,-Wformat]
aalg_desc->uinfo.auth.icv_fullbits / 8);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/printk.h:375:34: note: expanded from macro 'pr_info'
printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
~~~ ^~~~~~~~~~~
Here, the result of dividing a 16-bit number by a 32-bit number
produces a 32-bit result, which is printed as a 16-bit integer.
Change the %hu format to the normal %u, which has the same effect
but avoids the warning.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
net/ipv6/ah6.c | 2 +-
net/ipv6/esp6.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c
index 440080da805b..01c638f5d8b8 100644
--- a/net/ipv6/ah6.c
+++ b/net/ipv6/ah6.c
@@ -705,7 +705,7 @@ static int ah6_init_state(struct xfrm_state *x)
if (aalg_desc->uinfo.auth.icv_fullbits/8 !=
crypto_ahash_digestsize(ahash)) {
- pr_info("AH: %s digestsize %u != %hu\n",
+ pr_info("AH: %s digestsize %u != %u\n",
x->aalg->alg_name, crypto_ahash_digestsize(ahash),
aalg_desc->uinfo.auth.icv_fullbits/8);
goto error;
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 153ad103ba74..831a588b04a2 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -1147,7 +1147,7 @@ static int esp_init_authenc(struct xfrm_state *x)
err = -EINVAL;
if (aalg_desc->uinfo.auth.icv_fullbits / 8 !=
crypto_aead_authsize(aead)) {
- pr_info("ESP: %s digestsize %u != %hu\n",
+ pr_info("ESP: %s digestsize %u != %u\n",
x->aalg->alg_name,
crypto_aead_authsize(aead),
aalg_desc->uinfo.auth.icv_fullbits / 8);
--
2.29.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] ipv6: fix clang Wformat warning
2021-03-22 11:56 [PATCH net-next] ipv6: fix clang Wformat warning Arnd Bergmann
@ 2021-03-26 10:28 ` Steffen Klassert
0 siblings, 0 replies; 2+ messages in thread
From: Steffen Klassert @ 2021-03-26 10:28 UTC (permalink / raw)
To: Arnd Bergmann
Cc: netdev, Herbert Xu, David S. Miller, Hideaki YOSHIFUJI,
David Ahern, Jakub Kicinski, Arnd Bergmann, Nathan Chancellor,
Nick Desaulniers, Zhang Changzhong, Sabrina Dubroca,
Willem de Bruijn, Jiapeng Chong, linux-kernel, clang-built-linux
On Mon, Mar 22, 2021 at 12:56:49PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> When building with 'make W=1', clang warns about a mismatched
> format string:
>
> net/ipv6/ah6.c:710:4: error: format specifies type 'unsigned short' but the argument has type 'int' [-Werror,-Wformat]
> aalg_desc->uinfo.auth.icv_fullbits/8);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> include/linux/printk.h:375:34: note: expanded from macro 'pr_info'
> printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
> ~~~ ^~~~~~~~~~~
> net/ipv6/esp6.c:1153:5: error: format specifies type 'unsigned short' but the argument has type 'int' [-Werror,-Wformat]
> aalg_desc->uinfo.auth.icv_fullbits / 8);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> include/linux/printk.h:375:34: note: expanded from macro 'pr_info'
> printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
> ~~~ ^~~~~~~~~~~
>
> Here, the result of dividing a 16-bit number by a 32-bit number
> produces a 32-bit result, which is printed as a 16-bit integer.
>
> Change the %hu format to the normal %u, which has the same effect
> but avoids the warning.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Applied to ipsec-next, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-26 10:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-22 11:56 [PATCH net-next] ipv6: fix clang Wformat warning Arnd Bergmann
2021-03-26 10:28 ` Steffen Klassert
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).