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

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