lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-ID: <da17617717c5f6a79f58cdf4a56cd39e28c53377.camel@perches.com> Date: Thu, 07 Jul 2022 11:01:26 -0700 From: Joe Perches <joe@...ches.com> To: Justin Stitt <justinstitt@...gle.com> Cc: Steffen Klassert <steffen.klassert@...unet.com>, Herbert Xu <herbert@...dor.apana.org.au>, "David S . Miller" <davem@...emloft.net>, Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>, David Ahern <dsahern@...nel.org>, Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, Nathan Chancellor <nathan@...nel.org>, Nick Desaulniers <ndesaulniers@...gle.com>, Tom Rix <trix@...hat.com>, netdev@...r.kernel.org, linux-kernel@...r.kernel.org, llvm@...ts.linux.dev Subject: Re: [PATCH] net: ipv4: fix clang -Wformat warning On Thu, 2022-07-07 at 10:47 -0700, Justin Stitt wrote: > On Thu, Jul 7, 2022 at 10:40 AM Joe Perches <joe@...ches.com> wrote: > > > > On Thu, 2022-07-07 at 10:30 -0700, Justin Stitt wrote: > > > When building with Clang we encounter this warning: > > > > net/ipv4/ah4.c:513:4: error: format specifies type 'unsigned short' but > > > > the argument has type 'int' [-Werror,-Wformat] > > > > aalg_desc->uinfo.auth.icv_fullbits / 8); > > > > > > `aalg_desc->uinfo.auth.icv_fullbits` is a u16 but due to default > > > argument promotion becomes an int. > > > > > > Variadic functions (printf-like) undergo default argument promotion. > > > Documentation/core-api/printk-formats.rst specifically recommends using > > > the promoted-to-type's format flag. > > > > > > As per C11 6.3.1.1: > > > (https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf) `If an int > > > can represent all values of the original type ..., the value is > > > converted to an int; otherwise, it is converted to an unsigned int. > > > These are called the integer promotions.` Thus it makes sense to change > > > %hu to %d not only to follow this standard but to suppress the warning > > > as well. > > > > I think it also makes sense to use %u and not %d > > as the original type is unsigned. > Yeah, that would also work. An integer (even a signed one) fully > encompasses a u16 so it's really a choice of style. Do you think the > change to %u warrants a v2 of this patch? As it's rather odd output to use '%u != %d', probably. Your patch, up to you. > > > > > diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c > > [] > > > @@ -507,7 +507,7 @@ static int ah_init_state(struct xfrm_state *x) > > > > > > if (aalg_desc->uinfo.auth.icv_fullbits/8 != > > > crypto_ahash_digestsize(ahash)) { > > > - pr_info("%s: %s digestsize %u != %hu\n", > > > + pr_info("%s: %s digestsize %u != %d\n", > > > __func__, x->aalg->alg_name, > > > crypto_ahash_digestsize(ahash), > > > aalg_desc->uinfo.auth.icv_fullbits / 8); > >
Powered by blists - more mailing lists