Blame SOURCES/0004-ethtool-Fix-compilation-warning-when-pretty-dump-is-.patch

2a1b01
From 3960c91ade7b1ca9979eec5200a90dc11f339cfd Mon Sep 17 00:00:00 2001
2a1b01
From: Ido Schimmel <idosch@nvidia.com>
2a1b01
Date: Tue, 14 Sep 2021 14:27:37 +0300
2a1b01
Subject: [PATCH 04/35] ethtool: Fix compilation warning when pretty dump is
2a1b01
 disabled
2a1b01
MIME-Version: 1.0
2a1b01
Content-Type: text/plain; charset=UTF-8
2a1b01
Content-Transfer-Encoding: 8bit
2a1b01
2a1b01
When pretty dump is disabled (i.e., configure --disable-pretty-dump),
2a1b01
gcc 11.2.1 emits the following warning:
2a1b01
2a1b01
ethtool.c: In function ‘dump_regs’:
2a1b01
ethtool.c:1160:31: warning: comparison is always false due to limited range of data type [-Wtype-limits]
2a1b01
 1160 |                 for (i = 0; i < ARRAY_SIZE(driver_list); i++)
2a1b01
      |                               ^
2a1b01
2a1b01
Fix it by avoiding iterating over 'driver_list' when pretty dump is
2a1b01
disabled.
2a1b01
2a1b01
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2a1b01
---
2a1b01
 ethtool.c | 13 ++++++++-----
2a1b01
 1 file changed, 8 insertions(+), 5 deletions(-)
2a1b01
2a1b01
diff --git a/ethtool.c b/ethtool.c
2a1b01
index 33a0a492cb15..1b79e9f8d958 100644
2a1b01
--- a/ethtool.c
2a1b01
+++ b/ethtool.c
2a1b01
@@ -1089,12 +1089,12 @@ static int parse_hkey(char **rss_hkey, u32 key_size,
2a1b01
 	return 0;
2a1b01
 }
2a1b01
 
2a1b01
+#ifdef ETHTOOL_ENABLE_PRETTY_DUMP
2a1b01
 static const struct {
2a1b01
 	const char *name;
2a1b01
 	int (*func)(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
2a1b01
 
2a1b01
 } driver_list[] = {
2a1b01
-#ifdef ETHTOOL_ENABLE_PRETTY_DUMP
2a1b01
 	{ "8139cp", realtek_dump_regs },
2a1b01
 	{ "8139too", realtek_dump_regs },
2a1b01
 	{ "r8169", realtek_dump_regs },
2a1b01
@@ -1129,8 +1129,8 @@ static const struct {
2a1b01
 	{ "fec", fec_dump_regs },
2a1b01
 	{ "igc", igc_dump_regs },
2a1b01
 	{ "bnxt_en", bnxt_dump_regs },
2a1b01
-#endif
2a1b01
 };
2a1b01
+#endif
2a1b01
 
2a1b01
 void dump_hex(FILE *file, const u8 *data, int len, int offset)
2a1b01
 {
2a1b01
@@ -1149,14 +1149,15 @@ void dump_hex(FILE *file, const u8 *data, int len, int offset)
2a1b01
 static int dump_regs(int gregs_dump_raw, int gregs_dump_hex,
2a1b01
 		     struct ethtool_drvinfo *info, struct ethtool_regs *regs)
2a1b01
 {
2a1b01
-	unsigned int i;
2a1b01
-
2a1b01
 	if (gregs_dump_raw) {
2a1b01
 		fwrite(regs->data, regs->len, 1, stdout);
2a1b01
 		goto nested;
2a1b01
 	}
2a1b01
 
2a1b01
-	if (!gregs_dump_hex)
2a1b01
+#ifdef ETHTOOL_ENABLE_PRETTY_DUMP
2a1b01
+	if (!gregs_dump_hex) {
2a1b01
+		unsigned int i;
2a1b01
+
2a1b01
 		for (i = 0; i < ARRAY_SIZE(driver_list); i++)
2a1b01
 			if (!strncmp(driver_list[i].name, info->driver,
2a1b01
 				     ETHTOOL_BUSINFO_LEN)) {
2a1b01
@@ -1168,6 +1169,8 @@ static int dump_regs(int gregs_dump_raw, int gregs_dump_hex,
2a1b01
 				 */
2a1b01
 				break;
2a1b01
 			}
2a1b01
+	}
2a1b01
+#endif
2a1b01
 
2a1b01
 	dump_hex(stdout, regs->data, regs->len, 0);
2a1b01
 
2a1b01
-- 
2a1b01
2.35.1
2a1b01