From patchwork Wed Nov 20 21:43:44 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: 1198551 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="lhvCar8Q"; 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 47JGSd03Yzz9sPJ for ; Thu, 21 Nov 2019 08:45:05 +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=OADeK81AyE8HyhuySON5kjOMC/WXahfEJv6Ywa0t1OM=; b=lhvCar8QbeFK7A JpCaX72laBpAfFsQfPvQ2gpO492bM5jbsC60mErmVoMJOmKQt0wLt1BNZwVJ8q6d5Oey6o72Ko8/3 9cSLC1s5ZO34nlrbCgRPDP+AXfQ69YbP9xpDx6gpbLu/inQiSGkyKEAqNcx20OjQ2n7anUll9SshB KeSRgIKbO6dhKJzG+iqHxzSiK8h+ZjJ5SHraul2wnnmJFUYtCx6hSx0w1OgSx1M6W8+KT2+64Iq2M 6YvygpqY/1G3PQPCrzUfLs+8WnWeeg2jiUVe7gaucgZ51w15ukBmqw09ki243z/gYiSB19PTTs5/O zvwFnleUVA8q0YQTXQDQ==; 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 1iXXmZ-0006mi-8N; Wed, 20 Nov 2019 21:45:03 +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 1iXXla-0005nM-Bj for openwrt-devel@lists.openwrt.org; Wed, 20 Nov 2019 21:44:05 +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 C8DD04AD5; Wed, 20 Nov 2019 22:43:59 +0100 (CET) Received: by meh.true.cz (OpenSMTPD) with ESMTP id df55384d; Wed, 20 Nov 2019 22:43:50 +0100 (CET) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Date: Wed, 20 Nov 2019 22:43:44 +0100 Message-Id: <20191120214353.27652-2-ynezz@true.cz> In-Reply-To: <20191120214353.27652-1-ynezz@true.cz> References: <20191120214353.27652-1-ynezz@true.cz> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191120_134402_559698_2A1AAE77 X-CRM114-Status: GOOD ( 12.08 ) 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_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record Subject: [OpenWrt-Devel] [PATCH v2 libubox 01/10] 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 on x86/64 has reported following issues: base64.c:173:17: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare] base64.c:230:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare] base64.c:238:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare] base64.c:242:22: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare] base64.c:252:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare] base64.c:256:22: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare] base64.c:266:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare] base64.c:315:27: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare] base64.c:329:15: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare] blob.c:207:11: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare] blob.c:210:11: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare] blob.c:243:31: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare] blob.c:246:31: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare] blob.h:245:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare] blob.h:253:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare] blobmsg.h:269:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare] blobmsg_json.c:155:10: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare] examples/../blob.h:245:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare] examples/../blobmsg.h:269:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare] json_script.c:590:7: error: this statement may fall through [-Werror=implicit-fallthrough=] Signed-off-by: Petr Štetiar --- base64.c | 5 +++-- blob.c | 6 +++--- blob.h | 6 +++--- blobmsg.c | 2 +- blobmsg_json.c | 4 ++-- examples/blobmsg-example.c | 2 +- examples/json_script-example.c | 2 +- json_script.c | 17 ++++++++++------- 8 files changed, 24 insertions(+), 20 deletions(-) diff --git a/base64.c b/base64.c index 4186ce848c71..4759ede01e7c 100644 --- a/base64.c +++ b/base64.c @@ -142,7 +142,7 @@ int b64_encode(const void *_src, size_t srclength, size_t datalength = 0; u_char input[3] = {0}; u_char output[4]; - int i; + size_t i; while (2 < srclength) { input[0] = *src++; @@ -200,7 +200,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 03d5e9c27ee7..9b3d8abe330a 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,12 +222,12 @@ blob_parse(struct blob_attr *attr, struct blob_attr **data, const struct blob_at { struct blob_attr *pos; int found = 0; - int rem; + size_t 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); + size_t len = blob_len(pos); if (id >= max) continue; diff --git a/blob.h b/blob.h index a092f5dabca6..d34652229b59 100644 --- a/blob.h +++ b/blob.h @@ -96,7 +96,7 @@ blob_is_extended(const struct blob_attr *attr) /* * blob_len: returns the length of the attribute's payload */ -static inline unsigned int +static inline size_t blob_len(const struct blob_attr *attr) { return (be32_to_cpu(attr->id_len) & BLOB_ATTR_LEN_MASK) - sizeof(struct blob_attr); @@ -105,7 +105,7 @@ blob_len(const struct blob_attr *attr) /* * blob_raw_len: returns the complete length of an attribute (including the header) */ -static inline unsigned int +static inline size_t blob_raw_len(const struct blob_attr *attr) { return blob_len(attr) + sizeof(struct blob_attr); @@ -114,7 +114,7 @@ blob_raw_len(const struct blob_attr *attr) /* * blob_pad_len: returns the padded length of an attribute (including the header) */ -static inline unsigned int +static inline size_t blob_pad_len(const struct blob_attr *attr) { unsigned int len = blob_raw_len(attr); diff --git a/blobmsg.c b/blobmsg.c index 8019c45b83ed..a860483bfa7e 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; + size_t rem; int size = 0; switch (blobmsg_type(attr)) { diff --git a/blobmsg_json.c b/blobmsg_json.c index 59a4b3183d8c..a5980e8a2b62 100644 --- a/blobmsg_json.c +++ b/blobmsg_json.c @@ -146,7 +146,7 @@ static bool blobmsg_puts(struct strbuf *s, const char *c, int len) static void add_separator(struct strbuf *s) { const char *indent_chars = "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"; - int len; + size_t len; if (!s->indent) return; @@ -279,7 +279,7 @@ static void blobmsg_format_json_list(struct strbuf *s, struct blob_attr *attr, i { struct blob_attr *pos; bool first = true; - int rem = len; + size_t rem = len; blobmsg_puts(s, (array ? "[" : "{" ), 1); s->indent_level++; diff --git a/examples/blobmsg-example.c b/examples/blobmsg-example.c index 1c8601735fd0..56cac2718123 100644 --- a/examples/blobmsg-example.c +++ b/examples/blobmsg-example.c @@ -15,7 +15,7 @@ static const char *indent_str = "\t\t\t\t\t\t\t\t\t\t\t\t\t"; static void dump_attr_data(struct blob_attr *data, int indent, int next_indent); static void -dump_table(struct blob_attr *head, int len, int indent, bool array) +dump_table(struct blob_attr *head, size_t len, int indent, bool array) { struct blob_attr *attr; struct blobmsg_hdr *hdr; diff --git a/examples/json_script-example.c b/examples/json_script-example.c index 4d252a9a6bd2..6d93059a412e 100644 --- a/examples/json_script-example.c +++ b/examples/json_script-example.c @@ -14,7 +14,7 @@ static void handle_command(struct json_script_ctx *ctx, const char *name, struct blob_attr *data, struct blob_attr *vars) { struct blob_attr *cur; - int rem; + size_t rem; fprintf(stdout, "%s", name); blobmsg_for_each_attr(cur, data, rem) diff --git a/json_script.c b/json_script.c index 87b1d71b1837..3b10b1015400 100644 --- a/json_script.c +++ b/json_script.c @@ -95,7 +95,7 @@ const char *json_script_find_var(struct json_script_ctx *ctx, struct blob_attr * const char *name) { struct blob_attr *cur; - int rem; + size_t rem; blobmsg_for_each_attr(cur, vars, rem) { if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING) @@ -164,7 +164,7 @@ static int handle_case(struct json_call *call, struct blob_attr *expr) { struct blob_attr *tb[3], *cur; const char *var; - int rem; + size_t rem; json_get_tuple(expr, tb, BLOBMSG_TYPE_STRING, BLOBMSG_TYPE_TABLE); if (!tb[1] || !tb[2]) @@ -233,7 +233,7 @@ static int expr_eq_regex(struct json_call *call, struct blob_attr *expr, bool re struct json_script_ctx *ctx = call->ctx; struct blob_attr *tb[3], *cur; const char *var; - int rem; + size_t rem; json_get_tuple(expr, tb, BLOBMSG_TYPE_STRING, 0); if (!tb[1] || !tb[2]) @@ -277,7 +277,7 @@ static int handle_expr_has(struct json_call *call, struct blob_attr *expr) { struct json_script_ctx *ctx = call->ctx; struct blob_attr *tb[3], *cur; - int rem; + size_t rem; json_get_tuple(expr, tb, 0, 0); if (!tb[1]) @@ -306,7 +306,8 @@ static int handle_expr_has(struct json_call *call, struct blob_attr *expr) static int expr_and_or(struct json_call *call, struct blob_attr *expr, bool and) { struct blob_attr *cur; - int ret, rem; + int ret; + size_t rem; int i = 0; blobmsg_for_each_attr(cur, expr, rem) { @@ -515,7 +516,8 @@ static int cmd_process_strings(struct json_call *call, struct blob_attr *attr) struct json_script_ctx *ctx = call->ctx; struct blob_attr *cur; int args = -1; - int rem, ret; + int ret; + size_t rem; void *c; blob_buf_init(&ctx->buf, 0); @@ -572,7 +574,7 @@ static int json_process_cmd(struct json_call *call, struct blob_attr *block) { struct json_script_ctx *ctx = call->ctx; struct blob_attr *cur; - int rem; + size_t rem; int ret; int i = 0; @@ -589,6 +591,7 @@ static int json_process_cmd(struct json_call *call, struct blob_attr *block) case BLOBMSG_TYPE_STRING: if (!i) return __json_process_cmd(call, block); + /* fall through */ default: ret = json_process_cmd(call, cur); if (ret < -1)