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 <ros...@gmail.com> --- 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; -- 2.9.3 _______________________________________________ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev