From patchwork Mon Oct 21 09:36:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1180435 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=true.cz Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="neeAB2IL"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46xWlH1Td3z9sPL for ; Mon, 21 Oct 2019 20:37:47 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qUj7HMKjunDi5z0cPe8YOxIMqm20uLDQtq9ZmvJKKWQ=; b=neeAB2ILAQexiN aWk/tfvx2T4oa5r+UF1HGMglaXvzyw6uVKG7WC6us6mMBfuJ8ld2uv2yv26Eir2ppVwUJNWbo5Br3 ieGfVcZB8H+IT4KN94GKyCvMb0vgDd3z3nW03EX9Mog9xgNbbbyffpXLIvev0/vcX9gP2sd8xxUOn 0IywvEd9HVZ4gK/af2yok3xn6ubF65q0L2QAKZ3W97cL+J7lix7ORSzJmQbIzV8QERkliLAsHZuQR Adf1gPesNKHCmCG1zMsejF5FfJopX1NeRRr+LBNxlWfDdZrms1kweolgn4pPiBPLKWUSnHaxFzv8e pzJblrscnZtuq3jNOb0A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMU83-0006kS-Tv; Mon, 21 Oct 2019 09:37:31 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMU7O-0005tO-QN for openwrt-devel@lists.openwrt.org; Mon, 21 Oct 2019 09:36:54 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id 517EE35DD; Mon, 21 Oct 2019 11:36:46 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id 3389401d; Mon, 21 Oct 2019 11:36:36 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Date: Mon, 21 Oct 2019 11:36:41 +0200 Message-Id: <20191021093642.3118-4-ynezz@true.cz> In-Reply-To: <20191021093642.3118-1-ynezz@true.cz> References: <20191021093642.3118-1-ynezz@true.cz> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191021_023651_172470_7A5E4919 X-CRM114-Status: GOOD ( 11.66 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.217.244.18 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record Subject: [OpenWrt-Devel] [PATCH libnl-tiny 4/5] iron out all extra compiler warnings X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Petr_=C5=A0tetiar?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org 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 --- attr.c | 6 ++++-- genl.c | 2 +- genl_mngt.c | 2 +- msg.c | 8 +++++--- nl.c | 4 ++-- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/attr.c b/attr.c index e0f50611cff9..eae91e52bcac 100644 --- a/attr.c +++ b/attr.c @@ -400,9 +400,11 @@ */ int nla_ok(const struct nlattr *nla, int remaining) { - return remaining >= sizeof(*nla) && + size_t r = remaining; + + return r >= sizeof(*nla) && nla->nla_len >= sizeof(*nla) && - nla->nla_len <= remaining; + nla->nla_len <= r; } /** diff --git a/genl.c b/genl.c index 055be919e1d3..f1df3f060c87 100644 --- a/genl.c +++ b/genl.c @@ -151,7 +151,7 @@ int genlmsg_valid_hdr(struct nlmsghdr *nlh, int hdrlen) return 0; ghdr = nlmsg_data(nlh); - if (genlmsg_len(ghdr) < NLMSG_ALIGN(hdrlen)) + if ((unsigned) genlmsg_len(ghdr) < NLMSG_ALIGN(hdrlen)) return 0; return 1; diff --git a/genl_mngt.c b/genl_mngt.c index 246521f696a2..3b603c7ac9bb 100644 --- a/genl_mngt.c +++ b/genl_mngt.c @@ -154,7 +154,7 @@ int genl_register(struct nl_cache_ops *ops) goto errout; } - if (ops->co_hdrsize < GENL_HDRSIZE(0)) { + if ((size_t) ops->co_hdrsize < GENL_HDRSIZE(0)) { err = -NLE_INVAL; goto errout; } diff --git a/msg.c b/msg.c index b502047c4c74..5992e381813b 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; diff --git a/nl.c b/nl.c index 2fb866eca903..2649470f542f 100644 --- a/nl.c +++ b/nl.c @@ -425,7 +425,7 @@ retry: } } - if (iov.iov_len < n || + if (iov.iov_len < (size_t) n || msg.msg_flags & MSG_TRUNC) { /* Provided buffer is not long enough, enlarge it * and try again. */ @@ -599,7 +599,7 @@ continue_reading: else if (hdr->nlmsg_type == NLMSG_ERROR) { struct nlmsgerr *e = nlmsg_data(hdr); - if (hdr->nlmsg_len < nlmsg_msg_size(sizeof(*e))) { + if (hdr->nlmsg_len < (unsigned) nlmsg_msg_size(sizeof(*e))) { /* Truncated error message, the default action * is to stop parsing. The user may overrule * this action by returning NL_SKIP or