netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net/ipv6: resolve warning in ip6_fib.c
@ 2024-01-05 17:39 Breno Leitao
  2024-01-06 16:13 ` David Ahern
  0 siblings, 1 reply; 3+ messages in thread
From: Breno Leitao @ 2024-01-05 17:39 UTC (permalink / raw)
  To: David S. Miller, David Ahern, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt
  Cc: leit, open list:NETWORKING [IPv4/IPv6], open list,
	open list:CLANG/LLVM BUILD SUPPORT:Keyword:b(?i:clang|llvm)b

In some configurations, the 'iter' variable in function
fib6_repair_tree() is unused, resulting the following warning when
compiled with W=1.

	net/ipv6/ip6_fib.c:1781:6: warning: variable 'iter' set but not used [-Wunused-but-set-variable]
	 1781 |         int iter = 0;
	      |             ^

Rewrite RT6_TRACE() macro to keep the variable in scope.

Clang 18 removes the trace completely from the binary when the trace is
disabled[1], so, no overhead is expected with this change.

[1] Link: https://paste.debian.net/1303162/

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 include/net/ip6_fib.h | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 9ba6413fd2e3..d2ef60ebeb25 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -30,11 +30,7 @@
 
 #define RT6_DEBUG 2
 
-#if RT6_DEBUG >= 3
-#define RT6_TRACE(x...) pr_debug(x)
-#else
-#define RT6_TRACE(x...) do { ; } while (0)
-#endif
+#define RT6_TRACE(x...) do { if (RT6_DEBUG > 3) pr_debug(x); } while (0)
 
 struct rt6_info;
 struct fib6_info;
-- 
2.39.3


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

* Re: [PATCH net-next] net/ipv6: resolve warning in ip6_fib.c
  2024-01-05 17:39 [PATCH net-next] net/ipv6: resolve warning in ip6_fib.c Breno Leitao
@ 2024-01-06 16:13 ` David Ahern
  2024-01-08 15:17   ` Breno Leitao
  0 siblings, 1 reply; 3+ messages in thread
From: David Ahern @ 2024-01-06 16:13 UTC (permalink / raw)
  To: Breno Leitao, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt
  Cc: leit, open list:NETWORKING [IPv4/IPv6], open list,
	open list:CLANG/LLVM BUILD SUPPORT:Keyword:b(?i:clang|llvm)b,
	Wei Wang

On 1/5/24 10:39 AM, Breno Leitao wrote:
> In some configurations, the 'iter' variable in function
> fib6_repair_tree() is unused, resulting the following warning when
> compiled with W=1.
> 
> 	net/ipv6/ip6_fib.c:1781:6: warning: variable 'iter' set but not used [-Wunused-but-set-variable]
> 	 1781 |         int iter = 0;
> 	      |             ^
> 
> Rewrite RT6_TRACE() macro to keep the variable in scope.
> 
> Clang 18 removes the trace completely from the binary when the trace is
> disabled[1], so, no overhead is expected with this change.
> 
> [1] Link: https://paste.debian.net/1303162/
> 
> Signed-off-by: Breno Leitao <leitao@debian.org>
> ---
>  include/net/ip6_fib.h | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
> index 9ba6413fd2e3..d2ef60ebeb25 100644
> --- a/include/net/ip6_fib.h
> +++ b/include/net/ip6_fib.h
> @@ -30,11 +30,7 @@
>  
>  #define RT6_DEBUG 2
>  
> -#if RT6_DEBUG >= 3
> -#define RT6_TRACE(x...) pr_debug(x)
> -#else
> -#define RT6_TRACE(x...) do { ; } while (0)
> -#endif
> +#define RT6_TRACE(x...) do { if (RT6_DEBUG > 3) pr_debug(x); } while (0)
>  
>  struct rt6_info;
>  struct fib6_info;

I question the value of RT6_TRACE vs just using pr_debug; pr_debug has
zero cost until enabled and can be enabled by file or line. Not
requiring a kernel build is actual better.

[cc'ed Wei who added the macro]

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

* Re: [PATCH net-next] net/ipv6: resolve warning in ip6_fib.c
  2024-01-06 16:13 ` David Ahern
@ 2024-01-08 15:17   ` Breno Leitao
  0 siblings, 0 replies; 3+ messages in thread
From: Breno Leitao @ 2024-01-08 15:17 UTC (permalink / raw)
  To: David Ahern
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	leit, open list:NETWORKING [IPv4/IPv6], open list,
	open list:CLANG/LLVM BUILD SUPPORT:Keyword:b(?i:clang|llvm)b,
	Wei Wang

On Sat, Jan 06, 2024 at 09:13:53AM -0700, David Ahern wrote:
> On 1/5/24 10:39 AM, Breno Leitao wrote:

> > -#if RT6_DEBUG >= 3
> > -#define RT6_TRACE(x...) pr_debug(x)
> > -#else
> > -#define RT6_TRACE(x...) do { ; } while (0)
> > -#endif
> > +#define RT6_TRACE(x...) do { if (RT6_DEBUG > 3) pr_debug(x); } while (0)
> >  
> >  struct rt6_info;
> >  struct fib6_info;
> 
> I question the value of RT6_TRACE vs just using pr_debug; pr_debug has
> zero cost until enabled and can be enabled by file or line. Not
> requiring a kernel build is actual better.
> 
> [cc'ed Wei who added the macro]

I also questioned it.

Anyway, if we don't hear any strong opinion in favor of RT6_TRACE(), I
will replace it by pr_debug() in a v2.

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

end of thread, other threads:[~2024-01-08 15:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-05 17:39 [PATCH net-next] net/ipv6: resolve warning in ip6_fib.c Breno Leitao
2024-01-06 16:13 ` David Ahern
2024-01-08 15:17   ` Breno Leitao

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).