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

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