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

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