[v2,04/54] net/e1000/base: remove unused parameter workaround

Message ID 39c610c0d023b0e5a24d973b92b0c75896ee6723.1738681726.git.anatoly.burakov@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Bruce Richardson
Headers
Series Merge Intel IGC and E1000 drivers, and update E1000 base code |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Burakov, Anatoly Feb. 4, 2025, 3:10 p.m. UTC
Currently, e1000 base code is compiled with removing warning for unused
parameters. The e1000 codebase does define a few macros to suppress
unused parameters explicitly and dilligently uses them where they are
needed, but the definitions for these macros are empty in e1000 osdep
file, which is probably the reason why the workaround for the warning was
added in the first place.

We address that by making them meaningful by using RTE_SET_USED macro, so
that we can use them for their intended purposes. The meson file workaround
can now be removed. After removing the workaround, there is a bunch of
warnings coming from osdep.c file, so fix those too.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 drivers/net/intel/e1000/base/e1000_osdep.c | 10 ++++++---
 drivers/net/intel/e1000/base/e1000_osdep.h | 26 +++++++++++++++++-----
 drivers/net/intel/e1000/base/meson.build   | 12 +---------
 3 files changed, 29 insertions(+), 19 deletions(-)
  

Patch

diff --git a/drivers/net/intel/e1000/base/e1000_osdep.c b/drivers/net/intel/e1000/base/e1000_osdep.c
index 55265931b9..23f9556fd8 100644
--- a/drivers/net/intel/e1000/base/e1000_osdep.c
+++ b/drivers/net/intel/e1000/base/e1000_osdep.c
@@ -6,7 +6,7 @@ 
 #include "e1000_api.h"
 
 /*
- * NOTE: the following routines using the e1000 
+ * NOTE: the following routines using the e1000
  * 	naming style are provided to the shared
  *	code but are OS specific
  */
@@ -14,24 +14,26 @@ 
 void
 e1000_write_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value)
 {
-	return;
+	UNREFERENCED_3PARAMETER(hw, reg, value);
 }
 
 void
 e1000_read_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value)
 {
+	UNREFERENCED_2PARAMETER(hw, reg);
 	*value = 0;
-	return;
 }
 
 void
 e1000_pci_set_mwi(struct e1000_hw *hw)
 {
+	UNREFERENCED_1PARAMETER(hw);
 }
 
 void
 e1000_pci_clear_mwi(struct e1000_hw *hw)
 {
+	UNREFERENCED_1PARAMETER(hw);
 }
 
 
@@ -41,6 +43,7 @@  e1000_pci_clear_mwi(struct e1000_hw *hw)
 int32_t
 e1000_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value)
 {
+	UNREFERENCED_3PARAMETER(hw, reg, value);
 	return E1000_NOT_IMPLEMENTED;
 }
 
@@ -50,5 +53,6 @@  e1000_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value)
 int32_t
 e1000_write_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value)
 {
+	UNREFERENCED_3PARAMETER(hw, reg, value);
 	return E1000_NOT_IMPLEMENTED;
 }
diff --git a/drivers/net/intel/e1000/base/e1000_osdep.h b/drivers/net/intel/e1000/base/e1000_osdep.h
index 0cf6da1545..7b29a526b4 100644
--- a/drivers/net/intel/e1000/base/e1000_osdep.h
+++ b/drivers/net/intel/e1000/base/e1000_osdep.h
@@ -35,12 +35,28 @@ 
 #define DEBUGOUT7(S, ...)       DEBUGOUT(S, ##__VA_ARGS__)
 
 #ifndef UNREFERENCED_PARAMETER
-#define UNREFERENCED_PARAMETER(_p)
+#define UNREFERENCED_PARAMETER(_p) do { \
+	RTE_SET_USED(_p); \
+} while (0)
 #endif
-#define UNREFERENCED_1PARAMETER(_p)
-#define UNREFERENCED_2PARAMETER(_p, _q)
-#define UNREFERENCED_3PARAMETER(_p, _q, _r)
-#define UNREFERENCED_4PARAMETER(_p, _q, _r, _s)
+#define UNREFERENCED_1PARAMETER(_p) do { \
+	RTE_SET_USED(_p); \
+} while (0)
+#define UNREFERENCED_2PARAMETER(_p, _q) do { \
+	RTE_SET_USED(_p); \
+	RTE_SET_USED(_q); \
+} while (0)
+#define UNREFERENCED_3PARAMETER(_p, _q, _r) do { \
+	RTE_SET_USED(_p); \
+	RTE_SET_USED(_q); \
+	RTE_SET_USED(_r); \
+} while (0)
+#define UNREFERENCED_4PARAMETER(_p, _q, _r, _s) do { \
+	RTE_SET_USED(_p); \
+	RTE_SET_USED(_q); \
+	RTE_SET_USED(_r); \
+	RTE_SET_USED(_s); \
+} while (0)
 
 #define FALSE			0
 #define TRUE			1
diff --git a/drivers/net/intel/e1000/base/meson.build b/drivers/net/intel/e1000/base/meson.build
index 033b3af2e2..8cbd9f62e6 100644
--- a/drivers/net/intel/e1000/base/meson.build
+++ b/drivers/net/intel/e1000/base/meson.build
@@ -23,17 +23,7 @@  sources = [
         'e1000_vf.c',
 ]
 
-error_cflags = [
-        '-Wno-unused-parameter',
-]
-c_args = cflags
-foreach flag: error_cflags
-    if cc.has_argument(flag)
-        c_args += flag
-    endif
-endforeach
-
 base_lib = static_library('e1000_base', sources,
     dependencies: static_rte_eal,
-    c_args: c_args)
+    c_args: cflags)
 base_objs = base_lib.extract_all_objects(recursive: true)