Re: [PATCH v2] net: rxrpc: fix clang -Wformat warning

From: David Howells
Date: Fri Jul 08 2022 - 05:39:16 EST


Justin Stitt <justinstitt@xxxxxxxxxx> wrote:

> y is a u32 but the format specifier is `%hx`. Going from unsigned int to
> short int results in a loss of data. This is surely not intended
> behavior. If it is intended, the warning should be suppressed through
> other means.

Yeah, y is reduced to a 16-bit number so that it can be used in the protocol,
but the type is still 32-bit because that's needed for the calculation. An
alternative would be to print sp->hdr.cksum since that's the value that will
appear on the wire, but I've no objection to this change either.

> This patch should get us closer to the goal of enabling the -Wformat
> flag for Clang builds.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/378
> Signed-off-by: Justin Stitt <justinstitt@xxxxxxxxxx>

Acked-by: David Howells <dhowells@xxxxxxxxxx>