diff mbox series

netfilter: remove unnecessary assignment in translate_table

Message ID 20240701115302.7246-1-liujing@cmss.chinamobile.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series netfilter: remove unnecessary assignment in translate_table | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be 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: 839 this patch: 839
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 846 this patch: 846
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: 853 this patch: 853
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 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
netdev/contest success net-next-2024-07-01--21-00 (tests: 665)

Commit Message

liujing July 1, 2024, 11:53 a.m. UTC
in translate_table, the initialized value of 'ret' is unused,
because it will be assigned in the rear. thus remove it.

Signed-off-by: Liu Jing <liujing@cmss.chinamobile.com>
---
 net/ipv4/netfilter/ip_tables.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Horman July 2, 2024, 9:28 a.m. UTC | #1
On Mon, Jul 01, 2024 at 07:53:02PM +0800, Liu Jing wrote:
> in translate_table, the initialized value of 'ret' is unused,
> because it will be assigned in the rear. thus remove it.
> 
> Signed-off-by: Liu Jing <liujing@cmss.chinamobile.com>

Thanks,

I agree that ret is always set before it is used in translate_table(),
and thus the initialisation to 0 accompanying the variable declaration
is unnecessary.

Reviewed-by: Simon Horman <horms@kernel.org>
Pablo Neira Ayuso Aug. 19, 2024, 5:02 p.m. UTC | #2
On Mon, Jul 01, 2024 at 07:53:02PM +0800, Liu Jing wrote:
> in translate_table, the initialized value of 'ret' is unused,
> because it will be assigned in the rear. thus remove it.
> 
> Signed-off-by: Liu Jing <liujing@cmss.chinamobile.com>
> ---
>  net/ipv4/netfilter/ip_tables.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
> index fe89a056eb06..c9b34d7d7558 100644
> --- a/net/ipv4/netfilter/ip_tables.c
> +++ b/net/ipv4/netfilter/ip_tables.c
> @@ -664,7 +664,7 @@ translate_table(struct net *net, struct xt_table_info *newinfo, void *entry0,
>  	struct ipt_entry *iter;
>  	unsigned int *offsets;
>  	unsigned int i;
> -	int ret = 0;
> +	int ret;

ip6_tables is a copy&paste from ip_tables, so it is arp_tables.

I think all of them have the same unnecessary initialization.

Would you still post v2?
diff mbox series

Patch

diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index fe89a056eb06..c9b34d7d7558 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -664,7 +664,7 @@  translate_table(struct net *net, struct xt_table_info *newinfo, void *entry0,
 	struct ipt_entry *iter;
 	unsigned int *offsets;
 	unsigned int i;
-	int ret = 0;
+	int ret;
 
 	newinfo->size = repl->size;
 	newinfo->number = repl->num_entries;