Skip to contentSkip to conversation

remove unused variables and add MSVC compiler flag

PATCH Superseded Andre Muezerie 3 participants 13 messages Dec 26, 2024 – Feb 5, 2025

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

cover remove unused variables and add MSVC compiler flag

Removed unused variables and added MSVC specific compiler flag to ignore warnings about unused variables, like is being done for other compilers.

Andre Muezerie (2):
drivers/common: remove unused variables and add MSVC compiler flag drivers/net: remove unused variables and add MSVC compiler flag

 drivers/common/idpf/base/meson.build       | 13 +++--
 drivers/common/idpf/idpf_common_rxtx.c     |  2 -
 drivers/common/idpf/idpf_common_virtchnl.c |  4 +-
 drivers/common/sfc_efx/base/efx_mae.c      |  2 +-
 drivers/common/sfc_efx/base/efx_table.c    |  1 -
 drivers/common/sfc_efx/base/meson.build    | 20 +++++---
 drivers/net/ice/base/ice_switch.c          |  2 -
 drivers/net/ice/base/meson.build           | 16 ++++--
 drivers/net/qede/base/ecore_dcbx.c         |  2 -
 drivers/net/qede/base/ecore_mcp.c          |  2 -
 drivers/net/qede/base/meson.build          | 57 ++++++++++++----------
 11 files changed, 69 insertions(+), 52 deletions(-)

--
2.47.0.vfs.0.3

#1 lore raw

PATCH 1/2 drivers/common: remove unused variables and add MSVC compiler flag

Removed unused variables and added MSVC specific compiler flag to ignore warnings about unused variables, like is being done for other compilers.

---
 drivers/common/idpf/base/meson.build       | 13 ++++++++++---
 drivers/common/idpf/idpf_common_rxtx.c     |  2 --
 drivers/common/idpf/idpf_common_virtchnl.c |  4 ++--
 drivers/common/sfc_efx/base/efx_mae.c      |  2 +-
 drivers/common/sfc_efx/base/efx_table.c    |  1 -
 drivers/common/sfc_efx/base/meson.build    | 20 +++++++++++++-------
 6 files changed, 26 insertions(+), 16 deletions(-)
drivers/common/idpf/base/meson.build +10 -3
index f30ec7dfc2..c069507f12 100644
@@ -6,9 +6,16 @@ sources += files(
         'idpf_controlq_setup.c',
 )
 
-error_cflags = [
-        '-Wno-unused-variable',
-]
+if is_ms_compiler
+    error_cflags = [
+            '/wd4101', # unreferenced local variable
+    ]
+else
+    error_cflags = [
+            '-Wno-unused-variable',
+    ]
+endif
+
 foreach flag: error_cflags
     if cc.has_argument(flag)
         cflags += flag
drivers/common/idpf/idpf_common_rxtx.c +0 -2
index a04e54ce26..9b17279181 100644
@@ -1178,7 +1178,6 @@ idpf_dp_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	struct rte_mbuf *last_seg = rxq->pkt_last_seg;
 	struct rte_mbuf *rxm;
 	struct rte_mbuf *nmb;
-	struct rte_eth_dev *dev;
 	const uint32_t *ptype_tbl = rxq->adapter->ptype_tbl;
 	uint16_t rx_id = rxq->rx_tail;
 	uint16_t rx_packet_len;
@@ -1310,7 +1309,6 @@ idpf_xmit_cleanup(struct idpf_tx_queue *txq)
 	uint16_t nb_tx_desc = txq->nb_tx_desc;
 	uint16_t desc_to_clean_to;
 	uint16_t nb_tx_to_clean;
-	uint16_t i;
 
 	volatile struct idpf_base_tx_desc *txd = txq->tx_ring;
 
drivers/common/idpf/idpf_common_virtchnl.c +2 -2
index de511da788..0ae1d55d79 100644
@@ -362,7 +362,7 @@ idpf_vc_queue_grps_add(struct idpf_vport *vport,
 {
 	struct idpf_adapter *adapter = vport->adapter;
 	struct idpf_cmd_info args;
-	int size, qg_info_size;
+	int size;
 	int err = -1;
 
 	size = sizeof(*p2p_queue_grps_info) +
@@ -1044,7 +1044,7 @@ int idpf_vc_rxq_config_by_info(struct idpf_vport *vport, struct virtchnl2_rxq_in
 	struct idpf_adapter *adapter = vport->adapter;
 	struct virtchnl2_config_rx_queues *vc_rxqs = NULL;
 	struct idpf_cmd_info args;
-	int size, err, i;
+	int size, err;
 
 	size = sizeof(*vc_rxqs) + (num_qs - 1) *
 		sizeof(struct virtchnl2_rxq_info);
drivers/common/sfc_efx/base/efx_mae.c +1 -1
index 9ae136dcce..1429e7dd0a 100644
@@ -740,7 +740,6 @@ efx_mae_mport_by_pcie_function(
 	__in				uint32_t vf,
 	__out				efx_mport_sel_t *mportp)
 {
-	efx_dword_t dword;
 	efx_rc_t rc;
 
 	rc = efx_mae_mport_by_pcie_mh_function(EFX_PCIE_INTERFACE_CALLER,
@@ -4280,6 +4279,7 @@ efx_mae_action_set_replay(
 	__out			efx_mae_actions_t **spec_clonep)
 {
 	const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
+	(void)encp;
 	efx_mae_actions_t *spec_clone;
 	efx_rc_t rc;
 
drivers/common/sfc_efx/base/efx_table.c +0 -1
index 13a12a116e..50e9a37d1c 100644
@@ -240,7 +240,6 @@ efx_table_describe(
 	const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
 	unsigned int n_entries;
 	efx_mcdi_req_t req;
-	unsigned int i;
 	efx_rc_t rc;
 	EFX_MCDI_DECLARE_BUF(payload,
 	    MC_CMD_TABLE_DESCRIPTOR_IN_LEN,
drivers/common/sfc_efx/base/meson.build +13 -7
index 7fc04aa57b..c8deb4555e 100644
@@ -66,13 +66,19 @@ sources = [
         'rhead_virtio.c',
 ]
 
-extra_flags = [
-        '-Wno-sign-compare',
-        '-Wno-unused-parameter',
-        '-Wno-unused-variable',
-        '-Wno-empty-body',
-        '-Wno-unused-but-set-variable',
-]
+if is_ms_compiler
+    extra_flags = [
+            '/wd4101', # unreferenced local variable
+    ]
+else
+    extra_flags = [
+            '-Wno-sign-compare',
+            '-Wno-unused-parameter',
+            '-Wno-unused-variable',
+            '-Wno-empty-body',
+            '-Wno-unused-but-set-variable',
+    ]
+endif
 
 c_args = cflags
 foreach flag: extra_flags
Signature · 1 line
2.47.0.vfs.0.3
#2 lore raw

Re: [PATCH 1/2] drivers/common: remove unused variables and add MSVC compiler flag

Quoted 19 lines · Andre Muezerie

Removed unused variables and added MSVC specific compiler flag to ignore warnings about unused variables, like is being done for other compilers.

---
 drivers/common/idpf/base/meson.build       | 13 ++++++++++---
 drivers/common/idpf/idpf_common_rxtx.c     |  2 --
 drivers/common/idpf/idpf_common_virtchnl.c |  4 ++--
 drivers/common/sfc_efx/base/efx_mae.c      |  2 +-
 drivers/common/sfc_efx/base/efx_table.c    |  1 -
 drivers/common/sfc_efx/base/meson.build    | 20 +++++++++++++-------
 6 files changed, 26 insertions(+), 16 deletions(-)
drivers/common/idpf/base/meson.build +0 -0
index f30ec7dfc2..c069507f12 100644

drivers/common/idpf/base/meson.build sources += files( · line 12

Quoted 10 lines
drivers/common/idpf/base/meson.build +4 -3
@@ -6,9 +6,16 @@ sources += files(
         'idpf_controlq_setup.c',
 )
 
-error_cflags = [
-        '-Wno-unused-variable',
-]
+if is_ms_compiler
+    error_cflags = [
+            '/wd4101', # unreferenced local variable
+    ]

Just an idea here, since I see this same flag with the same constant appearing multiple times in the patches: Would it be worthwhile defining these MSVC flags as global strings in meson e.g. in a file in the "config" directory. That would then allow them to put in the flags array using meaningful names, and avoid the need for putting in the same comment each time.

if is_ms_compiler
error_cflags = [
msvc_no_unref_local_var
]

If we want to take this a step further, we could define all common error flags across all compilers this way, so that we avoid the need for conditional in each individual meson.build file - we just define the names of the errors we want and let the string replacement handle the conversion to the appropriate compiler flag. The names could be, for example, the gcc/clang error names without the "-W" bit. If no MSVC equivalent they could be empty strings in those builds.

WDYT?

/Bruce

#3 lore raw

PATCH 2/2 drivers/net: remove unused variables and add MSVC compiler flag

In reply to Andre Muezerie

Removed unused variables and added MSVC specific compiler flag to ignore warnings about unused variables, like is being done for other compilers.

---
 drivers/net/ice/base/ice_switch.c  |  2 --
 drivers/net/ice/base/meson.build   | 16 ++++++---
 drivers/net/qede/base/ecore_dcbx.c |  2 --
 drivers/net/qede/base/ecore_mcp.c  |  2 --
 drivers/net/qede/base/meson.build  | 57 +++++++++++++++++-------------
 5 files changed, 43 insertions(+), 36 deletions(-)
drivers/net/ice/base/ice_switch.c +0 -2
index a3786961e6..468a9f055d 100644
@@ -8190,7 +8190,6 @@ ice_add_adv_recipe(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
 	struct ice_sw_recipe *rm;
 	u8 i;
 	int status = ICE_SUCCESS;
-	u16 cnt;
 
 	if (!ice_is_prof_rule(rinfo->tun_type) && !lkups_cnt)
 		return ICE_ERR_PARAM;
@@ -9795,7 +9794,6 @@ ice_rem_adv_rule(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
 	bool remove_rule = false;
 	struct ice_lock *rule_lock; /* Lock to protect filter rule list */
 	u16 i, rid, vsi_handle;
-	bool is_add = false;
 	int status = ICE_SUCCESS;
 
 	ice_memset(&lkup_exts, 0, sizeof(lkup_exts), ICE_NONDMA_MEM);
drivers/net/ice/base/meson.build +11 -5
index addb922ac9..a291d05b93 100644
@@ -31,11 +31,17 @@ sources = [
         'ice_vf_mbx.c',
 ]
 
-error_cflags = [
-        '-Wno-unused-but-set-variable',
-        '-Wno-unused-variable',
-        '-Wno-unused-parameter',
-]
+if is_ms_compiler
+    error_cflags = [
+            '/wd4101', # unreferenced local variable
+    ]
+else
+    error_cflags = [
+            '-Wno-unused-but-set-variable',
+            '-Wno-unused-variable',
+            '-Wno-unused-parameter',
+    ]
+endif
 
 # Bugzilla ID: 678
 if (toolchain == 'gcc' and cc.version().version_compare('>=11.0.0'))
drivers/net/qede/base/ecore_dcbx.c +0 -2
index 31234f18cf..dc4f17ccbb 100644
@@ -421,8 +421,6 @@ ecore_dcbx_get_priority_info(struct ecore_hwfn *p_hwfn,
 			     struct ecore_dcbx_app_prio *p_prio,
 			     struct ecore_dcbx_results *p_results)
 {
-	u8 val;
-
 	if (p_results->arr[DCBX_PROTOCOL_ETH].update &&
 	    p_results->arr[DCBX_PROTOCOL_ETH].enable)
 		p_prio->eth = p_results->arr[DCBX_PROTOCOL_ETH].priority;
drivers/net/qede/base/ecore_mcp.c +0 -2
index ec83b244e6..ccd56a45d9 100644
@@ -1193,7 +1193,6 @@ enum _ecore_status_t ecore_mcp_unload_done(struct ecore_hwfn *p_hwfn,
 					   struct ecore_ptt *p_ptt)
 {
 	struct ecore_mcp_mb_params mb_params;
-	struct mcp_mac wol_mac;
 
 	OSAL_MEM_ZERO(&mb_params, sizeof(mb_params));
 	mb_params.cmd = DRV_MSG_CODE_UNLOAD_DONE;
@@ -2531,7 +2530,6 @@ ecore_mcp_get_shmem_proto_mfw(struct ecore_hwfn *p_hwfn,
 			      enum ecore_pci_personality *p_proto)
 {
 	u32 resp = 0, param = 0;
-	enum _ecore_status_t rc;
 
 	DP_VERBOSE(p_hwfn, ECORE_MSG_IFUP,
 		   "According to capabilities, L2 personality is %08x [resp %08x param %08x]\n",
drivers/net/qede/base/meson.build +32 -25

63 lines not on this page · raw message

Signature · 1 line
2.47.0.vfs.0.3
#4 lore raw

Re: [PATCH 2/2] drivers/net: remove unused variables and add MSVC compiler flag

Quoted 4 lines · On Thu, 26 Dec 2024 10:41:44 -0800 Andre Muezerie…

Removed unused variables and added MSVC specific compiler flag to ignore warnings about unused variables, like is being done for other compilers.

Quoted 8 lines
---
 drivers/net/ice/base/ice_switch.c  |  2 --
 drivers/net/ice/base/meson.build   | 16 ++++++---
 drivers/net/qede/base/ecore_dcbx.c |  2 --
 drivers/net/qede/base/ecore_mcp.c  |  2 --
 drivers/net/qede/base/meson.build  | 57 +++++++++++++++++-------------
 5 files changed, 43 insertions(+), 36 deletions(-)

Makes sense, but this base (ie shared across OS code).
Can't make changes there in general; and requires approval of that PMD maintainer.

#5 lore raw

v2 cover remove unused variables and add MSVC compiler flag

In reply to Andre Muezerie

Removed unused variables and added MSVC specific compiler flag to ignore warnings about unused variables, like is being done for other compilers.

Andre Muezerie (2):
drivers/common: remove unused variables and add MSVC compiler flag drivers/net: add MSVC compiler flag for unused variables

 drivers/common/idpf/base/meson.build       | 13 +++--
 drivers/common/idpf/idpf_common_rxtx.c     |  2 -
 drivers/common/idpf/idpf_common_virtchnl.c |  4 +-
 drivers/common/sfc_efx/base/efx_mae.c      |  2 +-
 drivers/common/sfc_efx/base/efx_table.c    |  1 -
 drivers/common/sfc_efx/base/meson.build    | 20 +++++---
 drivers/net/ice/base/meson.build           | 16 ++++--
 drivers/net/qede/base/meson.build          | 57 ++++++++++++----------
 8 files changed, 69 insertions(+), 46 deletions(-)

--
2.47.0.vfs.0.3

#6 lore raw

PATCH v2 1/2 drivers/common: remove unused variables and add MSVC compiler flag

Removed unused variables and added MSVC specific compiler flag to ignore warnings about unused variables, like is being done for other compilers.

---
 drivers/common/idpf/base/meson.build       | 13 ++++++++++---
 drivers/common/idpf/idpf_common_rxtx.c     |  2 --
 drivers/common/idpf/idpf_common_virtchnl.c |  4 ++--
 drivers/common/sfc_efx/base/efx_mae.c      |  2 +-
 drivers/common/sfc_efx/base/efx_table.c    |  1 -
 drivers/common/sfc_efx/base/meson.build    | 20 +++++++++++++-------
 6 files changed, 26 insertions(+), 16 deletions(-)
drivers/common/idpf/base/meson.build +10 -3
index f30ec7dfc2..c069507f12 100644
@@ -6,9 +6,16 @@ sources += files(
         'idpf_controlq_setup.c',
 )
 
-error_cflags = [
-        '-Wno-unused-variable',
-]
+if is_ms_compiler
+    error_cflags = [
+            '/wd4101', # unreferenced local variable
+    ]
+else
+    error_cflags = [
+            '-Wno-unused-variable',
+    ]
+endif
+
 foreach flag: error_cflags
     if cc.has_argument(flag)
         cflags += flag
drivers/common/idpf/idpf_common_rxtx.c +0 -2
index a04e54ce26..9b17279181 100644
@@ -1178,7 +1178,6 @@ idpf_dp_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	struct rte_mbuf *last_seg = rxq->pkt_last_seg;
 	struct rte_mbuf *rxm;
 	struct rte_mbuf *nmb;
-	struct rte_eth_dev *dev;
 	const uint32_t *ptype_tbl = rxq->adapter->ptype_tbl;
 	uint16_t rx_id = rxq->rx_tail;
 	uint16_t rx_packet_len;
@@ -1310,7 +1309,6 @@ idpf_xmit_cleanup(struct idpf_tx_queue *txq)
 	uint16_t nb_tx_desc = txq->nb_tx_desc;
 	uint16_t desc_to_clean_to;
 	uint16_t nb_tx_to_clean;
-	uint16_t i;
 
 	volatile struct idpf_base_tx_desc *txd = txq->tx_ring;
 
drivers/common/idpf/idpf_common_virtchnl.c +2 -2
index de511da788..0ae1d55d79 100644
@@ -362,7 +362,7 @@ idpf_vc_queue_grps_add(struct idpf_vport *vport,
 {
 	struct idpf_adapter *adapter = vport->adapter;
 	struct idpf_cmd_info args;
-	int size, qg_info_size;
+	int size;
 	int err = -1;
 
 	size = sizeof(*p2p_queue_grps_info) +
@@ -1044,7 +1044,7 @@ int idpf_vc_rxq_config_by_info(struct idpf_vport *vport, struct virtchnl2_rxq_in
 	struct idpf_adapter *adapter = vport->adapter;
 	struct virtchnl2_config_rx_queues *vc_rxqs = NULL;
 	struct idpf_cmd_info args;
-	int size, err, i;
+	int size, err;
 
 	size = sizeof(*vc_rxqs) + (num_qs - 1) *
 		sizeof(struct virtchnl2_rxq_info);
drivers/common/sfc_efx/base/efx_mae.c +1 -1
index 9ae136dcce..1429e7dd0a 100644
@@ -740,7 +740,6 @@ efx_mae_mport_by_pcie_function(
 	__in				uint32_t vf,
 	__out				efx_mport_sel_t *mportp)
 {
-	efx_dword_t dword;
 	efx_rc_t rc;
 
 	rc = efx_mae_mport_by_pcie_mh_function(EFX_PCIE_INTERFACE_CALLER,
@@ -4280,6 +4279,7 @@ efx_mae_action_set_replay(
 	__out			efx_mae_actions_t **spec_clonep)
 {
 	const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
+	(void)encp;
 	efx_mae_actions_t *spec_clone;
 	efx_rc_t rc;
 
drivers/common/sfc_efx/base/efx_table.c +0 -1
index 13a12a116e..50e9a37d1c 100644
@@ -240,7 +240,6 @@ efx_table_describe(
 	const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
 	unsigned int n_entries;
 	efx_mcdi_req_t req;
-	unsigned int i;
 	efx_rc_t rc;
 	EFX_MCDI_DECLARE_BUF(payload,
 	    MC_CMD_TABLE_DESCRIPTOR_IN_LEN,
drivers/common/sfc_efx/base/meson.build +13 -7
index 7fc04aa57b..c8deb4555e 100644
@@ -66,13 +66,19 @@ sources = [
         'rhead_virtio.c',
 ]
 
-extra_flags = [
-        '-Wno-sign-compare',
-        '-Wno-unused-parameter',
-        '-Wno-unused-variable',
-        '-Wno-empty-body',
-        '-Wno-unused-but-set-variable',
-]
+if is_ms_compiler
+    extra_flags = [
+            '/wd4101', # unreferenced local variable
+    ]
+else
+    extra_flags = [
+            '-Wno-sign-compare',
+            '-Wno-unused-parameter',
+            '-Wno-unused-variable',
+            '-Wno-empty-body',
+            '-Wno-unused-but-set-variable',
+    ]
+endif
 
 c_args = cflags
 foreach flag: extra_flags
Signature · 1 line
2.47.0.vfs.0.3
#7 lore raw

PATCH v2 2/2 drivers/net: add MSVC compiler flag for unused variables

In reply to Andre Muezerie

Added MSVC specific compiler flag to ignore warnings about unused variables, like is being done for other compilers.

---
 drivers/net/ice/base/meson.build  | 16 ++++++---
 drivers/net/qede/base/meson.build | 57 +++++++++++++++++--------------
 2 files changed, 43 insertions(+), 30 deletions(-)
drivers/net/ice/base/meson.build +11 -5
index addb922ac9..a291d05b93 100644
@@ -31,11 +31,17 @@ sources = [
         'ice_vf_mbx.c',
 ]
 
-error_cflags = [
-        '-Wno-unused-but-set-variable',
-        '-Wno-unused-variable',
-        '-Wno-unused-parameter',
-]
+if is_ms_compiler
+    error_cflags = [
+            '/wd4101', # unreferenced local variable
+    ]
+else
+    error_cflags = [
+            '-Wno-unused-but-set-variable',
+            '-Wno-unused-variable',
+            '-Wno-unused-parameter',
+    ]
+endif
 
 # Bugzilla ID: 678
 if (toolchain == 'gcc' and cc.version().version_compare('>=11.0.0'))
drivers/net/qede/base/meson.build +32 -25

63 lines not on this page · raw message

Signature · 1 line
2.47.0.vfs.0.3
#8 lore raw

Re: [PATCH v2 2/2] drivers/net: add MSVC compiler flag for unused variables

Quoted 4 lines · On Tue, 14 Jan 2025 12:46:51 -0800 Andre Muezerie…

Added MSVC specific compiler flag to ignore warnings about unused variables, like is being done for other compilers.

This patch series needs rebase now that Intel drivers got reorganized.

#9 lore raw

Re: [PATCH v2 2/2] drivers/net: add MSVC compiler flag for unused variables

Quoted 9 lines · Stephen Hemminger
Quoted 4 lines · On Tue, 14 Jan 2025 12:46:51 -0800 Andre Muezerie…

Added MSVC specific compiler flag to ignore warnings about unused variables, like is being done for other compilers.

This patch series needs rebase now that Intel drivers got reorganized.

Thanks for letting me know Stephen.
I sent out a rebased v3 of the series.

#10 lore raw

v3 cover remove unused variables and add MSVC compiler flag

In reply to Andre Muezerie

v3:
* rebased.

Removed unused variables and added MSVC specific compiler flag to ignore warnings about unused variables, like is being done for other compilers.

Andre Muezerie (2):
drivers/common: remove unused variables and add MSVC compiler flag drivers/net: add MSVC compiler flag for unused variables

 drivers/common/idpf/base/meson.build       | 13 +++--
 drivers/common/idpf/idpf_common_rxtx.c     |  2 -
 drivers/common/idpf/idpf_common_virtchnl.c |  4 +-
 drivers/common/sfc_efx/base/efx_mae.c      |  2 +-
 drivers/common/sfc_efx/base/efx_table.c    |  1 -
 drivers/common/sfc_efx/base/meson.build    | 20 +++++---
 drivers/net/qede/base/meson.build          | 57 ++++++++++++----------
 7 files changed, 58 insertions(+), 41 deletions(-)

--
2.47.2.vfs.0.1

#11 lore raw

PATCH v3 1/2 drivers/common: remove unused variables and add MSVC compiler flag

Removed unused variables and added MSVC specific compiler flag to ignore warnings about unused variables, like is being done for other compilers.

---
 drivers/common/idpf/base/meson.build       | 13 ++++++++++---
 drivers/common/idpf/idpf_common_rxtx.c     |  2 --
 drivers/common/idpf/idpf_common_virtchnl.c |  4 ++--
 drivers/common/sfc_efx/base/efx_mae.c      |  2 +-
 drivers/common/sfc_efx/base/efx_table.c    |  1 -
 drivers/common/sfc_efx/base/meson.build    | 20 +++++++++++++-------
 6 files changed, 26 insertions(+), 16 deletions(-)
drivers/common/idpf/base/meson.build +10 -3
index f30ec7dfc2..c069507f12 100644
@@ -6,9 +6,16 @@ sources += files(
         'idpf_controlq_setup.c',
 )
 
-error_cflags = [
-        '-Wno-unused-variable',
-]
+if is_ms_compiler
+    error_cflags = [
+            '/wd4101', # unreferenced local variable
+    ]
+else
+    error_cflags = [
+            '-Wno-unused-variable',
+    ]
+endif
+
 foreach flag: error_cflags
     if cc.has_argument(flag)
         cflags += flag
drivers/common/idpf/idpf_common_rxtx.c +0 -2
index a04e54ce26..9b17279181 100644
@@ -1178,7 +1178,6 @@ idpf_dp_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	struct rte_mbuf *last_seg = rxq->pkt_last_seg;
 	struct rte_mbuf *rxm;
 	struct rte_mbuf *nmb;
-	struct rte_eth_dev *dev;
 	const uint32_t *ptype_tbl = rxq->adapter->ptype_tbl;
 	uint16_t rx_id = rxq->rx_tail;
 	uint16_t rx_packet_len;
@@ -1310,7 +1309,6 @@ idpf_xmit_cleanup(struct idpf_tx_queue *txq)
 	uint16_t nb_tx_desc = txq->nb_tx_desc;
 	uint16_t desc_to_clean_to;
 	uint16_t nb_tx_to_clean;
-	uint16_t i;
 
 	volatile struct idpf_base_tx_desc *txd = txq->tx_ring;
 
drivers/common/idpf/idpf_common_virtchnl.c +2 -2
index de511da788..0ae1d55d79 100644
@@ -362,7 +362,7 @@ idpf_vc_queue_grps_add(struct idpf_vport *vport,
 {
 	struct idpf_adapter *adapter = vport->adapter;
 	struct idpf_cmd_info args;
-	int size, qg_info_size;
+	int size;
 	int err = -1;
 
 	size = sizeof(*p2p_queue_grps_info) +
@@ -1044,7 +1044,7 @@ int idpf_vc_rxq_config_by_info(struct idpf_vport *vport, struct virtchnl2_rxq_in
 	struct idpf_adapter *adapter = vport->adapter;
 	struct virtchnl2_config_rx_queues *vc_rxqs = NULL;
 	struct idpf_cmd_info args;
-	int size, err, i;
+	int size, err;
 
 	size = sizeof(*vc_rxqs) + (num_qs - 1) *
 		sizeof(struct virtchnl2_rxq_info);
drivers/common/sfc_efx/base/efx_mae.c +1 -1
index 9ae136dcce..1429e7dd0a 100644
@@ -740,7 +740,6 @@ efx_mae_mport_by_pcie_function(
 	__in				uint32_t vf,
 	__out				efx_mport_sel_t *mportp)
 {
-	efx_dword_t dword;
 	efx_rc_t rc;
 
 	rc = efx_mae_mport_by_pcie_mh_function(EFX_PCIE_INTERFACE_CALLER,
@@ -4280,6 +4279,7 @@ efx_mae_action_set_replay(
 	__out			efx_mae_actions_t **spec_clonep)
 {
 	const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
+	(void)encp;
 	efx_mae_actions_t *spec_clone;
 	efx_rc_t rc;
 
drivers/common/sfc_efx/base/efx_table.c +0 -1
index 13a12a116e..50e9a37d1c 100644
@@ -240,7 +240,6 @@ efx_table_describe(
 	const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
 	unsigned int n_entries;
 	efx_mcdi_req_t req;
-	unsigned int i;
 	efx_rc_t rc;
 	EFX_MCDI_DECLARE_BUF(payload,
 	    MC_CMD_TABLE_DESCRIPTOR_IN_LEN,
drivers/common/sfc_efx/base/meson.build +13 -7
index 7fc04aa57b..c8deb4555e 100644
@@ -66,13 +66,19 @@ sources = [
         'rhead_virtio.c',
 ]
 
-extra_flags = [
-        '-Wno-sign-compare',
-        '-Wno-unused-parameter',
-        '-Wno-unused-variable',
-        '-Wno-empty-body',
-        '-Wno-unused-but-set-variable',
-]
+if is_ms_compiler
+    extra_flags = [
+            '/wd4101', # unreferenced local variable
+    ]
+else
+    extra_flags = [
+            '-Wno-sign-compare',
+            '-Wno-unused-parameter',
+            '-Wno-unused-variable',
+            '-Wno-empty-body',
+            '-Wno-unused-but-set-variable',
+    ]
+endif
 
 c_args = cflags
 foreach flag: extra_flags
Signature · 1 line
2.47.2.vfs.0.1
#12 lore raw

PATCH v3 2/2 drivers/net: add MSVC compiler flag for unused variables

In reply to Andre Muezerie

Added MSVC specific compiler flag to ignore warnings about unused variables, like is being done for other compilers.

---
 drivers/net/qede/base/meson.build | 57 +++++++++++++++++--------------
 1 file changed, 32 insertions(+), 25 deletions(-)
drivers/net/qede/base/meson.build +32 -25
index 4ad177b478..66251360bf 100644
@@ -19,31 +19,38 @@ sources = [
 ]
 
 
-error_cflags = [
-        '-Wno-unused-parameter',
-        '-Wno-sign-compare',
-        '-Wno-missing-prototypes',
-        '-Wno-cast-qual',
-        '-Wno-unused-function',
-        '-Wno-unused-variable',
-        '-Wno-strict-aliasing',
-        '-Wno-missing-prototypes',
-        '-Wno-unused-value',
-        '-Wno-format-nonliteral',
-        '-Wno-shift-negative-value',
-        '-Wno-unused-but-set-variable',
-        '-Wno-missing-declarations',
-        '-Wno-maybe-uninitialized',
-        '-Wno-strict-prototypes',
-        '-Wno-shift-negative-value',
-        '-Wno-implicit-fallthrough',
-        '-Wno-format-extra-args',
-        '-Wno-visibility',
-        '-Wno-empty-body',
-        '-Wno-invalid-source-encoding',
-        '-Wno-sometimes-uninitialized',
-        '-Wno-pointer-bool-conversion',
-]
+if is_ms_compiler
+        error_cflags = [
+                '/wd4101', # unreferenced local variable
+        ]
+else
+        error_cflags = [
+                '-Wno-unused-parameter',
+                '-Wno-sign-compare',
+                '-Wno-missing-prototypes',
+                '-Wno-cast-qual',
+                '-Wno-unused-function',
+                '-Wno-unused-variable',
+                '-Wno-strict-aliasing',
+                '-Wno-missing-prototypes',
+                '-Wno-unused-value',
+                '-Wno-format-nonliteral',
+                '-Wno-shift-negative-value',
+                '-Wno-unused-but-set-variable',
+                '-Wno-missing-declarations',
+                '-Wno-maybe-uninitialized',
+                '-Wno-strict-prototypes',
+                '-Wno-shift-negative-value',
+                '-Wno-implicit-fallthrough',
+                '-Wno-format-extra-args',
+                '-Wno-visibility',
+                '-Wno-empty-body',
+                '-Wno-invalid-source-encoding',
+                '-Wno-sometimes-uninitialized',
+                '-Wno-pointer-bool-conversion',
+        ]
+endif
+
 c_args = cflags
 foreach flag: error_cflags
         if cc.has_argument(flag)
Signature · 1 line
2.47.2.vfs.0.1