From 0aeb127f3cfe4abbc9a894c236541467396ed5ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Fri, 4 Oct 2019 16:56:12 +0200 Subject: iron out all extra compiler warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gcc 9.1 on x86/64 has reported following: attr.c:403:19: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Werror=sign-compare] genl.c:154:24: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare] genl_mngt.c:157:22: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Werror=sign-compare] msg.c:190:20: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Werror=sign-compare] msg.c:192:18: error: comparison of integer expressions of different signedness: ‘__u32’ {aka ‘const unsigned int’} and ‘int’ [-Werror=sign-compare] msg.c:361:10: error: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Werror=sign-compare] nl.c:428:18: error: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Werror=sign-compare] nl.c:602:23: error: comparison of integer expressions of different signedness: ‘__u32’ {aka ‘unsigned int’} and ‘int’ [-Werror=sign-compare] Signed-off-by: Petr Štetiar --- msg.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'msg.c') diff --git a/msg.c b/msg.c index b502047..5992e38 100644 --- a/msg.c +++ b/msg.c @@ -187,9 +187,11 @@ static size_t default_msg_size = 4096; */ int nlmsg_ok(const struct nlmsghdr *nlh, int remaining) { - return (remaining >= sizeof(struct nlmsghdr) && + size_t r = remaining; + + return (r >= sizeof(struct nlmsghdr) && nlh->nlmsg_len >= sizeof(struct nlmsghdr) && - nlh->nlmsg_len <= remaining); + nlh->nlmsg_len <= r); } /** @@ -358,7 +360,7 @@ struct nl_msg *nlmsg_alloc_simple(int nlmsgtype, int flags) */ void nlmsg_set_default_size(size_t max) { - if (max < nlmsg_total_size(0)) + if (max < (size_t) nlmsg_total_size(0)) max = nlmsg_total_size(0); default_msg_size = max; -- cgit v1.2.1