From: Petr Štetiar Date: Mon, 10 Jun 2019 06:47:38 +0000 (+0200) Subject: iron out all extra compiler warnings X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6228df9de91d4047ca89f7db670788f3d9b51170;p=oweals%2Flibubox.git iron out all extra compiler warnings 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 --- diff --git a/base64.c b/base64.c index 4186ce8..4759ede 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 03d5e9c..9b3d8ab 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 a092f5d..d346522 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 8019c45..a860483 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 59a4b31..a5980e8 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 1c86017..56cac27 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 4d252a9..6d93059 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 87b1d71..3b10b10 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)