All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: rxrpc: fix clang -Wformat warning
@ 2022-07-06 23:56 Justin Stitt
  2022-07-07 17:58 ` Nathan Chancellor
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Justin Stitt @ 2022-07-06 23:56 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: David Howells, Marc Dionne, Nathan Chancellor, Nick Desaulniers,
	Tom Rix, linux-afs, netdev, linux-kernel, llvm, Justin Stitt

When building with Clang we encounter this warning:
| net/rxrpc/rxkad.c:434:33: error: format specifies type 'unsigned short'
| but the argument has type 'u32' (aka 'unsigned int') [-Werror,-Wformat]
| _leave(" = %d [set %hx]", ret, y);

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.

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@google.com>
---
 net/rxrpc/rxkad.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
index 08aab5c01437..aa180464ec37 100644
--- a/net/rxrpc/rxkad.c
+++ b/net/rxrpc/rxkad.c
@@ -431,7 +431,7 @@ static int rxkad_secure_packet(struct rxrpc_call *call,
 		break;
 	}
 
-	_leave(" = %d [set %hx]", ret, y);
+	_leave(" = %d [set %u]", ret, y);
 	return ret;
 }
 
-- 
2.37.0.rc0.161.g10f37bed90-goog


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] net: rxrpc: fix clang -Wformat warning
  2022-07-06 23:56 [PATCH] net: rxrpc: fix clang -Wformat warning Justin Stitt
@ 2022-07-07 17:58 ` Nathan Chancellor
  2022-07-07 18:20 ` [PATCH v2] " Justin Stitt
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Nathan Chancellor @ 2022-07-07 17:58 UTC (permalink / raw)
  To: Justin Stitt
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	David Howells, Marc Dionne, Nick Desaulniers, Tom Rix, linux-afs,
	netdev, linux-kernel, llvm

Hi Justin,

On Wed, Jul 06, 2022 at 04:56:48PM -0700, Justin Stitt wrote:
> When building with Clang we encounter this warning:
> | net/rxrpc/rxkad.c:434:33: error: format specifies type 'unsigned short'
> | but the argument has type 'u32' (aka 'unsigned int') [-Werror,-Wformat]
> | _leave(" = %d [set %hx]", ret, y);
> 
> 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.
> 
> 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@google.com>
> ---
>  net/rxrpc/rxkad.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
> index 08aab5c01437..aa180464ec37 100644
> --- a/net/rxrpc/rxkad.c
> +++ b/net/rxrpc/rxkad.c
> @@ -431,7 +431,7 @@ static int rxkad_secure_packet(struct rxrpc_call *call,
>  		break;
>  	}
>  
> -	_leave(" = %d [set %hx]", ret, y);
> +	_leave(" = %d [set %u]", ret, y);

Should this just become %x to keep printing it as a hexidecimal number?

Cheers,
Nathan

>  	return ret;
>  }
>  
> -- 
> 2.37.0.rc0.161.g10f37bed90-goog
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2] net: rxrpc: fix clang -Wformat warning
  2022-07-06 23:56 [PATCH] net: rxrpc: fix clang -Wformat warning Justin Stitt
  2022-07-07 17:58 ` Nathan Chancellor
@ 2022-07-07 18:20 ` Justin Stitt
  2022-07-07 18:24   ` Nathan Chancellor
  2022-07-09  3:20   ` patchwork-bot+netdevbpf
  2022-07-07 23:10 ` [PATCH] " Joe Perches
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 9+ messages in thread
From: Justin Stitt @ 2022-07-07 18:20 UTC (permalink / raw)
  To: justinstitt
  Cc: davem, dhowells, edumazet, kuba, linux-afs, linux-kernel, llvm,
	marc.dionne, nathan, ndesaulniers, netdev, pabeni, trix

When building with Clang we encounter this warning:
| net/rxrpc/rxkad.c:434:33: error: format specifies type 'unsigned short'
| but the argument has type 'u32' (aka 'unsigned int') [-Werror,-Wformat]
| _leave(" = %d [set %hx]", ret, y);

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.

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@google.com>
---
diff from v1 -> v2: 
* Change format specifier from %u to %x to properly represent hexadecimal.

 net/rxrpc/rxkad.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
index 08aab5c01437..258917a714c8 100644
--- a/net/rxrpc/rxkad.c
+++ b/net/rxrpc/rxkad.c
@@ -431,7 +431,7 @@ static int rxkad_secure_packet(struct rxrpc_call *call,
 		break;
 	}
 
-	_leave(" = %d [set %hx]", ret, y);
+	_leave(" = %d [set %x]", ret, y);
 	return ret;
 }
 
-- 
2.37.0.rc0.161.g10f37bed90-goog


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] net: rxrpc: fix clang -Wformat warning
  2022-07-07 18:20 ` [PATCH v2] " Justin Stitt
@ 2022-07-07 18:24   ` Nathan Chancellor
  2022-07-09  3:20   ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 9+ messages in thread
From: Nathan Chancellor @ 2022-07-07 18:24 UTC (permalink / raw)
  To: Justin Stitt
  Cc: davem, dhowells, edumazet, kuba, linux-afs, linux-kernel, llvm,
	marc.dionne, ndesaulniers, netdev, pabeni, trix

On Thu, Jul 07, 2022 at 11:20:52AM -0700, Justin Stitt wrote:
> When building with Clang we encounter this warning:
> | net/rxrpc/rxkad.c:434:33: error: format specifies type 'unsigned short'
> | but the argument has type 'u32' (aka 'unsigned int') [-Werror,-Wformat]
> | _leave(" = %d [set %hx]", ret, y);
> 
> 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.
> 
> 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@google.com>

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
> diff from v1 -> v2: 
> * Change format specifier from %u to %x to properly represent hexadecimal.
> 
>  net/rxrpc/rxkad.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
> index 08aab5c01437..258917a714c8 100644
> --- a/net/rxrpc/rxkad.c
> +++ b/net/rxrpc/rxkad.c
> @@ -431,7 +431,7 @@ static int rxkad_secure_packet(struct rxrpc_call *call,
>  		break;
>  	}
>  
> -	_leave(" = %d [set %hx]", ret, y);
> +	_leave(" = %d [set %x]", ret, y);
>  	return ret;
>  }
>  
> -- 
> 2.37.0.rc0.161.g10f37bed90-goog
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] net: rxrpc: fix clang -Wformat warning
  2022-07-06 23:56 [PATCH] net: rxrpc: fix clang -Wformat warning Justin Stitt
  2022-07-07 17:58 ` Nathan Chancellor
  2022-07-07 18:20 ` [PATCH v2] " Justin Stitt
@ 2022-07-07 23:10 ` Joe Perches
  2022-07-08  9:39 ` [PATCH v2] " David Howells
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Joe Perches @ 2022-07-07 23:10 UTC (permalink / raw)
  To: Justin Stitt, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni
  Cc: David Howells, Marc Dionne, Nathan Chancellor, Nick Desaulniers,
	Tom Rix, linux-afs, netdev, linux-kernel, llvm

On Wed, 2022-07-06 at 16:56 -0700, Justin Stitt wrote:
> When building with Clang we encounter this warning:
> > net/rxrpc/rxkad.c:434:33: error: format specifies type 'unsigned short'
> > but the argument has type 'u32' (aka 'unsigned int') [-Werror,-Wformat]
> > _leave(" = %d [set %hx]", ret, y);

Does anyone still use these debugging macros in rxrpc or
is it historic cruft?

net/rxrpc/ar-internal.h-#define kenter(FMT,...) dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
net/rxrpc/ar-internal.h-#define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
net/rxrpc/ar-internal.h-#define kdebug(FMT,...) dbgprintk("    "FMT ,##__VA_ARGS__)
net/rxrpc/ar-internal.h-#define kproto(FMT,...) dbgprintk("### "FMT ,##__VA_ARGS__)
net/rxrpc/ar-internal.h-#define knet(FMT,...)   dbgprintk("@@@ "FMT ,##__VA_ARGS__)

etc...

[]

net/rxrpc/Kconfig:config AF_RXRPC_DEBUG
net/rxrpc/Kconfig-      bool "RxRPC dynamic debugging"
net/rxrpc/Kconfig-      help
net/rxrpc/Kconfig-        Say Y here to make runtime controllable debugging messages appear.
net/rxrpc/Kconfig-
net/rxrpc/Kconfig-        See Documentation/networking/rxrpc.rst

This seems to show there is debugging documentation, but it
doesn't seem to exist in this file.

> diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
[]
> @@ -431,7 +431,7 @@ static int rxkad_secure_packet(struct rxrpc_call *call,
>  		break;
>  	}
>  
> -	_leave(" = %d [set %hx]", ret, y);
> +	_leave(" = %d [set %u]", ret, y);
>  	return ret;
>  }
>  


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] net: rxrpc: fix clang -Wformat warning
  2022-07-06 23:56 [PATCH] net: rxrpc: fix clang -Wformat warning Justin Stitt
                   ` (2 preceding siblings ...)
  2022-07-07 23:10 ` [PATCH] " Joe Perches
@ 2022-07-08  9:39 ` David Howells
  2022-07-08  9:39 ` [PATCH] " David Howells
  2022-07-08  9:40 ` David Howells
  5 siblings, 0 replies; 9+ messages in thread
From: David Howells @ 2022-07-08  9:39 UTC (permalink / raw)
  To: Justin Stitt
  Cc: dhowells, davem, edumazet, kuba, linux-afs, linux-kernel, llvm,
	marc.dionne, nathan, ndesaulniers, netdev, pabeni, trix

Justin Stitt <justinstitt@google.com> 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@google.com>

Acked-by: David Howells <dhowells@redhat.com>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] net: rxrpc: fix clang -Wformat warning
  2022-07-06 23:56 [PATCH] net: rxrpc: fix clang -Wformat warning Justin Stitt
                   ` (3 preceding siblings ...)
  2022-07-08  9:39 ` [PATCH v2] " David Howells
@ 2022-07-08  9:39 ` David Howells
  2022-07-08  9:40 ` David Howells
  5 siblings, 0 replies; 9+ messages in thread
From: David Howells @ 2022-07-08  9:39 UTC (permalink / raw)
  To: Joe Perches
  Cc: dhowells, Justin Stitt, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Marc Dionne, Nathan Chancellor,
	Nick Desaulniers, Tom Rix, linux-afs, netdev, linux-kernel, llvm

Joe Perches <joe@perches.com> wrote:

> Does anyone still use these debugging macros in rxrpc

Yes.

David


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] net: rxrpc: fix clang -Wformat warning
  2022-07-06 23:56 [PATCH] net: rxrpc: fix clang -Wformat warning Justin Stitt
                   ` (4 preceding siblings ...)
  2022-07-08  9:39 ` [PATCH] " David Howells
@ 2022-07-08  9:40 ` David Howells
  5 siblings, 0 replies; 9+ messages in thread
From: David Howells @ 2022-07-08  9:40 UTC (permalink / raw)
  To: Joe Perches
  Cc: dhowells, Justin Stitt, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Marc Dionne, Nathan Chancellor,
	Nick Desaulniers, Tom Rix, linux-afs, netdev, linux-kernel, llvm

Joe Perches <joe@perches.com> wrote:

> net/rxrpc/Kconfig:config AF_RXRPC_DEBUG
> net/rxrpc/Kconfig-      bool "RxRPC dynamic debugging"
> net/rxrpc/Kconfig-      help
> net/rxrpc/Kconfig-        Say Y here to make runtime controllable debugging messages appear.
> net/rxrpc/Kconfig-
> net/rxrpc/Kconfig-        See Documentation/networking/rxrpc.rst
> 
> This seems to show there is debugging documentation, but it
> doesn't seem to exist in this file.

Try looking in net/rxrpc/ar-internal.h:

	#elif defined(CONFIG_AF_RXRPC_DEBUG)

David


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] net: rxrpc: fix clang -Wformat warning
  2022-07-07 18:20 ` [PATCH v2] " Justin Stitt
  2022-07-07 18:24   ` Nathan Chancellor
@ 2022-07-09  3:20   ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 9+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-07-09  3:20 UTC (permalink / raw)
  To: Justin Stitt
  Cc: davem, dhowells, edumazet, kuba, linux-afs, linux-kernel, llvm,
	marc.dionne, nathan, ndesaulniers, netdev, pabeni, trix

Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Thu,  7 Jul 2022 11:20:52 -0700 you wrote:
> When building with Clang we encounter this warning:
> | net/rxrpc/rxkad.c:434:33: error: format specifies type 'unsigned short'
> | but the argument has type 'u32' (aka 'unsigned int') [-Werror,-Wformat]
> | _leave(" = %d [set %hx]", ret, y);
> 
> 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.
> 
> [...]

Here is the summary with links:
  - [v2] net: rxrpc: fix clang -Wformat warning
    https://git.kernel.org/netdev/net-next/c/5b47d2364652

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-07-09  3:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-06 23:56 [PATCH] net: rxrpc: fix clang -Wformat warning Justin Stitt
2022-07-07 17:58 ` Nathan Chancellor
2022-07-07 18:20 ` [PATCH v2] " Justin Stitt
2022-07-07 18:24   ` Nathan Chancellor
2022-07-09  3:20   ` patchwork-bot+netdevbpf
2022-07-07 23:10 ` [PATCH] " Joe Perches
2022-07-08  9:39 ` [PATCH v2] " David Howells
2022-07-08  9:39 ` [PATCH] " David Howells
2022-07-08  9:40 ` David Howells

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.