diff --git a/avl-cmp.c b/avl-cmp.c index 39c1f5b..70b092f 100644 --- a/avl-cmp.c +++ b/avl-cmp.c @@ -17,7 +17,7 @@ #include "avl-cmp.h" #include "blob.h" -static inline int _min(int v1, int v2) +static inline size_t _min(size_t v1, size_t v2) { return v1 < v2 ? v1 : v2; } @@ -31,7 +31,7 @@ avl_strcmp(const void *k1, const void *k2, void *ptr) int avl_blobcmp(const void *k1, const void *k2, void *ptr) { - int len = _min(blob_raw_len(k1), blob_raw_len(k2)); + size_t len = _min(blob_raw_len(k1), blob_raw_len(k2)); return memcmp(k1, k2, len); } diff --git a/blob.c b/blob.c index 93321ed..529e08c 100644 --- a/blob.c +++ b/blob.c @@ -125,8 +125,8 @@ void blob_fill_pad(struct blob_attr *attr) { char *buf = (char *) attr; - int len = blob_pad_len(attr); - int delta = len - blob_raw_len(attr); + size_t len = blob_pad_len(attr); + size_t delta = len - blob_raw_len(attr); if (delta > 0) memset(buf + len - delta, 0, delta); diff --git a/blob.h b/blob.h index 13bc7cc..95b0852 100644 --- a/blob.h +++ b/blob.h @@ -83,7 +83,7 @@ blob_data(const struct blob_attr *attr) static inline unsigned int blob_id(const struct blob_attr *attr) { - int id = (be32_to_cpu(attr->id_len) & BLOB_ATTR_ID_MASK) >> BLOB_ATTR_ID_SHIFT; + unsigned int id = (be32_to_cpu(attr->id_len) & BLOB_ATTR_ID_MASK) >> BLOB_ATTR_ID_SHIFT; return id; } @@ -117,8 +117,8 @@ blob_raw_len(const struct blob_attr *attr) static inline size_t blob_pad_len(const struct blob_attr *attr) { - unsigned int len = blob_raw_len(attr); - len = (len + BLOB_ATTR_ALIGN - 1) & ~(BLOB_ATTR_ALIGN - 1); + size_t len = blob_raw_len(attr); + len = (len + BLOB_ATTR_ALIGN - 1) & ~(size_t)(BLOB_ATTR_ALIGN - 1); return len; } @@ -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_json.c b/blobmsg_json.c index 04bb9a1..4865cd3 100644 --- a/blobmsg_json.c +++ b/blobmsg_json.c @@ -30,7 +30,7 @@ bool blobmsg_add_object(struct blob_buf *b, json_object *obj) static bool blobmsg_add_array(struct blob_buf *b, struct array_list *a) { - int i, len; + size_t i, len; for (i = 0, len = array_list_length(a); i < len; i++) { if (!blobmsg_add_json_element(b, NULL, array_list_get_idx(a, i))) @@ -228,14 +228,14 @@ static void blobmsg_format_string(struct strbuf *s, const char *str) blobmsg_puts(s, "\"", 1); } -static void blobmsg_format_json_list(struct strbuf *s, struct blob_attr *attr, int len, bool array); +static void blobmsg_format_json_list(struct strbuf *s, struct blob_attr *attr, size_t len, bool array); static void blobmsg_format_element(struct strbuf *s, struct blob_attr *attr, bool without_name, bool head) { const char *data_str; char buf[317]; void *data; - int len; + size_t len; if (!blobmsg_check_attr(attr, false)) return; @@ -289,7 +289,7 @@ static void blobmsg_format_element(struct strbuf *s, struct blob_attr *attr, boo blobmsg_puts(s, data_str, strlen(data_str)); } -static void blobmsg_format_json_list(struct strbuf *s, struct blob_attr *attr, int len, bool array) +static void blobmsg_format_json_list(struct strbuf *s, struct blob_attr *attr, size_t len, bool array) { struct blob_attr *pos; bool first = true; diff --git a/jshn.c b/jshn.c index 4b947e1..bd34a2c 100644 --- a/jshn.c +++ b/jshn.c @@ -58,12 +58,12 @@ static int add_json_object(json_object *obj) static int add_json_array(struct array_list *a) { - char seq[12]; - int i, len; + char seq[21]; + size_t i, len; int ret; for (i = 0, len = array_list_length(a); i < len; i++) { - snprintf(seq, sizeof(seq), "%d", i); + snprintf(seq, sizeof(seq), "%zu", i); ret = add_json_element(seq, array_list_get_idx(a, i)); if (ret) return ret; diff --git a/json_script.c b/json_script.c index de7e546..d33462b 100644 --- a/json_script.c +++ b/json_script.c @@ -39,7 +39,7 @@ json_script_file_from_blobmsg(const char *name, void *data, int len) { struct json_script_file *f; char *new_name; - int name_len = 0; + size_t name_len = 0; if (name) name_len = strlen(name) + 1; diff --git a/udebug-remote.c b/udebug-remote.c index 7fa0b3a..8894908 100644 --- a/udebug-remote.c +++ b/udebug-remote.c @@ -66,7 +66,7 @@ int udebug_remote_buf_map(struct udebug *ctx, struct udebug_remote_buf *rb, uint return -1; } - rb->pcap_iface = ~0; + rb->pcap_iface = ~0U; rb->node.key = key; avl_insert(&ctx->remote_rings, &rb->node); @@ -82,7 +82,7 @@ void udebug_remote_buf_unmap(struct udebug *ctx, struct udebug_remote_buf *rb) udebug_buf_free(&rb->buf); rb->poll = 0; rb->node.key = NULL; - rb->pcap_iface = ~0; + rb->pcap_iface = ~0U; } int udebug_remote_buf_set_poll(struct udebug *ctx, struct udebug_remote_buf *rb, bool val) @@ -237,7 +237,7 @@ udebug_remote_buf_snapshot(struct udebug_remote_buf *rb) s = calloc_a(sizeof(*s), &ptr_buf, ptr_size * sizeof(*ptr_buf), - &data_buf, data_size); + &data_buf, (size_t)data_size); s->data = memcpy(data_buf, udebug_buf_ptr(&rb->buf, data_start), data_size); s->data_size = data_size; diff --git a/udebug.c b/udebug.c index 1b43f69..09e97ef 100644 --- a/udebug.c +++ b/udebug.c @@ -595,7 +595,7 @@ void udebug_entry_set_length(struct udebug_buf *buf, uint16_t len) int udebug_entry_printf(struct udebug_buf *buf, const char *fmt, ...) { va_list ap; - size_t ret; + int ret; va_start(ap, fmt); ret = udebug_entry_vprintf(buf, fmt, ap);