diff mbox series

[net-next] net/ipv6: resolve warning in ip6_fib.c

Message ID 20240105173920.1041474-1-leitao@debian.org (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net/ipv6: resolve warning in ip6_fib.c | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1583 this patch: 1583
netdev/cc_maintainers success CCed 0 of 0 maintainers
netdev/build_clang success Errors and warnings before: 1114 this patch: 1112
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1622 this patch: 1622
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 12 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Breno Leitao Jan. 5, 2024, 5:39 p.m. UTC
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(-)

Comments

David Ahern Jan. 6, 2024, 4:13 p.m. UTC | #1
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]
Breno Leitao Jan. 8, 2024, 3:17 p.m. UTC | #2
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.
diff mbox series

Patch

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;