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