|
|
4f6fcd |
From 7e3888aeb31d2920c3c282b135563a06c3bcf6e1 Mon Sep 17 00:00:00 2001
|
|
|
4f6fcd |
From: Michal Kubecek <mkubecek@suse.cz>
|
|
|
4f6fcd |
Date: Sun, 23 Aug 2020 21:40:27 +0200
|
|
|
4f6fcd |
Subject: [PATCH 06/17] ioctl: make argc counters unsigned
|
|
|
4f6fcd |
|
|
|
4f6fcd |
Use unsigned int for cmd_context::argc and local variables used for
|
|
|
4f6fcd |
command line argument count. These counters may never get negative and are
|
|
|
4f6fcd |
often compared to unsigned expressions.
|
|
|
4f6fcd |
|
|
|
4f6fcd |
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
|
|
|
4f6fcd |
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
|
|
4f6fcd |
(cherry picked from commit 519f95bd59034e672cfbac70ca8d7badc4f26cc7)
|
|
|
4f6fcd |
---
|
|
|
4f6fcd |
ethtool.c | 24 ++++++++++++------------
|
|
|
4f6fcd |
internal.h | 2 +-
|
|
|
4f6fcd |
2 files changed, 13 insertions(+), 13 deletions(-)
|
|
|
4f6fcd |
|
|
|
4f6fcd |
diff --git a/ethtool.c b/ethtool.c
|
|
|
4f6fcd |
index 6c12452be7b4..7c7e98957c80 100644
|
|
|
4f6fcd |
--- a/ethtool.c
|
|
|
4f6fcd |
+++ b/ethtool.c
|
|
|
4f6fcd |
@@ -223,9 +223,9 @@ static void parse_generic_cmdline(struct cmd_context *ctx,
|
|
|
4f6fcd |
struct cmdline_info *info,
|
|
|
4f6fcd |
unsigned int n_info)
|
|
|
4f6fcd |
{
|
|
|
4f6fcd |
- int argc = ctx->argc;
|
|
|
4f6fcd |
+ unsigned int argc = ctx->argc;
|
|
|
4f6fcd |
char **argp = ctx->argp;
|
|
|
4f6fcd |
- int i, idx;
|
|
|
4f6fcd |
+ unsigned int i, idx;
|
|
|
4f6fcd |
int found;
|
|
|
4f6fcd |
|
|
|
4f6fcd |
for (i = 0; i < argc; i++) {
|
|
|
4f6fcd |
@@ -2724,9 +2724,9 @@ static int do_sset(struct cmd_context *ctx)
|
|
|
4f6fcd |
u32 msglvl_wanted = 0;
|
|
|
4f6fcd |
u32 msglvl_mask = 0;
|
|
|
4f6fcd |
struct cmdline_info cmdline_msglvl[n_flags_msglvl];
|
|
|
4f6fcd |
- int argc = ctx->argc;
|
|
|
4f6fcd |
+ unsigned int argc = ctx->argc;
|
|
|
4f6fcd |
char **argp = ctx->argp;
|
|
|
4f6fcd |
- int i;
|
|
|
4f6fcd |
+ unsigned int i;
|
|
|
4f6fcd |
int err = 0;
|
|
|
4f6fcd |
|
|
|
4f6fcd |
for (i = 0; i < n_flags_msglvl; i++)
|
|
|
4f6fcd |
@@ -3671,7 +3671,7 @@ static int do_grxfh(struct cmd_context *ctx)
|
|
|
4f6fcd |
struct ethtool_rxfh *rss;
|
|
|
4f6fcd |
u32 rss_context = 0;
|
|
|
4f6fcd |
u32 i, indir_bytes;
|
|
|
4f6fcd |
- int arg_num = 0;
|
|
|
4f6fcd |
+ unsigned int arg_num = 0;
|
|
|
4f6fcd |
char *hkey;
|
|
|
4f6fcd |
int err;
|
|
|
4f6fcd |
|
|
|
4f6fcd |
@@ -4832,9 +4832,8 @@ static int do_gtunable(struct cmd_context *ctx)
|
|
|
4f6fcd |
{
|
|
|
4f6fcd |
struct ethtool_tunable_info *tinfo = tunables_info;
|
|
|
4f6fcd |
char **argp = ctx->argp;
|
|
|
4f6fcd |
- int argc = ctx->argc;
|
|
|
4f6fcd |
- int i;
|
|
|
4f6fcd |
- int j;
|
|
|
4f6fcd |
+ unsigned int argc = ctx->argc;
|
|
|
4f6fcd |
+ unsigned int i, j;
|
|
|
4f6fcd |
|
|
|
4f6fcd |
if (argc < 1)
|
|
|
4f6fcd |
exit_bad_args();
|
|
|
4f6fcd |
@@ -4876,7 +4875,7 @@ static int do_gtunable(struct cmd_context *ctx)
|
|
|
4f6fcd |
|
|
|
4f6fcd |
static int do_get_phy_tunable(struct cmd_context *ctx)
|
|
|
4f6fcd |
{
|
|
|
4f6fcd |
- int argc = ctx->argc;
|
|
|
4f6fcd |
+ unsigned int argc = ctx->argc;
|
|
|
4f6fcd |
char **argp = ctx->argp;
|
|
|
4f6fcd |
|
|
|
4f6fcd |
if (argc < 1)
|
|
|
4f6fcd |
@@ -4980,9 +4979,9 @@ static int do_reset(struct cmd_context *ctx)
|
|
|
4f6fcd |
{
|
|
|
4f6fcd |
struct ethtool_value resetinfo;
|
|
|
4f6fcd |
__u32 data;
|
|
|
4f6fcd |
- int argc = ctx->argc;
|
|
|
4f6fcd |
+ unsigned int argc = ctx->argc;
|
|
|
4f6fcd |
char **argp = ctx->argp;
|
|
|
4f6fcd |
- int i;
|
|
|
4f6fcd |
+ unsigned int i;
|
|
|
4f6fcd |
|
|
|
4f6fcd |
if (argc == 0)
|
|
|
4f6fcd |
exit_bad_args();
|
|
|
4f6fcd |
@@ -5270,7 +5269,8 @@ static int do_sfec(struct cmd_context *ctx)
|
|
|
4f6fcd |
enum { ARG_NONE, ARG_ENCODING } state = ARG_NONE;
|
|
|
4f6fcd |
struct ethtool_fecparam feccmd;
|
|
|
4f6fcd |
int fecmode = 0, newmode;
|
|
|
4f6fcd |
- int rv, i;
|
|
|
4f6fcd |
+ unsigned int i;
|
|
|
4f6fcd |
+ int rv;
|
|
|
4f6fcd |
|
|
|
4f6fcd |
for (i = 0; i < ctx->argc; i++) {
|
|
|
4f6fcd |
if (!strcmp(ctx->argp[i], "encoding")) {
|
|
|
4f6fcd |
diff --git a/internal.h b/internal.h
|
|
|
4f6fcd |
index 8ae1efab5b5c..d096a28abfa2 100644
|
|
|
4f6fcd |
--- a/internal.h
|
|
|
4f6fcd |
+++ b/internal.h
|
|
|
4f6fcd |
@@ -221,7 +221,7 @@ struct cmd_context {
|
|
|
4f6fcd |
const char *devname; /* net device name */
|
|
|
4f6fcd |
int fd; /* socket suitable for ethtool ioctl */
|
|
|
4f6fcd |
struct ifreq ifr; /* ifreq suitable for ethtool ioctl */
|
|
|
4f6fcd |
- int argc; /* number of arguments to the sub-command */
|
|
|
4f6fcd |
+ unsigned int argc; /* number of arguments to the sub-command */
|
|
|
4f6fcd |
char **argp; /* arguments to the sub-command */
|
|
|
4f6fcd |
unsigned long debug; /* debugging mask */
|
|
|
4f6fcd |
bool json; /* Output JSON, if supported */
|
|
|
4f6fcd |
--
|
|
|
4f6fcd |
2.26.2
|
|
|
4f6fcd |
|