From patchwork Sun Jan 29 01:11:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 721121 X-Patchwork-Delegate: openwrt@kresin.me Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3v9vfr2CKhz9t0P for ; Sun, 29 Jan 2017 12:13:39 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="bzPAbpNn"; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cXe3i-0004qk-NS; Sun, 29 Jan 2017 01:13:34 +0000 Received: from mail-pf0-f194.google.com ([209.85.192.194]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cXe3e-0004pU-MG for lede-dev@lists.infradead.org; Sun, 29 Jan 2017 01:13:32 +0000 Received: by mail-pf0-f194.google.com with SMTP id f144so20947855pfa.2 for ; Sat, 28 Jan 2017 17:13:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=1ZLpcsTdXfw3xlmkJDAOkAeTzY4tUKqBHTeLTTI1dMw=; b=bzPAbpNn4WPEzy41gtdABQ2oMrcXlenaU9mH8D7HwVammyeJHVtOrso9taOwMNxS+e Cnb0dZ/ZuYQhkmtPxAJURH0PJVwEVJbqBGblGiM33JQqsr0mUSzRJYhxW9XDov8NUKXU w81YQOKnApV59MHOQll+vEF1URZNaZnSXtSAcEkfBjv6+/Ra29c0MAb732WUKFyb9kWV I9HoriwUWioF+7VTyg9vxX+hMgrMSYtzRT8DrzWOj6TT37DQvTbbtC7UyProSa64jsKS NM2bcfFVP26eoR3Ml4sNzmDG9i9R/RavdQwyIwB12/VAbO9O46K+qLMsudXevJeja7vC Y4mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1ZLpcsTdXfw3xlmkJDAOkAeTzY4tUKqBHTeLTTI1dMw=; b=iE6NDA9QjKU3XVo0V8bk8xiy3ymFg4XJ6i/B3C77rO6HywVkL20vHQXOYt6bsDDEZJ hr47Jf1pmmjzkqGXrdDndSZk0TtyLWdoK83NBQ27KdIpPZemBWIhsdH/+0MS5vt9eUZC OgxBCM/w6S7uQNHeqF0zMHWiznd0zH+x4oxkfKsdaSipbkAQENmNseqQCN9Z49dlB/OH 3j70wdixTD3dp2hWOtgh+gJeJ/XoV/4gmv/1V9fqEZB69BSk6mb8AH/50KB3ch562vHr yvW3I9fRjhrmAcccAcoPrWLs6MIWEezzFsPU4Co+hj083SO+5VdpZw2fe73+fYSwHraR iX8Q== X-Gm-Message-State: AIkVDXIrsFkUFacsdQDNTPw242x2Vn23qdj+QX1O8iS7sqfcXXzSvGZMbrTWE5Q2LGrmbw== X-Received: by 10.84.177.129 with SMTP id x1mr22111831plb.75.1485652328752; Sat, 28 Jan 2017 17:12:08 -0800 (PST) Received: from localhost.localdomain (c-67-161-2-172.hsd1.ca.comcast.net. [67.161.2.172]) by smtp.gmail.com with ESMTPSA id e189sm21455660pfg.64.2017.01.28.17.12.07 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 28 Jan 2017 17:12:08 -0800 (PST) From: Rosen Penev To: lede-dev@lists.infradead.org Date: Sat, 28 Jan 2017 17:11:59 -0800 Message-Id: <20170129011159.4594-1-rosenp@gmail.com> X-Mailer: git-send-email 2.9.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170128_171330_790179_64AD16C4 X-CRM114-Status: GOOD ( 13.77 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.5 RCVD_IN_SORBS_SPAM RBL: SORBS: sender is a spam source [209.85.192.194 listed in dnsbl.sorbs.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.192.194 listed in list.dnswl.org] -1.2 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.192.194 listed in wl.mailspike.net] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (rosenp[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Subject: [LEDE-DEV] [PATCH] libubox: Fix -Wsign-compare and sign conversion warnings X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rosen Penev MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org While at it, also add -Wextra and -Wno-unused-parameter to the CFLAGS. Compile tested on 32 and 64-bit x86. Signed-off by: Rosen Penev --- CMakeLists.txt | 3 +-- base64.c | 6 +++--- blob.c | 12 ++++++------ blob.h | 8 ++++---- blobmsg.c | 2 +- kvlist.c | 2 +- usock.c | 6 +++--- 7 files changed, 19 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 57804cf..44032df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,8 +3,7 @@ INCLUDE(CheckLibraryExists) INCLUDE(CheckFunctionExists) PROJECT(ubox C) -ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations) - +ADD_DEFINITIONS(-Os -Wall -Wextra -Werror --std=gnu99 -g3 -Wmissing-declarations -Wno-unused-parameter) OPTION(BUILD_LUA "build Lua plugin" ON) OPTION(BUILD_EXAMPLES "build examples" ON) diff --git a/base64.c b/base64.c index 4186ce8..f4cb5c6 100644 --- a/base64.c +++ b/base64.c @@ -142,7 +142,6 @@ int b64_encode(const void *_src, size_t srclength, size_t datalength = 0; u_char input[3] = {0}; u_char output[4]; - int i; while (2 < srclength) { input[0] = *src++; @@ -167,7 +166,7 @@ int b64_encode(const void *_src, size_t srclength, if (0 != srclength) { /* Get what's left. */ input[0] = input[1] = input[2] = '\0'; - for (i = 0; i < srclength; i++) + for (size_t i = 0; i < srclength; i++) input[i] = *src++; output[0] = input[0] >> 2; @@ -200,7 +199,8 @@ int b64_decode(const void *_src, void *dest, size_t targsize) { const char *src = _src; unsigned char *target = dest; - int tarindex, state, ch; + int state, ch; + size_t tarindex; u_char nextbyte; char *pos; diff --git a/blob.c b/blob.c index 03d5e9c..45c3204 100644 --- a/blob.c +++ b/blob.c @@ -186,7 +186,7 @@ blob_nest_end(struct blob_buf *buf, void *cookie) buf->head = attr; } -static const int blob_type_minlen[BLOB_ATTR_LAST] = { +static const size_t blob_type_minlen[BLOB_ATTR_LAST] = { [BLOB_ATTR_STRING] = 1, [BLOB_ATTR_INT8] = sizeof(uint8_t), [BLOB_ATTR_INT16] = sizeof(uint16_t), @@ -222,18 +222,18 @@ blob_parse(struct blob_attr *attr, struct blob_attr **data, const struct blob_at { struct blob_attr *pos; int found = 0; - int rem; + unsigned int rem; memset(data, 0, sizeof(struct blob_attr *) * max); blob_for_each_attr(pos, attr, rem) { - int id = blob_id(pos); - int len = blob_len(pos); + unsigned int id = blob_id(pos); + unsigned int len = blob_len(pos); - if (id >= max) + if ((int)id >= max) continue; if (info) { - int type = info[id].type; + unsigned int type = info[id].type; if (type < BLOB_ATTR_LAST) { if (!blob_check_type(blob_data(pos), len, type)) diff --git a/blob.h b/blob.h index a092f5d..3f069da 100644 --- a/blob.h +++ b/blob.h @@ -154,25 +154,25 @@ blob_get_u64(const struct blob_attr *attr) static inline int8_t blob_get_int8(const struct blob_attr *attr) { - return blob_get_u8(attr); + return (int8_t)blob_get_u8(attr); } static inline int16_t blob_get_int16(const struct blob_attr *attr) { - return blob_get_u16(attr); + return (int16_t)blob_get_u16(attr); } static inline int32_t blob_get_int32(const struct blob_attr *attr) { - return blob_get_u32(attr); + return (int32_t)blob_get_u32(attr); } static inline int64_t blob_get_int64(const struct blob_attr *attr) { - return blob_get_u64(attr); + return (int64_t)blob_get_u64(attr); } static inline const char * diff --git a/blobmsg.c b/blobmsg.c index c2bb717..1eddf23 100644 --- a/blobmsg.c +++ b/blobmsg.c @@ -67,7 +67,7 @@ int blobmsg_check_array(const struct blob_attr *attr, int type) { struct blob_attr *cur; bool name; - int rem; + unsigned int rem; int size = 0; switch (blobmsg_type(attr)) { diff --git a/kvlist.c b/kvlist.c index a7b6ea0..66fc8cd 100644 --- a/kvlist.c +++ b/kvlist.c @@ -75,7 +75,7 @@ bool kvlist_set(struct kvlist *kv, const char *name, const void *data) { struct kvlist_node *node; char *name_buf; - int len = kv->get_len(kv, data); + size_t len = kv->get_len(kv, data); node = calloc_a(sizeof(struct kvlist_node) + len, &name_buf, strlen(name) + 1); diff --git a/usock.c b/usock.c index 0ce5390..c159a76 100644 --- a/usock.c +++ b/usock.c @@ -33,7 +33,7 @@ #include "usock.h" #include "utils.h" -static void usock_set_flags(int sock, unsigned int type) +static void usock_set_flags(int sock, int type) { if (!(type & USOCK_NOCLOEXEC)) fcntl(sock, F_SETFD, fcntl(sock, F_GETFD) | FD_CLOEXEC); @@ -42,7 +42,7 @@ static void usock_set_flags(int sock, unsigned int type) fcntl(sock, F_SETFL, fcntl(sock, F_GETFL) | O_NONBLOCK); } -static int usock_connect(int type, struct sockaddr *sa, int sa_len, int family, int socktype, bool server) +static int usock_connect(int type, struct sockaddr *sa, socklen_t sa_len, int family, int socktype, bool server) { int sock; @@ -103,7 +103,7 @@ usock_inet_notimeout(int type, struct addrinfo *result, void *addr) return -1; } -static int poll_restart(struct pollfd *fds, int nfds, int timeout) +static int poll_restart(struct pollfd *fds, nfds_t nfds, int timeout) { struct timespec ts, cur; int msec = timeout % 1000;