Skip to contentSkip to conversation

netfilter: clean up returns in nf_conntrack_log_invalid_sysctl()

PATCH In review Dan Carpenter 2 participants 2 messages Aug 4, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: clean up returns in nf_conntrack_log_invalid_sysctl()

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.

---
 net/netfilter/nf_conntrack_standalone.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
net/netfilter/nf_conntrack_standalone.c +3 -3
index 9b8b10a85233..1f14ef0436c6 100644
@@ -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;
Signature · 1 line
2.47.2
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Dan Carpenter

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.

LGTM, feel free to add:

Quoted 28 lines
---
  net/netfilter/nf_conntrack_standalone.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
net/netfilter/nf_conntrack_standalone.c +3 -3
index 9b8b10a85233..1f14ef0436c6 100644
@@ -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;