fix unused-but-set-global warnings
cover fix unused-but-set-global warnings
Clang 23 adds -Wunused-but-set-global, which reports file scope variables that are assigned but never read. It is enabled by -Wall and does not appear with gcc or with clang 20 through 22.
Three of these are dead variables and are simply removed. The fourth, 'alive' in dpaa_of.c, is a real debug aid: it is only read by DPAAX_HWWARN, which discards its condition when RTE_LIBRTE_DPAAX_DEBUG is not defined. That one is fixed by making the empty expansion consume its argument, which keeps the condition compiled in both builds and covers every other DPAAX_HWWARN user as well.
The patches are independent and touch four unrelated drivers.
Stephen Hemminger (4):
common/dpaax: fix unused variable warning in non-debug build bus/dpaa: remove unused qman_clk variable common/zsda: remove unused device counter net/qede: remove unused app version variable
drivers/bus/dpaa/base/qbman/qman_driver.c | 4 ---- drivers/common/dpaax/dpaax_logs.h | 3 ++- drivers/common/zsda/zsda_device.c | 5 ----- drivers/net/qede/qede_debug.c | 9 --------- 4 files changed, 2 insertions(+), 19 deletions(-)
Signature · 1 line
2.53.0
PATCH 1/4 common/dpaax: fix unused variable warning in non-debug build
Fix compiler warning on clang-23.
dpaa_of.c:14:12: warning: variable 'alive' set but not used
[-Wunused-but-set-global]
The 'alive' flag is only read by DPAAX_HWWARN, which expands to an empty statement and discards its condition unless RTE_LIBRTE_DPAAX_DEBUG is defined. Make the empty expansion consume its argument so the condition is still checked in a non-debug build.
--- drivers/common/dpaax/dpaax_logs.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/common/dpaax/dpaax_logs.h +2 -1
@@ -5,6 +5,7 @@#ifndef _DPAAX_LOGS_H_#define _DPAAX_LOGS_H_ +#include <rte_common.h> #include <rte_log.h> extern int dpaax_logger;
@@ -17,7 +18,7 @@ extern int dpaax_logger; DPAAX_LOG(DEBUG, "WARN: " fmt, ##__VA_ARGS__); \ } while (0) #else -#define DPAAX_HWWARN (cond, fmt, ...) do { } while (0) +#define DPAAX_HWWARN (cond, fmt, ...) do { RTE_SET_USED(cond); } while (0)#endif #define DPAAX_LOG (level, ...) \
Signature · 1 line
2.53.0
Re: [PATCH 1/4] common/dpaax: fix unused variable warning in non-debug build
Quoted 6 lines · Stephen Hemminger
Fix compiler warning on clang-23.
dpaa_of.c:14:12: warning: variable 'alive' set but not used
[-Wunused-but-set-global]
Quoted 6 lines
The 'alive' flag is only read by
DPAAX_HWWARN, which expands to an empty statement and discards its condition unlessRTE_LIBRTE_DPAAX_DEBUGis defined. Make the empty expansion consume its argument so the condition is still checked in a non-debug build.Fixes 8c83f28cc8a4 ("common/dpaax: move OF library from DPAA bus")
Not that important, the issue probably predates this commit.
And looking at this change, it seems DPAA_BUS_HWWARN is dead code since then.
Quoted 3 lines
Signed-off-by Stephen Hemminger <[email protected]>
Otherwise lgtm.
Signature · 1 line
David Marchand
Re: [PATCH 1/4] common/dpaax: fix unused variable warning in non-debug build
Quoted 13 lines · On Thu, 27 Aug 2026 11:07:50 +0200 David Marchand <[email protected]>…
Quoted 11 lines · Stephen Hemminger
Fix compiler warning on clang-23.
dpaa_of.c:14:12: warning: variable 'alive' set but not used
[-Wunused-but-set-global]The 'alive' flag is only read by
DPAAX_HWWARN, which expands to an empty statement and discards its condition unlessRTE_LIBRTE_DPAAX_DEBUGis defined. Make the empty expansion consume its argument so the condition is still checked in a non-debug build.
Quoted 4 lines
Quoted 1 line
Fixes 8c83f28cc8a4 ("common/dpaax: move OF library from DPAA bus")Not that important, the issue probably predates this commit.
And looking at this change, it seemsDPAA_BUS_HWWARNis dead code since then.
That is when the device-tree warning was added.
The history scan looks right.
It seems like it should either be removed as irrelevant or made into a regular warning. But that is up to Hemant and Sachin to decide; I just want clean builds for now.
Hemant Agrawal
Acked-byRe: [PATCH 1/4] common/dpaax: fix unused variable warning in non-debug build
Quoted 16 lines · Stephen Hemminger
Quoted 13 lines · On Thu, 27 Aug 2026 11:07:50 +0200 David Marchand<[email protected]>…
Quoted 11 lines · Stephen Hemminger
Fix compiler warning on clang-23.
dpaa_of.c:14:12: warning: variable 'alive' set but not used
[-Wunused-but-set-global]The 'alive' flag is only read by
DPAAX_HWWARN, which expands to an empty statement and discards its condition unlessRTE_LIBRTE_DPAAX_DEBUGis defined. Make the empty expansion consume its argument so the condition is still checked in a non-debug build.Fixes 8c83f28cc8a4 ("common/dpaax: move OF library from DPAA bus")
Quoted 8 lines
Quoted 2 lines
Not that important, the issue probably predates this commit.
And looking at this change, it seemsDPAA_BUS_HWWARNis dead code since then.That is when the device-tree warning was added.
The history scan looks right.It seems like it should either be removed as irrelevant or made into a regular warning. But that is up to Hemant and Sachin to decide; I just want clean builds for now.We need to remove this define.
We will plan to remove this definition in future.
PATCH 2/4 bus/dpaa: remove unused qman_clk variable
In reply to Stephen HemmingerThe driver was recording the clock frequency and never using it.
clang 23 reports:
qman_driver.c:27:12: warning: variable 'qman_clk' set but not used
[-Wunused-but-set-global]
Remove the variable and the dead store.
--- drivers/bus/dpaa/base/qbman/qman_driver.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/bus/dpaa/base/qbman/qman_driver.c +0 -4
@@ -23,8 +23,6 @@ u16 qm_channel_pme = QMAN_CHANNEL_PME;/* Ccsr map address to access ccsrbased register */ static void *qman_ccsr_map; -/* The qman clock frequency */ -static u32 qman_clk;static __threadint qmfd =-1 ;static __threadstruct qm_portal_config qpcfg;
@@ -371,8 +369,6 @@ int qman_global_init(void) clk =of_get_property (dt_node,"clock-frequency" ,NULL );if (!clk)pr_warn ("Can't find Qman clock frequency\n" ); -else - qman_clk =be32_to_cpu (*clk);#ifdef CONFIG_FSL_QMAN_FQ_LOOKUP return qman_setup_fq_lookup_table (CONFIG_FSL_QMAN_FQ_LOOKUP_MAX );
Signature · 1 line
2.53.0
Re: [PATCH 2/4] bus/dpaa: remove unused qman_clk variable
PATCH 3/4 common/zsda: remove unused device counter
In reply to Stephen Hemmingerzsda_nb_pci_devices is incremented when a PCI device is allocated and decremented when it is released, but the count is never read.
clang 23 reports:
zsda_device.c:10:12: warning: variable 'zsda_nb_pci_devices' set but
not used [-Wunused-but-set-global]
Remove the counter and the three sites that update it.
--- drivers/common/zsda/zsda_device.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/common/zsda/zsda_device.c +0 -5
@@ -7,7 +7,6 @@/* per-process array of device data */ struct zsda_device_info zsda_devs[RTE_PMD_ZSDA_MAX_PCI_DEVICES ]; -static int zsda_nb_pci_devices;/* * The set of PCI devices this driver supports
@@ -85,7 +84,6 @@ zsda_pci_device_allocate(struct rte_pci_device *pci_dev) zsda_pci_dev = mz->addr; zsda_devs[zsda_pci_dev->zsda_dev_id].mz = mz; zsda_devs[zsda_pci_dev->zsda_dev_id].pci_dev = pci_dev; - zsda_nb_pci_devices++;return zsda_pci_dev; }
@@ -114,8 +112,6 @@ zsda_pci_device_allocate(struct rte_pci_device *pci_dev) zsda_pci_dev->pci_dev = pci_dev; zsda_devs[zsda_dev_id].pci_dev = pci_dev; - zsda_nb_pci_devices++; -return zsda_pci_dev; }
@@ -141,7 +137,6 @@ zsda_pci_device_release(const struct rte_pci_device *pci_dev)rte_memzone_free (inst->mz);memset (inst,0 ,sizeof (struct zsda_device_info )); - zsda_nb_pci_devices--; }return 0 ; }
Signature · 1 line
2.53.0
PATCH 4/4 net/qede: remove unused app version variable
In reply to Stephen Hemmingerqed_dbg_set_app_ver() validates the caller's version and stores it. But the variable s_app_ver is never used in DPDK driver.
clang 23 reports:
qede_debug.c:820:12: warning: variable 's_app_ver' set but not used
[-Wunused-but-set-global]
Remove the variable and the dead store.
--- drivers/net/qede/qede_debug.c | 9 --------- 1 file changed, 9 deletions(-)
drivers/net/qede/qede_debug.c +0 -9
@@ -812,13 +812,6 @@ static struct split_type_defs s_split_type_defs[] = { {"vf"} }; -/******************************** Variables *********************************/ - -/** -* The version of the calling app -*/ -static u32 s_app_ver; -/**************************** Private Functions ******************************/ /* Reads and returns a single dword from the specified unaligned buffer */
@@ -4869,8 +4862,6 @@ enum dbg_status qed_dbg_set_app_ver(u32 ver)if (ver <TOOLS_VERSION )return DBG_STATUS_UNSUPPORTED_APP_VERSION ; - s_app_ver = ver; -return DBG_STATUS_OK ; }
Signature · 1 line
2.53.0
Re: [PATCH 4/4] net/qede: remove unused app version variable
Quoted 10 lines · Stephen Hemminger
qed_dbg_set_app_ver()validates the caller's version and stores it. But the variables_app_veris never used in DPDK driver.clang 23 reports:
qede_debug.c:820:12: warning: variable '
s_app_ver' set but not used
[-Wunused-but-set-global]Remove the variable and the dead store.
Maybe go one step further?qed_dbg_set_app_ver() looks useless.
Quoted 5 lines
Fixes ec55c118792b ("net/qede: add infrastructure for debug data collection")Signed-off-by Stephen Hemminger <[email protected]>
Signature · 1 line
David Marchand
Re: [PATCH 4/4] net/qede: remove unused app version variable
Quoted 8 lines · On Thu, 27 Aug 2026 11:08:07 +0200 David Marchand <[email protected]>…
Quoted 6 lines · Stephen Hemminger
qed_dbg_set_app_ver()validates the caller's version and stores it. But the variables_app_veris never used in DPDK driver.clang 23 reports:
Quoted 7 lines
Quoted 4 lines
qede_debug.c:820:12: warning: variable '
s_app_ver' set but not used
[-Wunused-but-set-global]Remove the variable and the dead store.
Maybe go one step further?
qed_dbg_set_app_ver()looks useless.
Yes it is useless code. Looks like inherited from Linux driver.
v2 cover fix clang 23 unused but set warnings
In reply to Stephen HemmingerClang 23 adds -Wunused-but-set-global, which reports file scope variables that are assigned but never read. It is enabled by -Wall and does not appear with gcc or with clang 20 through 22.
Three of these are dead variables and are simply removed. The fourth, 'alive' in dpaa_of.c, is a real debug aid: it is only read by DPAAX_HWWARN, which discards its condition when RTE_LIBRTE_DPAAX_DEBUG is not defined. That one is fixed by making the empty expansion consume its argument, which keeps the condition compiled in both builds and covers every other DPAAX_HWWARN user as well.
v2 - remove more unused code as suggested.
Stephen Hemminger (4):
common/dpaax: fix unused variable warning in non-debug build bus/dpaa: remove unused qman_clk variable common/zsda: remove unused device counter net/qede: remove unused app version variable
drivers/bus/dpaa/base/qbman/qman_driver.c | 4 ---- drivers/common/dpaax/dpaax_logs.h | 3 ++- drivers/common/zsda/zsda_device.c | 5 ----- drivers/net/qede/qede_debug.c | 20 -------------------- 4 files changed, 2 insertions(+), 30 deletions(-)
Signature · 1 line
2.53.0
PATCH v2 1/4 common/dpaax: fix unused variable warning in non-debug build
Fix compiler warning on clang-23.
dpaa_of.c:14:12: warning: variable 'alive' set but not used
[-Wunused-but-set-global]
The 'alive' flag is only read by DPAAX_HWWARN, which expands to an empty statement and discards its condition unless RTE_LIBRTE_DPAAX_DEBUG is defined. Make the empty expansion consume its argument so the condition is still checked in a non-debug build.
--- drivers/common/dpaax/dpaax_logs.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/common/dpaax/dpaax_logs.h +2 -1
@@ -5,6 +5,7 @@#ifndef _DPAAX_LOGS_H_#define _DPAAX_LOGS_H_ +#include <rte_common.h> #include <rte_log.h> extern int dpaax_logger;
@@ -17,7 +18,7 @@ extern int dpaax_logger; DPAAX_LOG(DEBUG, "WARN: " fmt, ##__VA_ARGS__); \ } while (0) #else -#define DPAAX_HWWARN (cond, fmt, ...) do { } while (0) +#define DPAAX_HWWARN (cond, fmt, ...) do { RTE_SET_USED(cond); } while (0)#endif #define DPAAX_LOG (level, ...) \
Signature · 1 line
2.53.0
PATCH v2 2/4 bus/dpaa: remove unused qman_clk variable
In reply to Stephen HemmingerThe driver was recording the clock frequency and never using it.
clang 23 reports:
qman_driver.c:27:12: warning: variable 'qman_clk' set but not used
[-Wunused-but-set-global]
Remove the variable and the dead store.
--- drivers/bus/dpaa/base/qbman/qman_driver.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/bus/dpaa/base/qbman/qman_driver.c +0 -4
@@ -23,8 +23,6 @@ u16 qm_channel_pme = QMAN_CHANNEL_PME;/* Ccsr map address to access ccsrbased register */ static void *qman_ccsr_map; -/* The qman clock frequency */ -static u32 qman_clk;static __threadint qmfd =-1 ;static __threadstruct qm_portal_config qpcfg;
@@ -371,8 +369,6 @@ int qman_global_init(void) clk =of_get_property (dt_node,"clock-frequency" ,NULL );if (!clk)pr_warn ("Can't find Qman clock frequency\n" ); -else - qman_clk =be32_to_cpu (*clk);#ifdef CONFIG_FSL_QMAN_FQ_LOOKUP return qman_setup_fq_lookup_table (CONFIG_FSL_QMAN_FQ_LOOKUP_MAX );
Signature · 1 line
2.53.0
PATCH v2 3/4 common/zsda: remove unused device counter
In reply to Stephen Hemmingerzsda_nb_pci_devices is incremented when a PCI device is allocated and decremented when it is released, but the count is never read.
clang 23 reports:
zsda_device.c:10:12: warning: variable 'zsda_nb_pci_devices' set but
not used [-Wunused-but-set-global]
Remove the counter and the three sites that update it.
---
The CI AI review of this patch was hallucinating and fabricated functions that don't exist.
drivers/common/zsda/zsda_device.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/common/zsda/zsda_device.c +0 -5
@@ -7,7 +7,6 @@/* per-process array of device data */ struct zsda_device_info zsda_devs[RTE_PMD_ZSDA_MAX_PCI_DEVICES ]; -static int zsda_nb_pci_devices;/* * The set of PCI devices this driver supports
@@ -85,7 +84,6 @@ zsda_pci_device_allocate(struct rte_pci_device *pci_dev) zsda_pci_dev = mz->addr; zsda_devs[zsda_pci_dev->zsda_dev_id].mz = mz; zsda_devs[zsda_pci_dev->zsda_dev_id].pci_dev = pci_dev; - zsda_nb_pci_devices++;return zsda_pci_dev; }
@@ -114,8 +112,6 @@ zsda_pci_device_allocate(struct rte_pci_device *pci_dev) zsda_pci_dev->pci_dev = pci_dev; zsda_devs[zsda_dev_id].pci_dev = pci_dev; - zsda_nb_pci_devices++; -return zsda_pci_dev; }
@@ -141,7 +137,6 @@ zsda_pci_device_release(const struct rte_pci_device *pci_dev)rte_memzone_free (inst->mz);memset (inst,0 ,sizeof (struct zsda_device_info )); - zsda_nb_pci_devices--; }return 0 ; }
Signature · 1 line
2.53.0
PATCH v2 4/4 net/qede: remove unused app version variable
In reply to Stephen Hemmingerqed_dbg_set_app_ver() validates the caller's version and stores it. clang 23 reports:
qede_debug.c:820:12: warning: variable 's_app_ver' set but not used
[-Wunused-but-set-global]
Since the whole qed_dbg_set_app_ver() function is doing nothing remove it.
--- drivers/net/qede/qede_debug.c | 20 -------------------- 1 file changed, 20 deletions(-)
drivers/net/qede/qede_debug.c +0 -20
@@ -812,13 +812,6 @@ static struct split_type_defs s_split_type_defs[] = { {"vf"} }; -/******************************** Variables *********************************/ - -/** -* The version of the calling app -*/ -static u32 s_app_ver; -/**************************** Private Functions ******************************/ /* Reads and returns a single dword from the specified unaligned buffer */
@@ -4864,16 +4857,6 @@ enum dbg_status qed_dbg_set_bin_ptr(struct ecore_hwfn *p_hwfn,return DBG_STATUS_OK ; } -enum dbg_status qed_dbg_set_app_ver (u32 ver) -{ -if (ver <TOOLS_VERSION ) -return DBG_STATUS_UNSUPPORTED_APP_VERSION ; - - s_app_ver = ver; - -return DBG_STATUS_OK ; -} -bool qed_read_fw_info (struct ecore_hwfn *p_hwfn,struct ecore_ptt *p_ptt,struct fw_info *fw_info) {
@@ -8087,9 +8070,6 @@ void qed_dbg_pf_init(struct ecore_dev *edev)OSAL_MUTEX_INIT (&edev->dbg_lock); -/* Sync ver with debugbus qed code */ -qed_dbg_set_app_ver (TOOLS_VERSION ); -/* Debug values are after init values. * The offset is the first dword of the file. */
Signature · 1 line
2.53.0
Re: [PATCH v2 0/4] fix clang 23 unused but set warnings
In reply to Stephen HemmingerQuoted 20 lines · Stephen Hemminger
Clang 23 adds -Wunused-but-set-global, which reports file scope variables that are assigned but never read. It is enabled by -Wall and does not appear with gcc or with clang 20 through 22.
Three of these are dead variables and are simply removed. The fourth, 'alive' in
dpaa_of.c, is a real debug aid: it is only read byDPAAX_HWWARN, which discards its condition whenRTE_LIBRTE_DPAAX_DEBUGis not defined. That one is fixed by making the empty expansion consume its argument, which keeps the condition compiled in both builds and covers every otherDPAAX_HWWARNuser as well.v2 - remove more unused code as suggested.
Stephen Hemminger (4):
common/dpaax: fix unused variable warning in non-debug build bus/dpaa: remove unusedqman_clkvariable common/zsda: remove unused device counter net/qede: remove unused app version variable
Quoted 5 lines
drivers/bus/dpaa/base/qbman/qman_driver.c | 4 ---- drivers/common/dpaax/dpaax_logs.h | 3 ++- drivers/common/zsda/zsda_device.c | 5 ----- drivers/net/qede/qede_debug.c | 20 -------------------- 4 files changed, 2 insertions(+), 30 deletions(-)
For the series:
Signature · 1 line
David Marchand
Re: [PATCH v2 0/4] fix clang 23 unused but set warnings
In reply to Stephen HemmingerQuoted 19 lines · On Sat, 29 Aug 2026 08:44:44 -0700 Stephen Hemminger…
Clang 23 adds -Wunused-but-set-global, which reports file scope variables that are assigned but never read. It is enabled by -Wall and does not appear with gcc or with clang 20 through 22.
Three of these are dead variables and are simply removed. The fourth, 'alive' in
dpaa_of.c, is a real debug aid: it is only read byDPAAX_HWWARN, which discards its condition whenRTE_LIBRTE_DPAAX_DEBUGis not defined. That one is fixed by making the empty expansion consume its argument, which keeps the condition compiled in both builds and covers every otherDPAAX_HWWARNuser as well.v2 - remove more unused code as suggested.
Stephen Hemminger (4):
common/dpaax: fix unused variable warning in non-debug build bus/dpaa: remove unusedqman_clkvariable common/zsda: remove unused device counter net/qede: remove unused app version variable
Quoted 6 lines
drivers/bus/dpaa/base/qbman/qman_driver.c | 4 ---- drivers/common/dpaax/dpaax_logs.h | 3 ++- drivers/common/zsda/zsda_device.c | 5 ----- drivers/net/qede/qede_debug.c | 20 -------------------- 4 files changed, 2 insertions(+), 30 deletions(-)
Applied to next-net; so that clang 23 build tests can run across all drivers