Blame SOURCES/0003-netlink-get-rid-of-signed-unsigned-comparison-warnin.patch

4f6fcd
From aef2a21a2221c03e4e00fd06ea74002317fbfd5e Mon Sep 17 00:00:00 2001
4f6fcd
From: Michal Kubecek <mkubecek@suse.cz>
4f6fcd
Date: Sun, 23 Aug 2020 21:40:18 +0200
4f6fcd
Subject: [PATCH 03/17] netlink: get rid of signed/unsigned comparison warnings
4f6fcd
4f6fcd
Use unsigned types where appropriate to get rid of compiler warnings about
4f6fcd
comparison between signed and unsigned integer values in netlink code.
4f6fcd
4f6fcd
v2: avoid casts in dump_features()
4f6fcd
4f6fcd
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
4f6fcd
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
4f6fcd
(cherry picked from commit b038eef080221b1f9df944c3d2307bad172cf318)
4f6fcd
---
4f6fcd
 netlink/features.c | 6 +++---
4f6fcd
 netlink/netlink.c  | 4 ++--
4f6fcd
 netlink/netlink.h  | 2 +-
4f6fcd
 netlink/nlsock.c   | 2 +-
4f6fcd
 netlink/parser.c   | 2 +-
4f6fcd
 netlink/settings.c | 6 +++---
4f6fcd
 6 files changed, 11 insertions(+), 11 deletions(-)
4f6fcd
4f6fcd
diff --git a/netlink/features.c b/netlink/features.c
4f6fcd
index 762259405acc..3f1240437350 100644
4f6fcd
--- a/netlink/features.c
4f6fcd
+++ b/netlink/features.c
4f6fcd
@@ -109,9 +109,9 @@ static bool flag_pattern_match(const char *name, const char *pattern)
4f6fcd
 int dump_features(const struct nlattr *const *tb,
4f6fcd
 		  const struct stringset *feature_names)
4f6fcd
 {
4f6fcd
+	unsigned int *feature_flags = NULL;
4f6fcd
 	struct feature_results results;
4f6fcd
 	unsigned int i, j;
4f6fcd
-	int *feature_flags = NULL;
4f6fcd
 	int ret;
4f6fcd
 
4f6fcd
 	ret = prepare_feature_results(tb, &results);
4f6fcd
@@ -126,7 +126,7 @@ int dump_features(const struct nlattr *const *tb,
4f6fcd
 	/* map netdev features to legacy flags */
4f6fcd
 	for (i = 0; i < results.count; i++) {
4f6fcd
 		const char *name = get_string(feature_names, i);
4f6fcd
-		feature_flags[i] = -1;
4f6fcd
+		feature_flags[i] = UINT_MAX;
4f6fcd
 
4f6fcd
 		if (!name || !*name)
4f6fcd
 			continue;
4f6fcd
@@ -177,7 +177,7 @@ int dump_features(const struct nlattr *const *tb,
4f6fcd
 	for (i = 0; i < results.count; i++) {
4f6fcd
 		const char *name = get_string(feature_names, i);
4f6fcd
 
4f6fcd
-		if (!name || !*name || feature_flags[i] >= 0)
4f6fcd
+		if (!name || !*name || feature_flags[i] != UINT_MAX)
4f6fcd
 			continue;
4f6fcd
 		dump_feature(&results, NULL, NULL, i, name, "");
4f6fcd
 	}
4f6fcd
diff --git a/netlink/netlink.c b/netlink/netlink.c
4f6fcd
index 76b6e825b1d0..e42d57076a4b 100644
4f6fcd
--- a/netlink/netlink.c
4f6fcd
+++ b/netlink/netlink.c
4f6fcd
@@ -33,9 +33,9 @@ int nomsg_reply_cb(const struct nlmsghdr *nlhdr, void *data __maybe_unused)
4f6fcd
 int attr_cb(const struct nlattr *attr, void *data)
4f6fcd
 {
4f6fcd
 	const struct attr_tb_info *tb_info = data;
4f6fcd
-	int type = mnl_attr_get_type(attr);
4f6fcd
+	uint16_t type = mnl_attr_get_type(attr);
4f6fcd
 
4f6fcd
-	if (type >= 0 && type <= tb_info->max_type)
4f6fcd
+	if (type <= tb_info->max_type)
4f6fcd
 		tb_info->tb[type] = attr;
4f6fcd
 
4f6fcd
 	return MNL_CB_OK;
4f6fcd
diff --git a/netlink/netlink.h b/netlink/netlink.h
4f6fcd
index a4984c82ae76..dd4a02bcc916 100644
4f6fcd
--- a/netlink/netlink.h
4f6fcd
+++ b/netlink/netlink.h
4f6fcd
@@ -45,7 +45,7 @@ struct nl_context {
4f6fcd
 	const char		*cmd;
4f6fcd
 	const char		*param;
4f6fcd
 	char			**argp;
4f6fcd
-	int			argc;
4f6fcd
+	unsigned int		argc;
4f6fcd
 	bool			ioctl_fallback;
4f6fcd
 	bool			wildcard_unsupported;
4f6fcd
 };
4f6fcd
diff --git a/netlink/nlsock.c b/netlink/nlsock.c
4f6fcd
index c3f09b6ee9ab..ef31d8c33b29 100644
4f6fcd
--- a/netlink/nlsock.c
4f6fcd
+++ b/netlink/nlsock.c
4f6fcd
@@ -168,7 +168,7 @@ static void debug_msg(struct nl_socket *nlsk, const void *msg, unsigned int len,
4f6fcd
  *
4f6fcd
  * Return: error code extracted from the message
4f6fcd
  */
4f6fcd
-static int nlsock_process_ack(struct nlmsghdr *nlhdr, ssize_t len,
4f6fcd
+static int nlsock_process_ack(struct nlmsghdr *nlhdr, unsigned long len,
4f6fcd
 			      unsigned int suppress_nlerr, bool pretty)
4f6fcd
 {
4f6fcd
 	const struct nlattr *tb[NLMSGERR_ATTR_MAX + 1] = {};
4f6fcd
diff --git a/netlink/parser.c b/netlink/parser.c
4f6fcd
index 395bd5743af9..c5a368a65a7a 100644
4f6fcd
--- a/netlink/parser.c
4f6fcd
+++ b/netlink/parser.c
4f6fcd
@@ -604,7 +604,7 @@ static int parse_numeric_bitset(struct nl_context *nlctx, uint16_t type,
4f6fcd
 		parser_err_invalid_value(nlctx, arg);
4f6fcd
 		return -EINVAL;
4f6fcd
 	}
4f6fcd
-	len1 = maskptr ? (maskptr - arg) : strlen(arg);
4f6fcd
+	len1 = maskptr ? (unsigned int)(maskptr - arg) : strlen(arg);
4f6fcd
 	nwords = DIV_ROUND_UP(len1, 8);
4f6fcd
 	nbits = 0;
4f6fcd
 
4f6fcd
diff --git a/netlink/settings.c b/netlink/settings.c
4f6fcd
index 17ef000ed812..2b9c6e7a782c 100644
4f6fcd
--- a/netlink/settings.c
4f6fcd
+++ b/netlink/settings.c
4f6fcd
@@ -276,10 +276,10 @@ int dump_link_modes(struct nl_context *nlctx, const struct nlattr *bitset,
4f6fcd
 	const struct nlattr *bitset_tb[ETHTOOL_A_BITSET_MAX + 1] = {};
4f6fcd
 	DECLARE_ATTR_TB_INFO(bitset_tb);
4f6fcd
 	const unsigned int before_len = strlen(before);
4f6fcd
+	unsigned int prev = UINT_MAX - 1;
4f6fcd
 	const struct nlattr *bits;
4f6fcd
 	const struct nlattr *bit;
4f6fcd
 	bool first = true;
4f6fcd
-	int prev = -2;
4f6fcd
 	bool nomask;
4f6fcd
 	int ret;
4f6fcd
 
4f6fcd
@@ -333,7 +333,7 @@ int dump_link_modes(struct nl_context *nlctx, const struct nlattr *bitset,
4f6fcd
 			if (first)
4f6fcd
 				first = false;
4f6fcd
 			/* ugly hack to preserve old output format */
4f6fcd
-			if (class == LM_CLASS_REAL && (prev == idx - 1) &&
4f6fcd
+			if (class == LM_CLASS_REAL && (idx == prev + 1) &&
4f6fcd
 			    prev < link_modes_count &&
4f6fcd
 			    link_modes[prev].class == LM_CLASS_REAL &&
4f6fcd
 			    link_modes[prev].duplex == DUPLEX_HALF)
4f6fcd
@@ -375,7 +375,7 @@ int dump_link_modes(struct nl_context *nlctx, const struct nlattr *bitset,
4f6fcd
 			first = false;
4f6fcd
 		} else {
4f6fcd
 			/* ugly hack to preserve old output format */
4f6fcd
-			if ((class == LM_CLASS_REAL) && (prev == idx - 1) &&
4f6fcd
+			if ((class == LM_CLASS_REAL) && (idx == prev + 1) &&
4f6fcd
 			    (prev < link_modes_count) &&
4f6fcd
 			    (link_modes[prev].class == LM_CLASS_REAL) &&
4f6fcd
 			    (link_modes[prev].duplex == DUPLEX_HALF))
4f6fcd
-- 
4f6fcd
2.26.2
4f6fcd