netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Kubecek <mkubecek@suse.cz>
To: netdev@vger.kernel.org
Subject: [PATCH ethtool 1/7] netlink: get rid of signed/unsigned comparison warnings
Date: Sun,  9 Aug 2020 23:24:19 +0200 (CEST)	[thread overview]
Message-ID: <90fd688121efaea8acce2a9547585416433493f3.1597007533.git.mkubecek@suse.cz> (raw)
In-Reply-To: <cover.1597007532.git.mkubecek@suse.cz>

Get rid of compiler warnings about comparison between signed and
unsigned integer values in netlink code.

Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
 netlink/features.c | 4 ++--
 netlink/netlink.c  | 4 ++--
 netlink/netlink.h  | 2 +-
 netlink/nlsock.c   | 2 +-
 netlink/parser.c   | 2 +-
 netlink/settings.c | 6 +++---
 6 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/netlink/features.c b/netlink/features.c
index 8b5b8588ca23..f5862e97a265 100644
--- a/netlink/features.c
+++ b/netlink/features.c
@@ -149,7 +149,7 @@ int dump_features(const struct nlattr *const *tb,
 			continue;
 
 		for (j = 0; j < results.count; j++) {
-			if (feature_flags[j] == i) {
+			if (feature_flags[j] == (int)i) {
 				n_match++;
 				flag_value = flag_value ||
 					feature_on(results.active, j);
@@ -163,7 +163,7 @@ int dump_features(const struct nlattr *const *tb,
 		for (j = 0; j < results.count; j++) {
 			const char *name = get_string(feature_names, j);
 
-			if (feature_flags[j] != i)
+			if (feature_flags[j] != (int)i)
 				continue;
 			if (n_match == 1)
 				dump_feature(&results, NULL, NULL, j,
diff --git a/netlink/netlink.c b/netlink/netlink.c
index 76b6e825b1d0..e42d57076a4b 100644
--- a/netlink/netlink.c
+++ b/netlink/netlink.c
@@ -33,9 +33,9 @@ int nomsg_reply_cb(const struct nlmsghdr *nlhdr, void *data __maybe_unused)
 int attr_cb(const struct nlattr *attr, void *data)
 {
 	const struct attr_tb_info *tb_info = data;
-	int type = mnl_attr_get_type(attr);
+	uint16_t type = mnl_attr_get_type(attr);
 
-	if (type >= 0 && type <= tb_info->max_type)
+	if (type <= tb_info->max_type)
 		tb_info->tb[type] = attr;
 
 	return MNL_CB_OK;
diff --git a/netlink/netlink.h b/netlink/netlink.h
index a4984c82ae76..dd4a02bcc916 100644
--- a/netlink/netlink.h
+++ b/netlink/netlink.h
@@ -45,7 +45,7 @@ struct nl_context {
 	const char		*cmd;
 	const char		*param;
 	char			**argp;
-	int			argc;
+	unsigned int		argc;
 	bool			ioctl_fallback;
 	bool			wildcard_unsupported;
 };
diff --git a/netlink/nlsock.c b/netlink/nlsock.c
index c3f09b6ee9ab..ef31d8c33b29 100644
--- a/netlink/nlsock.c
+++ b/netlink/nlsock.c
@@ -168,7 +168,7 @@ static void debug_msg(struct nl_socket *nlsk, const void *msg, unsigned int len,
  *
  * Return: error code extracted from the message
  */
-static int nlsock_process_ack(struct nlmsghdr *nlhdr, ssize_t len,
+static int nlsock_process_ack(struct nlmsghdr *nlhdr, unsigned long len,
 			      unsigned int suppress_nlerr, bool pretty)
 {
 	const struct nlattr *tb[NLMSGERR_ATTR_MAX + 1] = {};
diff --git a/netlink/parser.c b/netlink/parser.c
index 395bd5743af9..c5a368a65a7a 100644
--- a/netlink/parser.c
+++ b/netlink/parser.c
@@ -604,7 +604,7 @@ static int parse_numeric_bitset(struct nl_context *nlctx, uint16_t type,
 		parser_err_invalid_value(nlctx, arg);
 		return -EINVAL;
 	}
-	len1 = maskptr ? (maskptr - arg) : strlen(arg);
+	len1 = maskptr ? (unsigned int)(maskptr - arg) : strlen(arg);
 	nwords = DIV_ROUND_UP(len1, 8);
 	nbits = 0;
 
diff --git a/netlink/settings.c b/netlink/settings.c
index de35ad173627..99d047a3e497 100644
--- a/netlink/settings.c
+++ b/netlink/settings.c
@@ -276,10 +276,10 @@ int dump_link_modes(struct nl_context *nlctx, const struct nlattr *bitset,
 	const struct nlattr *bitset_tb[ETHTOOL_A_BITSET_MAX + 1] = {};
 	DECLARE_ATTR_TB_INFO(bitset_tb);
 	const unsigned int before_len = strlen(before);
+	unsigned int prev = UINT_MAX - 1;
 	const struct nlattr *bits;
 	const struct nlattr *bit;
 	bool first = true;
-	int prev = -2;
 	bool nomask;
 	int ret;
 
@@ -333,7 +333,7 @@ int dump_link_modes(struct nl_context *nlctx, const struct nlattr *bitset,
 			if (first)
 				first = false;
 			/* ugly hack to preserve old output format */
-			if (class == LM_CLASS_REAL && (prev == idx - 1) &&
+			if (class == LM_CLASS_REAL && (idx == prev + 1) &&
 			    prev < link_modes_count &&
 			    link_modes[prev].class == LM_CLASS_REAL &&
 			    link_modes[prev].duplex == DUPLEX_HALF)
@@ -375,7 +375,7 @@ int dump_link_modes(struct nl_context *nlctx, const struct nlattr *bitset,
 			first = false;
 		} else {
 			/* ugly hack to preserve old output format */
-			if ((class == LM_CLASS_REAL) && (prev == idx - 1) &&
+			if ((class == LM_CLASS_REAL) && (idx == prev + 1) &&
 			    (prev < link_modes_count) &&
 			    (link_modes[prev].class == LM_CLASS_REAL) &&
 			    (link_modes[prev].duplex == DUPLEX_HALF))
-- 
2.28.0


  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 ` Michal Kubecek [this message]
2020-08-10 14:11   ` [PATCH ethtool 1/7] netlink: get rid of signed/unsigned comparison warnings 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 ` [PATCH ethtool 4/7] get rid of signed/unsigned comparison warnings in register dump parsers Michal Kubecek
2020-08-10 14:20   ` 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=90fd688121efaea8acce2a9547585416433493f3.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).