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

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