netconsole: Make boolean comparison consistent
authorBreno Leitao <leitao@debian.org>
Fri, 28 Feb 2025 12:50:18 +0000 (04:50 -0800)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 4 Mar 2025 14:28:27 +0000 (15:28 +0100)
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/
Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/netconsole.c

index c086e2fe51f874812379e6f89c421d7d32980f91..698dbbea2713f1ea90db741e924b45dd85609b47 100644 (file)
@@ -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;