From: Michal Kubecek <mkubecek@suse.cz>
To: netdev@vger.kernel.org
Subject: [PATCH ethtool 4/7] get rid of signed/unsigned comparison warnings in register dump parsers
Date: Sun, 9 Aug 2020 23:24:29 +0200 (CEST) [thread overview]
Message-ID: <e135e814d434e58579969b838c3fc6bd9192f59b.1597007533.git.mkubecek@suse.cz> (raw)
In-Reply-To: <cover.1597007532.git.mkubecek@suse.cz>
All of these are avoided by declaring a variable (mostly loop iterators)
holding only unsigned values as unsigned.
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
dsa.c | 2 +-
fec.c | 2 +-
ibm_emac.c | 2 +-
marvell.c | 2 +-
natsemi.c | 2 +-
rxclass.c | 8 +++++---
sfpdiag.c | 2 +-
tg3.c | 4 ++--
8 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/dsa.c b/dsa.c
index 65502a899194..33c1d39d6605 100644
--- a/dsa.c
+++ b/dsa.c
@@ -824,8 +824,8 @@ static int dsa_mv88e6xxx_dump_regs(struct ethtool_regs *regs)
{
const struct dsa_mv88e6xxx_switch *sw = NULL;
const u16 *data = (u16 *)regs->data;
+ unsigned int i;
u16 id;
- int i;
/* Marvell chips have 32 per-port 16-bit registers */
if (regs->len < 32 * sizeof(u16))
diff --git a/fec.c b/fec.c
index 9cb4f8b1d4e1..d2373d6124c0 100644
--- a/fec.c
+++ b/fec.c
@@ -198,7 +198,7 @@ int fec_dump_regs(struct ethtool_drvinfo *info __maybe_unused,
struct ethtool_regs *regs)
{
const u32 *data = (u32 *)regs->data;
- int offset;
+ unsigned int offset;
u32 val;
for (offset = 0; offset < regs->len; offset += 4) {
diff --git a/ibm_emac.c b/ibm_emac.c
index ea01d56f609c..9f7cae605482 100644
--- a/ibm_emac.c
+++ b/ibm_emac.c
@@ -238,7 +238,7 @@ static void *print_mal_regs(void *buf)
{
struct emac_ethtool_regs_subhdr *hdr = buf;
struct mal_regs *p = (struct mal_regs *)(hdr + 1);
- int i;
+ unsigned int i;
printf("MAL%d Registers\n", hdr->index);
printf("-----------------\n");
diff --git a/marvell.c b/marvell.c
index 8afb150327a3..d3d570e4d4ad 100644
--- a/marvell.c
+++ b/marvell.c
@@ -130,7 +130,7 @@ static void dump_fifo(const char *name, const void *p)
static void dump_gmac_fifo(const char *name, const void *p)
{
const u32 *r = p;
- int i;
+ unsigned int i;
static const char *regs[] = {
"End Address",
"Almost Full Thresh",
diff --git a/natsemi.c b/natsemi.c
index 0af465959cbc..4d9fc092b623 100644
--- a/natsemi.c
+++ b/natsemi.c
@@ -967,8 +967,8 @@ int
natsemi_dump_eeprom(struct ethtool_drvinfo *info __maybe_unused,
struct ethtool_eeprom *ee)
{
- int i;
u16 *eebuf = (u16 *)ee->data;
+ unsigned int i;
if (ee->magic != NATSEMI_MAGIC) {
fprintf(stderr, "Magic number 0x%08x does not match 0x%08x\n",
diff --git a/rxclass.c b/rxclass.c
index 79972651e706..6cf81fdafc85 100644
--- a/rxclass.c
+++ b/rxclass.c
@@ -348,8 +348,9 @@ int rxclass_rule_getall(struct cmd_context *ctx)
{
struct ethtool_rxnfc *nfccmd;
__u32 *rule_locs;
- int err, i;
+ unsigned int i;
__u32 count;
+ int err;
/* determine rule count */
err = rxclass_get_dev_info(ctx, &count, NULL);
@@ -481,8 +482,9 @@ static int rmgr_find_empty_slot(struct rmgr_ctrl *rmgr,
static int rmgr_init(struct cmd_context *ctx, struct rmgr_ctrl *rmgr)
{
struct ethtool_rxnfc *nfccmd;
- int err, i;
__u32 *rule_locs;
+ unsigned int i;
+ int err;
/* clear rule manager settings */
memset(rmgr, 0, sizeof(*rmgr));
@@ -941,7 +943,7 @@ static int rxclass_get_long(char *str, long long *val, int size)
static int rxclass_get_ulong(char *str, unsigned long long *val, int size)
{
- long long max = ~0ULL >> (64 - size);
+ unsigned long long max = ~0ULL >> (64 - size);
char *endp;
errno = 0;
diff --git a/sfpdiag.c b/sfpdiag.c
index fa41651422ea..1fa8b7ba8fec 100644
--- a/sfpdiag.c
+++ b/sfpdiag.c
@@ -190,8 +190,8 @@ static float befloattoh(const __u32 *source)
static void sff8472_calibration(const __u8 *id, struct sff_diags *sd)
{
- int i;
__u16 rx_reading;
+ unsigned int i;
/* Calibration should occur for all values (threshold and current) */
for (i = 0; i < ARRAY_SIZE(sd->bias_cur); ++i) {
diff --git a/tg3.c b/tg3.c
index ac73b33ae4e3..ebdef2d60e6b 100644
--- a/tg3.c
+++ b/tg3.c
@@ -7,7 +7,7 @@
int tg3_dump_eeprom(struct ethtool_drvinfo *info __maybe_unused,
struct ethtool_eeprom *ee)
{
- int i;
+ unsigned int i;
if (ee->magic != TG3_MAGIC) {
fprintf(stderr, "Magic number 0x%08x does not match 0x%08x\n",
@@ -26,7 +26,7 @@ int tg3_dump_eeprom(struct ethtool_drvinfo *info __maybe_unused,
int tg3_dump_regs(struct ethtool_drvinfo *info __maybe_unused,
struct ethtool_regs *regs)
{
- int i;
+ unsigned int i;
u32 reg;
fprintf(stdout, "Offset\tValue\n");
--
2.28.0
next prev parent reply other threads:[~2020-08-09 21:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-09 21:24 [PATCH ethtool 0/7] compiler warnings cleanup, part 2 Michal Kubecek
2020-08-09 21:24 ` [PATCH ethtool 1/7] netlink: get rid of signed/unsigned comparison warnings Michal Kubecek
2020-08-10 14:11 ` Andrew Lunn
2020-08-11 20:30 ` Michal Kubecek
2020-08-09 21:24 ` [PATCH ethtool 2/7] ioctl: check presence of eeprom length argument properly Michal Kubecek
2020-08-10 14:12 ` Andrew Lunn
2020-08-09 21:24 ` [PATCH ethtool 3/7] ioctl: get rid of signed/unsigned comparison warnings Michal Kubecek
2020-08-10 14:19 ` Andrew Lunn
2020-08-10 14:24 ` David Laight
2020-08-11 21:20 ` Michal Kubecek
2020-08-09 21:24 ` Michal Kubecek [this message]
2020-08-10 14:20 ` [PATCH ethtool 4/7] get rid of signed/unsigned comparison warnings in register dump parsers Andrew Lunn
2020-08-09 21:24 ` [PATCH ethtool 5/7] settings: simplify link_mode_info[] initializers Michal Kubecek
2020-08-10 14:21 ` Andrew Lunn
2020-08-09 21:24 ` [PATCH ethtool 6/7] ioctl: convert cmdline_info arrays to named initializers Michal Kubecek
2020-08-10 14:21 ` Andrew Lunn
2020-08-09 21:24 ` [PATCH ethtool 7/7] build: add -Wextra to default CFLAGS Michal Kubecek
2020-08-10 14:22 ` Andrew Lunn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e135e814d434e58579969b838c3fc6bd9192f59b.1597007533.git.mkubecek@suse.cz \
--to=mkubecek@suse.cz \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).