diff mbox series

[net-next,v2,2/8] netconsole: Make boolean comparison consistent

Message ID 20250228-netcons_current-v2-2-f53ff79a0db2@debian.org (mailing list archive)
State Accepted
Commit efb878fbe8d1fae3bf1974628e6d267dc861207e
Delegated to: Netdev Maintainers
Headers show
Series netconsole: Add taskname sysdata support | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
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: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
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: 0 this patch: 0
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-2025-03-01--03-00 (tests: 893)

Commit Message

Breno Leitao Feb. 28, 2025, 12:50 p.m. UTC
Convert the current state assignment to use explicit boolean conversion,
making the code more robust and easier to read. This change adds a
double-negation operator to ensure consistent boolean conversion as
suggested by Paolo[1].

This approach aligns with the existing pattern used in
sysdata_cpu_nr_enabled_show().

Link: https://lore.kernel.org/all/7309e760-63b0-4b58-ad33-2fb8db361141@redhat.com/ [1]
Signed-off-by: Breno Leitao <leitao@debian.org>
---
 drivers/net/netconsole.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Horman March 4, 2025, 11:50 a.m. UTC | #1
On Fri, Feb 28, 2025 at 04:50:18AM -0800, Breno Leitao wrote:
> Convert the current state assignment to use explicit boolean conversion,
> making the code more robust and easier to read. This change adds a
> double-negation operator to ensure consistent boolean conversion as
> suggested by Paolo[1].
> 
> This approach aligns with the existing pattern used in
> sysdata_cpu_nr_enabled_show().
> 
> Link: https://lore.kernel.org/all/7309e760-63b0-4b58-ad33-2fb8db361141@redhat.com/ [1]
> Signed-off-by: Breno Leitao <leitao@debian.org>

Thanks Breno,

FWIIW, I 100% agree with this change.

Reviewed-by: Simon Horman <horms@kernel.org>
diff mbox series

Patch

diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index c086e2fe51f87..698dbbea2713f 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -850,7 +850,7 @@  static ssize_t sysdata_cpu_nr_enabled_store(struct config_item *item,
 		return ret;
 
 	mutex_lock(&dynamic_netconsole_mutex);
-	curr = nt->sysdata_fields & SYSDATA_CPU_NR;
+	curr = !!(nt->sysdata_fields & SYSDATA_CPU_NR);
 	if (cpu_nr_enabled == curr)
 		/* no change requested */
 		goto unlock_ok;