diff options
author | Petr Štetiar <ynezz@true.cz> | 2019-11-04 18:21:44 +0100 |
---|---|---|
committer | Petr Štetiar <ynezz@true.cz> | 2019-11-14 17:11:34 +0100 |
commit | af59f86a0db914db60243563956f20e2c0850213 (patch) | |
tree | ec91bd4e257368c04a967ba655ad0aa8b4d9ca3c | |
parent | 1637d29186923bf75c015a9c27e3bbfc951a488c (diff) | |
download | uci-af59f86a0db914db60243563956f20e2c0850213.tar.gz |
iron out all extra compiler warnings
gcc 9.1 on x86/64 has reported following issues:
list.c:140:11: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
file.c:572:51: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
file.c:850:15: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
file.c:865:15: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
delta.c:199:6: error: this statement may fall through [-Werror=implicit-fallthrough=]
parse.c:80:12: error: this statement may fall through [-Werror=implicit-fallthrough=]
parse.c:81:12: error: this statement may fall through [-Werror=implicit-fallthrough=]
file.c:572:51: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
file.c:850:15: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
file.c:865:15: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
delta.c:199:6: error: this statement may fall through [-Werror=implicit-fallthrough=]
parse.c:80:12: error: this statement may fall through [-Werror=implicit-fallthrough=]
parse.c:81:12: error: this statement may fall through [-Werror=implicit-fallthrough=]
ucimap.c:146:16: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
ucimap.c:151:17: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
ucimap.c:243:34: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
ucimap.c:247:9: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
ucimap.c:254:39: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
ucimap.c:258:9: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
ucimap.c:285:34: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
ucimap.c:363:17: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
ucimap.c:563:12: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
ucimap.c:753:18: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
ucimap.c:879:17: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
Signed-off-by: Petr Štetiar <ynezz@true.cz>
-rw-r--r-- | delta.c | 1 | ||||
-rw-r--r-- | file.c | 5 | ||||
-rw-r--r-- | list.c | 4 | ||||
-rw-r--r-- | lua/uci.c | 3 | ||||
-rw-r--r-- | parse.c | 2 | ||||
-rw-r--r-- | ucimap.c | 15 |
6 files changed, 18 insertions, 12 deletions
@@ -198,6 +198,7 @@ static inline int uci_parse_delta_tuple(struct uci_context *ctx, struct uci_ptr case UCI_CMD_LIST_ADD: if (!ptr->option) goto error; + /* fall through */ case UCI_CMD_LIST_DEL: if (!ptr->option) goto error; @@ -569,7 +569,7 @@ static const char *uci_escape(struct uci_context *ctx, const char *str) len = end - str; /* make sure that we have enough room in the buffer */ - while (ofs + len + sizeof(UCI_QUOTE_ESCAPE) + 1 > ctx->bufsz) { + while (ofs + len + (int) sizeof(UCI_QUOTE_ESCAPE) + 1 > ctx->bufsz) { ctx->bufsz *= 2; ctx->buf = uci_realloc(ctx, ctx->buf, ctx->bufsz); } @@ -834,7 +834,8 @@ static char **uci_list_config_files(struct uci_context *ctx) { char **configs; glob_t globbuf; - int size, i, j, skipped; + int size, j, skipped; + size_t i; char *buf; char *dir; @@ -137,7 +137,7 @@ static unsigned int djbhash(unsigned int hash, char *str) int i; /* initial value */ - if (hash == ~0) + if (hash == ~0U) hash = 5381; for(i = 0; i < len; i++) { @@ -149,7 +149,7 @@ static unsigned int djbhash(unsigned int hash, char *str) /* fix up an unnamed section, e.g. after adding options to it */ static void uci_fixup_section(struct uci_context *ctx, struct uci_section *s) { - unsigned int hash = ~0; + unsigned int hash = ~0U; struct uci_element *e; char buf[16]; @@ -605,7 +605,8 @@ uci_lua_set(lua_State *L) int err = UCI_ERR_MEM; char *s = NULL; const char *v; - int i, nargs, offset = 0; + unsigned int i; + int nargs, offset = 0; ctx = find_context(L, &offset); nargs = lua_gettop(L); @@ -78,7 +78,9 @@ static uint32_t hash_murmur2(uint32_t h, const void * key, int len) switch(len) { case 3: h ^= data[2] << 16; + /* fall through */ case 2: h ^= data[1] << 8; + /* fall through */ case 1: h ^= data[0]; h *= m; }; @@ -134,7 +134,7 @@ void ucimap_free_section(struct uci_map *map, struct ucimap_section_data *sd) { void *section; - int i; + unsigned int i; section = ucimap_section_ptr(sd); if (sd->ref) @@ -234,7 +234,7 @@ ucimap_free_item(struct ucimap_section_data *sd, void *item) struct ucimap_alloc_custom *ac; struct ucimap_alloc *a; void *ptr = *((void **) item); - int i; + unsigned int i; if (!ptr) return; @@ -270,7 +270,8 @@ ucimap_resize_list(struct ucimap_section_data *sd, struct ucimap_list **list, in { struct ucimap_list *new; struct ucimap_alloc *a; - int i, offset = 0; + unsigned int i; + int offset = 0; int size = sizeof(struct ucimap_list) + items * sizeof(union ucimap_data); if (!*list) { @@ -360,7 +361,7 @@ ucimap_add_value(union ucimap_data *data, struct uci_optmap *om, struct ucimap_s switch(om->type & UCIMAP_SUBTYPE) { case UCIMAP_STRING: if ((om->data.s.maxlen > 0) && - (strlen(str) > om->data.s.maxlen)) + (strlen(str) > (unsigned) om->data.s.maxlen)) return; s = strdup(str); @@ -532,7 +533,7 @@ ucimap_get_type_name(int type) static bool ucimap_check_optmap_type(struct uci_sectionmap *sm, struct uci_optmap *om) { - unsigned int type; + int type; if (unlikely(sm->type_name != om->type_name) && unlikely(strcmp(sm->type_name, om->type_name) != 0)) { @@ -746,7 +747,7 @@ ucimap_set_changed(struct ucimap_section_data *sd, void *field) void *section = ucimap_section_ptr(sd); struct uci_sectionmap *sm = sd->sm; struct uci_optmap *om; - int ofs = (char *)field - (char *)section; + unsigned int ofs = (char *)field - (char *)section; int i = 0; ucimap_foreach_option(sm, om) { @@ -868,7 +869,7 @@ ucimap_parse(struct uci_map *map, struct uci_package *pkg) struct uci_element *e; struct ucimap_section_data *sd, **sd_tail; struct ucimap_fixup *f; - int i; + unsigned int i; sd_tail = map->sdata_tail; map->parsed = false; |