Blame SOURCES/0007-ioctl-get-rid-of-signed-unsigned-comparison-warnings.patch

83ef35
From 4be3e49856ef6c4f09f2230bbcf40cb7492313ca Mon Sep 17 00:00:00 2001
83ef35
From: Michal Kubecek <mkubecek@suse.cz>
83ef35
Date: Sun, 23 Aug 2020 21:40:30 +0200
83ef35
Subject: [PATCH 07/17] ioctl: get rid of signed/unsigned comparison warnings
83ef35
83ef35
Comparison between signed and unsigned values is fragile and causes
83ef35
compiler warnings with recent compilers and stricter CFLAGS. Prevent such
83ef35
comparisons either by properly declaring variables (mostly loop iterators)
83ef35
as unsigned or by explicitly casting one side of the comparison.
83ef35
83ef35
v2: rework argc related changes and split them into a separate patch
83ef35
83ef35
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
83ef35
(cherry picked from commit f2f0fca943ffa25458865e4187690c9c7d6a89bc)
83ef35
---
83ef35
 ethtool.c | 31 +++++++++++++++++--------------
83ef35
 1 file changed, 17 insertions(+), 14 deletions(-)
83ef35
83ef35
diff --git a/ethtool.c b/ethtool.c
83ef35
index 7c7e98957c80..3c30824016d5 100644
83ef35
--- a/ethtool.c
83ef35
+++ b/ethtool.c
83ef35
@@ -641,8 +641,9 @@ static void dump_link_caps(const char *prefix, const char *an_prefix,
83ef35
 		  "200000baseCR4/Full" },
83ef35
 	};
83ef35
 	int indent;
83ef35
-	int did1, new_line_pend, i;
83ef35
+	int did1, new_line_pend;
83ef35
 	int fecreported = 0;
83ef35
+	unsigned int i;
83ef35
 
83ef35
 	/* Indent just like the separate functions used to */
83ef35
 	indent = strlen(prefix) + 14;
83ef35
@@ -1071,7 +1072,7 @@ void dump_hex(FILE *file, const u8 *data, int len, int offset)
83ef35
 static int dump_regs(int gregs_dump_raw, int gregs_dump_hex,
83ef35
 		     struct ethtool_drvinfo *info, struct ethtool_regs *regs)
83ef35
 {
83ef35
-	int i;
83ef35
+	unsigned int i;
83ef35
 
83ef35
 	if (gregs_dump_raw) {
83ef35
 		fwrite(regs->data, regs->len, 1, stdout);
83ef35
@@ -1128,7 +1129,8 @@ static int dump_eeprom(int geeprom_dump_raw,
83ef35
 static int dump_test(struct ethtool_test *test,
83ef35
 		     struct ethtool_gstrings *strings)
83ef35
 {
83ef35
-	int i, rc;
83ef35
+	unsigned int i;
83ef35
+	int rc;
83ef35
 
83ef35
 	rc = test->flags & ETH_TEST_FL_FAILED;
83ef35
 	fprintf(stdout, "The test result is %s\n", rc ? "FAIL" : "PASS");
83ef35
@@ -1359,7 +1361,7 @@ static void dump_one_feature(const char *indent, const char *name,
83ef35
 	       : "");
83ef35
 }
83ef35
 
83ef35
-static int linux_version_code(void)
83ef35
+static unsigned int linux_version_code(void)
83ef35
 {
83ef35
 	struct utsname utsname;
83ef35
 	unsigned version, patchlevel, sublevel = 0;
83ef35
@@ -1375,10 +1377,10 @@ static void dump_features(const struct feature_defs *defs,
83ef35
 			  const struct feature_state *state,
83ef35
 			  const struct feature_state *ref_state)
83ef35
 {
83ef35
-	int kernel_ver = linux_version_code();
83ef35
-	u32 value;
83ef35
+	unsigned int kernel_ver = linux_version_code();
83ef35
+	unsigned int i, j;
83ef35
 	int indent;
83ef35
-	int i, j;
83ef35
+	u32 value;
83ef35
 
83ef35
 	for (i = 0; i < OFF_FLAG_DEF_SIZE; i++) {
83ef35
 		/* Don't show features whose state is unknown on this
83ef35
@@ -1411,7 +1413,7 @@ static void dump_features(const struct feature_defs *defs,
83ef35
 
83ef35
 		/* Show matching features */
83ef35
 		for (j = 0; j < defs->n_features; j++) {
83ef35
-			if (defs->def[j].off_flag_index != i)
83ef35
+			if (defs->def[j].off_flag_index != (int)i)
83ef35
 				continue;
83ef35
 			if (defs->off_flag_matched[i] != 1)
83ef35
 				/* Show all matching feature states */
83ef35
@@ -1668,8 +1670,8 @@ static struct feature_defs *get_feature_defs(struct cmd_context *ctx)
83ef35
 {
83ef35
 	struct ethtool_gstrings *names;
83ef35
 	struct feature_defs *defs;
83ef35
+	unsigned int i, j;
83ef35
 	u32 n_features;
83ef35
-	int i, j;
83ef35
 
83ef35
 	names = get_stringset(ctx, ETH_SS_FEATURES, 0, 1);
83ef35
 	if (names) {
83ef35
@@ -2236,8 +2238,8 @@ static int do_sfeatures(struct cmd_context *ctx)
83ef35
 	struct cmdline_info *cmdline_features;
83ef35
 	struct feature_state *old_state, *new_state;
83ef35
 	struct ethtool_value eval;
83ef35
+	unsigned int i, j;
83ef35
 	int err, rc;
83ef35
-	int i, j;
83ef35
 
83ef35
 	defs = get_feature_defs(ctx);
83ef35
 	if (!defs) {
83ef35
@@ -2317,7 +2319,7 @@ static int do_sfeatures(struct cmd_context *ctx)
83ef35
 				continue;
83ef35
 
83ef35
 			for (j = 0; j < defs->n_features; j++) {
83ef35
-				if (defs->def[j].off_flag_index != i ||
83ef35
+				if (defs->def[j].off_flag_index != (int)i ||
83ef35
 				    !FEATURE_BIT_IS_SET(
83ef35
 					    old_state->features.features,
83ef35
 					    j, available) ||
83ef35
@@ -3869,7 +3871,7 @@ static int do_srxfh(struct cmd_context *ctx)
83ef35
 	char *hfunc_name = NULL;
83ef35
 	char *hkey = NULL;
83ef35
 	int err = 0;
83ef35
-	int i;
83ef35
+	unsigned int i;
83ef35
 	u32 arg_num = 0, indir_bytes = 0;
83ef35
 	u32 req_hfunc = 0;
83ef35
 	u32 entry_size = sizeof(rss_head.rss_config[0]);
83ef35
@@ -4135,7 +4137,8 @@ static int do_flash(struct cmd_context *ctx)
83ef35
 
83ef35
 static int do_permaddr(struct cmd_context *ctx)
83ef35
 {
83ef35
-	int i, err;
83ef35
+	unsigned int i;
83ef35
+	int err;
83ef35
 	struct ethtool_perm_addr *epaddr;
83ef35
 
83ef35
 	epaddr = malloc(sizeof(struct ethtool_perm_addr) + MAX_ADDR_LEN);
83ef35
@@ -4750,7 +4753,7 @@ static int do_stunable(struct cmd_context *ctx)
83ef35
 	struct cmdline_info cmdline_tunable[TUNABLES_INFO_SIZE];
83ef35
 	struct ethtool_tunable_info *tinfo = tunables_info;
83ef35
 	int changed = 0;
83ef35
-	int i;
83ef35
+	unsigned int i;
83ef35
 
83ef35
 	for (i = 0; i < TUNABLES_INFO_SIZE; i++) {
83ef35
 		cmdline_tunable[i].name = tunable_strings[tinfo[i].t_id];
83ef35
-- 
83ef35
2.26.2
83ef35