netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] netfilter: clean up returns in nf_conntrack_log_invalid_sysctl()
@ 2025-08-04 10:35 Dan Carpenter
  2025-08-04 10:43 ` Lance Yang
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2025-08-04 10:35 UTC (permalink / raw)
  To: Lance Yang, Pablo Neira Ayuso
  Cc: Jozsef Kadlecsik, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, netfilter-devel, coreteam, netdev,
	kernel-janitors

Smatch complains that these look like error paths with missing error
codes, especially the one where we return if nf_log_is_registered() is
true:

    net/netfilter/nf_conntrack_standalone.c:575 nf_conntrack_log_invalid_sysctl()
    warn: missing error code? 'ret'

In fact, all these return zero deliberately.  Change them to return a
literal instead which helps readability as well as silencing the warning.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 net/netfilter/nf_conntrack_standalone.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
index 9b8b10a85233..1f14ef0436c6 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -567,16 +567,16 @@ nf_conntrack_log_invalid_sysctl(const struct ctl_table *table, int write,
 		return ret;
 
 	if (*(u8 *)table->data == 0)
-		return ret;
+		return 0;
 
 	/* Load nf_log_syslog only if no logger is currently registered */
 	for (i = 0; i < NFPROTO_NUMPROTO; i++) {
 		if (nf_log_is_registered(i))
-			return ret;
+			return 0;
 	}
 	request_module("%s", "nf_log_syslog");
 
-	return ret;
+	return 0;
 }
 
 static struct ctl_table_header *nf_ct_netfilter_header;
-- 
2.47.2


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

* Re: [PATCH net-next] netfilter: clean up returns in nf_conntrack_log_invalid_sysctl()
  2025-08-04 10:35 [PATCH net-next] netfilter: clean up returns in nf_conntrack_log_invalid_sysctl() Dan Carpenter
@ 2025-08-04 10:43 ` Lance Yang
  0 siblings, 0 replies; 2+ messages in thread
From: Lance Yang @ 2025-08-04 10:43 UTC (permalink / raw)
  To: Dan Carpenter, Pablo Neira Ayuso
  Cc: Jozsef Kadlecsik, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, netfilter-devel, coreteam, netdev,
	kernel-janitors



On 2025/8/4 18:35, Dan Carpenter wrote:
> Smatch complains that these look like error paths with missing error
> codes, especially the one where we return if nf_log_is_registered() is
> true:
> 
>      net/netfilter/nf_conntrack_standalone.c:575 nf_conntrack_log_invalid_sysctl()
>      warn: missing error code? 'ret'
> 
> In fact, all these return zero deliberately.  Change them to return a
> literal instead which helps readability as well as silencing the warning.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

LGTM, feel free to add:

Acked-by: Lance Yang <lance.yang@linux.dev>

> ---
>   net/netfilter/nf_conntrack_standalone.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
> index 9b8b10a85233..1f14ef0436c6 100644
> --- a/net/netfilter/nf_conntrack_standalone.c
> +++ b/net/netfilter/nf_conntrack_standalone.c
> @@ -567,16 +567,16 @@ nf_conntrack_log_invalid_sysctl(const struct ctl_table *table, int write,
>   		return ret;
>   
>   	if (*(u8 *)table->data == 0)
> -		return ret;
> +		return 0;
>   
>   	/* Load nf_log_syslog only if no logger is currently registered */
>   	for (i = 0; i < NFPROTO_NUMPROTO; i++) {
>   		if (nf_log_is_registered(i))
> -			return ret;
> +			return 0;
>   	}
>   	request_module("%s", "nf_log_syslog");
>   
> -	return ret;
> +	return 0;
>   }
>   
>   static struct ctl_table_header *nf_ct_netfilter_header;


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

end of thread, other threads:[~2025-08-04 10:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-04 10:35 [PATCH net-next] netfilter: clean up returns in nf_conntrack_log_invalid_sysctl() Dan Carpenter
2025-08-04 10:43 ` Lance Yang

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