diff --git a/CMakeLists.txt b/CMakeLists.txt index f5c641feb..1a683fce9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -865,7 +865,7 @@ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_C_COMPILER_ID set(VISIBILITY_FLAG -fvisibility=hidden) endif() if ((UNIX OR LWS_WITH_ESP8266) AND NOT LWS_WITH_ESP32) - set(CMAKE_C_FLAGS "-Wall -Werror ${VISIBILITY_FLAG} -Wundef ${CMAKE_C_FLAGS}" ) + set(CMAKE_C_FLAGS "-Wall -Wsign-compare -Wignored-qualifiers -Wtype-limits -Wuninitialized -Werror ${VISIBILITY_FLAG} -Wundef ${CMAKE_C_FLAGS}" ) else() set(CMAKE_C_FLAGS "-Wall ${VISIBILITY_FLAG} ${CMAKE_C_FLAGS}" ) endif() diff --git a/lib/client/client.c b/lib/client/client.c index f7fa4c760..7614d6730 100644 --- a/lib/client/client.c +++ b/lib/client/client.c @@ -889,7 +889,7 @@ check_extensions: } ext_name[n] = *c++; - if (n < sizeof(ext_name) - 1) + if (n < (int)sizeof(ext_name) - 1) n++; continue; } diff --git a/lib/event-libs/libuv.c b/lib/event-libs/libuv.c index 28dd95921..60c93390f 100644 --- a/lib/event-libs/libuv.c +++ b/lib/event-libs/libuv.c @@ -215,7 +215,7 @@ lws_uv_initloop(struct lws_context *context, uv_loop_t *loop, int tsi) ns = 2; if (pt->context->use_ev_sigint) { - assert(ns <= ARRAY_SIZE(pt->signals)); + assert(ns <= (int)ARRAY_SIZE(pt->signals)); for (n = 0; n < ns; n++) { uv_signal_init(loop, &pt->signals[n]); pt->signals[n].data = pt->context; diff --git a/lib/ext/extension-permessage-deflate.c b/lib/ext/extension-permessage-deflate.c index e2be2ae61..210d46293 100644 --- a/lib/ext/extension-permessage-deflate.c +++ b/lib/ext/extension-permessage-deflate.c @@ -82,11 +82,11 @@ lws_extension_callback_pm_deflate(struct lws_context *context, oa = in; if (!oa->option_name) break; - for (n = 0; n < ARRAY_SIZE(lws_ext_pm_deflate_options); n++) + for (n = 0; n < (int)ARRAY_SIZE(lws_ext_pm_deflate_options); n++) if (!strcmp(lws_ext_pm_deflate_options[n].name, oa->option_name)) break; - if (n == ARRAY_SIZE(lws_ext_pm_deflate_options)) + if (n == (int)ARRAY_SIZE(lws_ext_pm_deflate_options)) break; oa->option_index = n; @@ -377,7 +377,7 @@ lws_extension_callback_pm_deflate(struct lws_context *context, if (priv->tx_held_valid) { priv->tx_held_valid = 0; - if (priv->tx.avail_out == 1 << priv->args[PMD_TX_BUF_PWR2]) + if ((int)priv->tx.avail_out == 1 << priv->args[PMD_TX_BUF_PWR2]) /* * we can get a situation he took something in * but did not generate anything out, at the end diff --git a/lib/http2/hpack.c b/lib/http2/hpack.c index eb1e97cf2..a99a94d0d 100644 --- a/lib/http2/hpack.c +++ b/lib/http2/hpack.c @@ -259,7 +259,7 @@ static int lws_frag_append(struct lws *wsi, unsigned char c) ah->data[ah->pos++] = c; ah->frags[ah->nfrag].len++; - return ah->pos >= wsi->context->max_http_header_data; + return (int)ah->pos >= wsi->context->max_http_header_data; } static int lws_frag_end(struct lws *wsi) @@ -354,8 +354,8 @@ lws_token_from_index(struct lws *wsi, int index, const char **arg, int *len, if (index < 0) return -1; - if (index < ARRAY_SIZE(static_token)) { - if (arg && index < ARRAY_SIZE(http2_canned)) { + if (index < (int)ARRAY_SIZE(static_token)) { + if (arg && index < (int)ARRAY_SIZE(http2_canned)) { *arg = http2_canned[index]; *len = strlen(http2_canned[index]); } @@ -370,8 +370,8 @@ lws_token_from_index(struct lws *wsi, int index, const char **arg, int *len, return -1; } - if (index < ARRAY_SIZE(static_token) || - index >= ARRAY_SIZE(static_token) + dyn->used_entries) { + if (index < (int)ARRAY_SIZE(static_token) || + index >= (int)ARRAY_SIZE(static_token) + dyn->used_entries) { lwsl_err(" %s: adjusted index %d >= %d\n", __func__, index, dyn->used_entries); lws_h2_goaway(wsi, H2_ERR_COMPRESSION_ERROR, @@ -379,7 +379,7 @@ lws_token_from_index(struct lws *wsi, int index, const char **arg, int *len, return -1; } - index -= ARRAY_SIZE(static_token); + index -= (int)ARRAY_SIZE(static_token); index = (dyn->pos - 1 - index) % dyn->num_entries; if (index < 0) index += dyn->num_entries; @@ -575,7 +575,7 @@ lws_hpack_dynamic_size(struct lws *wsi, int size) (int)dyn->num_entries, size, nwsi->u.h2.h2n->set.s[H2SET_HEADER_TABLE_SIZE]); - if (size > nwsi->u.h2.h2n->set.s[H2SET_HEADER_TABLE_SIZE]) { + if (size > (int)nwsi->u.h2.h2n->set.s[H2SET_HEADER_TABLE_SIZE]) { lws_h2_goaway(nwsi, H2_ERR_COMPRESSION_ERROR, "Asked for header table bigger than we told"); goto bail; @@ -693,7 +693,7 @@ lws_hpack_use_idx_hdr(struct lws *wsi, int idx, int known_token) if (arg) p = arg; - if (idx < ARRAY_SIZE(http2_canned)) + if (idx < (int)ARRAY_SIZE(http2_canned)) p = http2_canned[idx]; if (lws_frag_start(wsi, tok)) @@ -1231,7 +1231,7 @@ add_it: static int lws_h2_num_start(int starting_bits, unsigned long num) { - int mask = (1 << starting_bits) - 1; + unsigned int mask = (1 << starting_bits) - 1; if (num < mask) return (int)num; @@ -1243,7 +1243,7 @@ static int lws_h2_num(int starting_bits, unsigned long num, unsigned char **p, unsigned char *end) { - int mask = (1 << starting_bits) - 1; + unsigned int mask = (1 << starting_bits) - 1; if (num < mask) return 0; diff --git a/lib/http2/http2.c b/lib/http2/http2.c index 580eaba54..5df80d7c3 100644 --- a/lib/http2/http2.c +++ b/lib/http2/http2.c @@ -371,7 +371,7 @@ lws_h2_settings(struct lws *wsi, struct http2_settings *settings, w->u.h2.tx_cr + b - settings->s[a]); w->u.h2.tx_cr += b - settings->s[a]; if (w->u.h2.tx_cr > 0 && - w->u.h2.tx_cr <= b - settings->s[a]) + w->u.h2.tx_cr <= (int32_t)(b - settings->s[a])) lws_callback_on_writable(w); } lws_end_foreach_ll(w, u.h2.sibling_list); @@ -480,7 +480,7 @@ int lws_h2_frame_write(struct lws *wsi, int type, int flags, sid, len, wsi->u.h2.tx_cr, nwsi->u.h2.tx_cr); if (type == LWS_H2_FRAME_TYPE_DATA) { - if (wsi->u.h2.tx_cr < len) + if (wsi->u.h2.tx_cr < (int)len) lwsl_err("%s: %p: sending payload len %d" " but tx_cr only %d!\n", __func__, wsi, len, wsi->u.h2.tx_cr); @@ -627,7 +627,7 @@ int lws_h2_do_pps_send(struct lws *wsi) *p++ = pps->u.ga.err; q = (unsigned char *)pps->u.ga.str; n = 0; - while (*q && n++ < sizeof(pps->u.ga.str)) + while (*q && n++ < (int)sizeof(pps->u.ga.str)) *p++ = *q++; h2n->we_told_goaway = 1; n = lws_h2_frame_write(wsi, LWS_H2_FRAME_TYPE_GOAWAY, 0, @@ -1134,7 +1134,7 @@ lws_h2_parse_end_of_frame(struct lws *wsi) } len = lws_hdr_total_length(h2n->swsi, n); - if (!len || len > sizeof(buf) - 1) { + if (!len || len > (int)sizeof(buf) - 1) { n++; continue; } diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 55d156115..5abb1a737 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -1262,7 +1262,7 @@ lws_vfs_select_fops(const struct lws_plat_file_ops *fops, const char *vfs_path, pf = fops->next; while (pf) { n = 0; - while (n < ARRAY_SIZE(pf->fi) && pf->fi[n].sig) { + while (n < (int)ARRAY_SIZE(pf->fi) && pf->fi[n].sig) { if (p >= vfs_path + pf->fi[n].len) if (!strncmp(p - (pf->fi[n].len - 1), pf->fi[n].sig, @@ -1749,7 +1749,7 @@ LWS_VISIBLE void _lws_logv(int filter, const char *format, va_list vl) buf[sizeof(buf) - 1] = '\0'; #else /* vnsprintf returns what it would have written, even if truncated */ - if (n > sizeof(buf) - 1) + if (n > (int)sizeof(buf) - 1) n = sizeof(buf) - 1; if (n > 0) buf[n] = '\0'; diff --git a/lib/output.c b/lib/output.c index ed4752490..61975c979 100644 --- a/lib/output.c +++ b/lib/output.c @@ -653,7 +653,7 @@ LWS_VISIBLE int lws_serve_http_file_fragment(struct lws *wsi) lwsl_info("%s: came here with no tx credit", __func__); return 0; } - if (m < poss) + if ((lws_filepos_t)m < poss) poss = m; /* * consumption of the actual payload amount sent will be handled @@ -746,7 +746,7 @@ LWS_VISIBLE int lws_serve_http_file_fragment(struct lws *wsi) /* adjust for what was not sent */ if (lws_vfs_file_seek_cur(wsi->u.http.fop_fd, m - n) == - (unsigned long)-1) + (lws_fileofs_t)-1) goto file_had_it; } } diff --git a/lib/plat/lws-plat-unix.c b/lib/plat/lws-plat-unix.c index f55369129..74f2af583 100644 --- a/lib/plat/lws-plat-unix.c +++ b/lib/plat/lws-plat-unix.c @@ -193,7 +193,7 @@ faked_service: c = n; /* any socket with events to service? */ - for (n = 0; n < pt->fds_count && c; n++) { + for (n = 0; n < (int)pt->fds_count && c; n++) { if (!pt->fds[n].revents) continue; @@ -738,7 +738,8 @@ _lws_plat_file_seek_cur(lws_fop_fd_t fop_fd, lws_fileofs_t offset) { lws_fileofs_t r; - if (offset > 0 && offset > fop_fd->len - fop_fd->pos) + if (offset > 0 && + offset > (lws_fileofs_t)fop_fd->len - (lws_fileofs_t)fop_fd->pos) offset = fop_fd->len - fop_fd->pos; if ((lws_fileofs_t)fop_fd->pos + offset < 0) diff --git a/lib/pollfd.c b/lib/pollfd.c index 4d6704d41..38d6611ee 100644 --- a/lib/pollfd.c +++ b/lib/pollfd.c @@ -56,7 +56,7 @@ _lws_change_pollfd(struct lws *wsi, int _and, int _or, struct lws_pollargs *pa) context = wsi->context; pt = &context->pt[(int)wsi->tsi]; assert(wsi->position_in_fds_table >= 0 && - wsi->position_in_fds_table < pt->fds_count); + wsi->position_in_fds_table < (int)pt->fds_count); pfd = &pt->fds[wsi->position_in_fds_table]; pa->fd = wsi->desc.sockfd; diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h index 28b58923c..7fb963b27 100644 --- a/lib/private-libwebsockets.h +++ b/lib/private-libwebsockets.h @@ -2502,7 +2502,7 @@ struct lws_rewrite { }; static LWS_INLINE int hstrcmp(hubbub_string *s, const char *p, int len) { - if (s->len != len) + if ((int)s->len != len) return 1; return strncmp((const char *)s->ptr, p, len); diff --git a/lib/server/cgi.c b/lib/server/cgi.c index 1b9dfe45a..410733890 100644 --- a/lib/server/cgi.c +++ b/lib/server/cgi.c @@ -216,7 +216,7 @@ lws_cgi(struct lws *wsi, const char * const *exec_array, int script_uri_path_len }; if (script_uri_path_len >= 0) - for (m = 0; m < ARRAY_SIZE(meths); m++) + for (m = 0; m < (int)ARRAY_SIZE(meths); m++) if (lws_hdr_total_length(wsi, meths[m]) >= script_uri_path_len) { uritok = meths[m]; @@ -703,7 +703,7 @@ post_hpack_recode: */ if (!significant_hdr[n][wsi->cgi->match[n]] && (c >= '0' && c <= '9') && - wsi->cgi->lp < sizeof(wsi->cgi->l) - 1) { + wsi->cgi->lp < (int)sizeof(wsi->cgi->l) - 1) { wsi->cgi->l[wsi->cgi->lp++] = c; wsi->cgi->l[wsi->cgi->lp] = '\0'; switch (n) { diff --git a/lib/server/fops-zip.c b/lib/server/fops-zip.c index 2b254f67a..1f0bf416e 100644 --- a/lib/server/fops-zip.c +++ b/lib/server/fops-zip.c @@ -241,13 +241,13 @@ lws_fops_zip_scan(lws_fops_zip_t priv, const char *name, int len) if (priv->hdr.filename_len != len) goto next; - if (len >= sizeof(buf) - 1) + if (len >= (int)sizeof(buf) - 1) return LWS_FZ_ERR_NAME_TOO_LONG; if (priv->zip_fop_fd->fops->LWS_FOP_READ(priv->zip_fop_fd, &amount, buf, len)) return LWS_FZ_ERR_NAME_READ; - if (amount != len) + if ((int)amount != len) return LWS_FZ_ERR_NAME_READ; buf[len] = '\0'; @@ -565,7 +565,7 @@ spin: switch (ret) { case Z_NEED_DICT: ret = Z_DATA_ERROR; - /* and fall through */ + /* fallthru */ case Z_DATA_ERROR: case Z_MEM_ERROR: diff --git a/lib/server/lejp-conf.c b/lib/server/lejp-conf.c index a60573718..565e2da9d 100644 --- a/lib/server/lejp-conf.c +++ b/lib/server/lejp-conf.c @@ -216,7 +216,7 @@ arg_to_bool(const char *s) if (n) return 1; - for (n = 0; n < ARRAY_SIZE(on); n++) + for (n = 0; n < (int)ARRAY_SIZE(on); n++) if (!strcasecmp(s, on[n])) return 1; @@ -474,7 +474,7 @@ lejp_vhosts_cb(struct lejp_ctx *ctx, char reason) if (a->last) a->last->mount_next = m; - for (n = 0; n < ARRAY_SIZE(mount_protocols); n++) + for (n = 0; n < (int)ARRAY_SIZE(mount_protocols); n++) if (!strncmp(a->m.origin, mount_protocols[n], strlen(mount_protocols[n]))) { lwsl_info("----%s\n", a->m.origin); @@ -484,7 +484,7 @@ lejp_vhosts_cb(struct lejp_ctx *ctx, char reason) break; } - if (n == ARRAY_SIZE(mount_protocols)) { + if (n == (int)ARRAY_SIZE(mount_protocols)) { lwsl_err("unsupported protocol:// %s\n", a->m.origin); return 1; } diff --git a/lib/server/lws-spa.c b/lib/server/lws-spa.c index 73117c504..ee289466d 100644 --- a/lib/server/lws-spa.c +++ b/lib/server/lws-spa.c @@ -108,7 +108,7 @@ lws_urldecode_s_create(struct lws *wsi, char *out, int out_len, void *data, s->mime_boundary[m++] = '\x0a'; s->mime_boundary[m++] = '-'; s->mime_boundary[m++] = '-'; - while (m < sizeof(s->mime_boundary) - 1 && + while (m < (int)sizeof(s->mime_boundary) - 1 && *p && *p != ' ') s->mime_boundary[m++] = *p++; @@ -160,7 +160,7 @@ lws_urldecode_s_process(struct lws_urldecode_stateful *s, const char *in, in++; continue; } - if (s->pos >= sizeof(s->name) - 1) { + if (s->pos >= (int)sizeof(s->name) - 1) { lwsl_notice("Name too long\n"); return -1; } @@ -258,7 +258,7 @@ retry_as_first: c =*in; if (c >= 'A' && c <= 'Z') c += 'a' - 'A'; - for (n = 0; n < ARRAY_SIZE(mp_hdr); n++) + for (n = 0; n < (int)ARRAY_SIZE(mp_hdr); n++) if (c == mp_hdr[n][s->mp]) { m++; hit = n; @@ -317,28 +317,28 @@ retry_as_first: s->mp = 0; goto done; } - if (s->mp < sizeof(s->temp) - 1 && + if (s->mp < (int)sizeof(s->temp) - 1 && (*in != ' ' || s->inside_quote)) s->temp[s->mp++] = *in; goto done; } if (!s->temp[0]) { - if (s->mp < sizeof(s->content_disp) - 1) + if (s->mp < (int)sizeof(s->content_disp) - 1) s->content_disp[s->mp++] = *in; s->content_disp[s->mp] = '\0'; goto done; } if (!strcmp(s->temp, "name")) { - if (s->mp < sizeof(s->name) - 1) + if (s->mp < (int)sizeof(s->name) - 1) s->name[s->mp++] = *in; s->name[s->mp] = '\0'; goto done; } if (!strcmp(s->temp, "filename")) { - if (s->mp < sizeof(s->content_disp_filename) - 1) + if (s->mp < (int)sizeof(s->content_disp_filename) - 1) s->content_disp_filename[s->mp++] = *in; s->content_disp_filename[s->mp] = '\0'; goto done; @@ -351,7 +351,7 @@ done: if (*in == '\x0d') s->state = MT_IGNORE2; else { - if (s->mp < sizeof(s->content_type) - 1) + if (s->mp < (int)sizeof(s->content_type) - 1) s->content_type[s->mp++] = *in; s->content_type[s->mp] = '\0'; } diff --git a/lib/server/parsers.c b/lib/server/parsers.c index f4c412d82..71091287a 100644 --- a/lib/server/parsers.c +++ b/lib/server/parsers.c @@ -597,7 +597,7 @@ lws_pos_in_bounds(struct lws *wsi) (unsigned int)wsi->context->max_http_header_data) return 0; - if (wsi->u.hdr.ah->pos == wsi->context->max_http_header_data) { + if ((int)wsi->u.hdr.ah->pos == wsi->context->max_http_header_data) { lwsl_err("Ran out of header data space\n"); return 1; } diff --git a/lib/server/peer-limits.c b/lib/server/peer-limits.c index daaae9c96..7ddb9a43c 100644 --- a/lib/server/peer-limits.c +++ b/lib/server/peer-limits.c @@ -89,7 +89,7 @@ lws_get_or_create_peer(struct lws_vhost *vhost, lws_sockfd_type sockfd) #endif q8 = q; - for (n = 0; n < rlen; n++) + for (n = 0; n < (int)rlen; n++) hash = (((hash << 4) | (hash >> 28)) * n) ^ q8[n]; hash = hash % context->pl_hash_elements; diff --git a/lib/server/server-handshake.c b/lib/server/server-handshake.c index 3d319c35d..ba471b29d 100644 --- a/lib/server/server-handshake.c +++ b/lib/server/server-handshake.c @@ -85,7 +85,7 @@ lws_extension_server_handshake(struct lws *wsi, char **p, int budget) continue; } ext_name[n] = *c++; - if (n < sizeof(ext_name) - 1) + if (n < (int)sizeof(ext_name) - 1) n++; continue; } diff --git a/lib/server/server.c b/lib/server/server.c index 27237a9e9..1b0def6e5 100644 --- a/lib/server/server.c +++ b/lib/server/server.c @@ -752,7 +752,7 @@ lws_http_get_uri_and_method(struct lws *wsi, char **puri_ptr, int *puri_len) { int n, count = 0; - for (n = 0; n < ARRAY_SIZE(methods); n++) + for (n = 0; n < (int)ARRAY_SIZE(methods); n++) if (lws_hdr_total_length(wsi, methods[n])) count++; if (!count) { @@ -767,7 +767,7 @@ lws_http_get_uri_and_method(struct lws *wsi, char **puri_ptr, int *puri_len) return -1; } - for (n = 0; n < ARRAY_SIZE(methods); n++) + for (n = 0; n < (int)ARRAY_SIZE(methods); n++) if (lws_hdr_total_length(wsi, methods[n])) { *puri_ptr = lws_hdr_simple_ptr(wsi, methods[n]); *puri_len = lws_hdr_total_length(wsi, methods[n]); @@ -797,7 +797,7 @@ lws_http_action(struct lws *wsi) }; meth = lws_http_get_uri_and_method(wsi, &uri_ptr, &uri_len); - if (meth < 0 || meth >= ARRAY_SIZE(method_names)) + if (meth < 0 || meth >= (int)ARRAY_SIZE(method_names)) goto bail_nuke_ah; /* we insist on absolute paths */ @@ -1064,7 +1064,7 @@ lws_http_action(struct lws *wsi) else n = pslash - hit->origin; - if (n >= sizeof(ads) - 2) + if (n >= (int)sizeof(ads) - 2) n = sizeof(ads) - 2; memcpy(ads, hit->origin, n); @@ -1569,7 +1569,7 @@ upgrade_h2c: "Upgrade: h2c\x0d\x0a\x0d\x0a"); n = lws_issue_raw(wsi, (unsigned char *)protocol_list, strlen(protocol_list)); - if (n != strlen(protocol_list)) { + if (n != (int)strlen(protocol_list)) { lwsl_debug("http2 switch: ERROR writing to socket\n"); return 1; } @@ -1606,7 +1606,7 @@ upgrade_ws: while (*p && !hit) { n = 0; non_space_char_found = 0; - while (n < sizeof(protocol_name) - 1 && + while (n < (int)sizeof(protocol_name) - 1 && *p && *p != ',') { /* ignore leading spaces */ if (!non_space_char_found && *p == ' ') { @@ -2952,7 +2952,7 @@ skip: sp = s->start + 1; continue; } - if (hits == 1 && s->pos == strlen(s->vars[hit])) { + if (hits == 1 && s->pos == (int)strlen(s->vars[hit])) { pc = s->replace(s->data, hit); if (!pc) pc = "NULL"; diff --git a/lib/service.c b/lib/service.c index 37366757a..1de44ad73 100644 --- a/lib/service.c +++ b/lib/service.c @@ -877,7 +877,7 @@ spin_chunks: return 0; if (wsi->u.http.rx_content_remain && - wsi->u.http.rx_content_remain < *len) + wsi->u.http.rx_content_remain < (unsigned int)*len) n = (int)wsi->u.http.rx_content_remain; else n = *len; @@ -1069,7 +1069,7 @@ lws_service_fd_tsi(struct lws_context *context, struct lws_pollfd *pollfd, int t break; len = lws_hdr_total_length(wsi, m); - if (!len || len > sizeof(buf) - 1) { + if (!len || len > (int)sizeof(buf) - 1) { m++; continue; } @@ -1448,7 +1448,7 @@ read: pending = eff_buf.token_len; eff_buf.token_len = lws_ssl_capable_read(wsi, - (unsigned char *)eff_buf.token, pending ? pending : + (unsigned char *)eff_buf.token, pending ? (int)pending : eff_buf.token_len); switch (eff_buf.token_len) { case 0: diff --git a/lib/tls/mbedtls/server.c b/lib/tls/mbedtls/server.c index e137b73d8..aa411c353 100644 --- a/lib/tls/mbedtls/server.c +++ b/lib/tls/mbedtls/server.c @@ -79,7 +79,7 @@ int alloc_file(struct lws_context *context, const char *filename, uint8_t **buf, } s = ftell(f); - if (s == -1) { + if (s == (size_t)-1) { n = 1; goto bail; } diff --git a/lwsws/main.c b/lwsws/main.c index 16307f527..dda9016ee 100644 --- a/lwsws/main.c +++ b/lwsws/main.c @@ -179,7 +179,7 @@ reload_handler(int signum) fprintf(stderr, "root process receives reload\n"); if (!do_reload) { fprintf(stderr, "passing HUP to child processes\n"); - for (m = 0; m < ARRAY_SIZE(pids); m++) + for (m = 0; m < (int)ARRAY_SIZE(pids); m++) if (pids[m]) kill(pids[m], SIGHUP); sleep(1); @@ -190,7 +190,7 @@ reload_handler(int signum) case SIGTERM: case SIGKILL: fprintf(stderr, "killing service processes\n"); - for (m = 0; m < ARRAY_SIZE(pids); m++) + for (m = 0; m < (int)ARRAY_SIZE(pids); m++) if (pids[m]) kill(pids[m], SIGTERM); exit(0); @@ -249,7 +249,7 @@ int main(int argc, char **argv) break; /* old */ if (n > 0) - for (m = 0; m < ARRAY_SIZE(pids); m++) + for (m = 0; m < (int)ARRAY_SIZE(pids); m++) if (!pids[m]) { // fprintf(stderr, "added child pid %d\n", n); pids[m] = n; @@ -261,7 +261,7 @@ int main(int argc, char **argv) n = waitpid(-1, &status, WNOHANG); if (n > 0) - for (m = 0; m < ARRAY_SIZE(pids); m++) + for (m = 0; m < (int)ARRAY_SIZE(pids); m++) if (pids[m] == n) { // fprintf(stderr, "reaped child pid %d\n", pids[m]); pids[m] = 0; diff --git a/plugins/generic-sessions/handlers.c b/plugins/generic-sessions/handlers.c index 88494dc5d..8b8665f6c 100644 --- a/plugins/generic-sessions/handlers.c +++ b/plugins/generic-sessions/handlers.c @@ -289,7 +289,7 @@ lwsgs_handler_change_password(struct per_vhost_data__gs *vhd, struct lws *wsi, return 1; /* did a forgot pw ? */ - if (u.last_forgot_validated > lws_now_secs() - 300) { + if (u.last_forgot_validated > (time_t)lws_now_secs() - 300) { n |= LWSGS_AUTH_FORGOT_FLOW; lwsl_debug("within forgot password flow\n"); } diff --git a/plugins/generic-sessions/utils.c b/plugins/generic-sessions/utils.c index c6adc5e11..7db4369e6 100644 --- a/plugins/generic-sessions/utils.c +++ b/plugins/generic-sessions/utils.c @@ -146,7 +146,7 @@ lwsgw_session_from_cookie(const char *cookie, lwsgw_hash *sid) return 1; } - for (n = 0; n < sizeof(sid->id) - 1 && *p; n++) { + for (n = 0; n < (int)sizeof(sid->id) - 1 && *p; n++) { /* our SID we issue only has these chars */ if ((*p >= '0' && *p <= '9') || (*p >= 'a' && *p <= 'f')) @@ -157,7 +157,7 @@ lwsgw_session_from_cookie(const char *cookie, lwsgw_hash *sid) } } - if (n < sizeof(sid->id) - 1) { + if (n < (int)sizeof(sid->id) - 1) { lwsl_info("cookie id too short\n"); return 1; } @@ -376,7 +376,7 @@ lwsgs_get_auth_level(struct per_vhost_data__gs *vhd, if ((u.verified & 0xff) == LWSGS_VERIFIED_ACCEPTED) n |= LWSGS_AUTH_VERIFIED; - if (u.last_forgot_validated > lws_now_secs() - 300) + if (u.last_forgot_validated > (time_t)lws_now_secs() - 300) n |= LWSGS_AUTH_FORGOT_FLOW; } diff --git a/plugins/generic-table/protocol_table_dirlisting.c b/plugins/generic-table/protocol_table_dirlisting.c index 0734a14b3..f8787980c 100644 --- a/plugins/generic-table/protocol_table_dirlisting.c +++ b/plugins/generic-table/protocol_table_dirlisting.c @@ -263,7 +263,7 @@ callback_lws_table_dirlisting(struct lws *wsi, enum lws_callback_reasons reason, q += strlen(q); } else { n = q1 - q; - if (n > sizeof(s) - 1) + if (n > (int)sizeof(s) - 1) n = sizeof(s) - 1; if (first) { strcpy(s1, "/"); @@ -273,7 +273,7 @@ callback_lws_table_dirlisting(struct lws *wsi, enum lws_callback_reasons reason, s[n] = '\0'; n = q1 - pss->reldir; - if (n > sizeof(s1) - 1) + if (n > (int)sizeof(s1) - 1) n = sizeof(s1) - 1; strncpy(s1, pss->reldir, n); s1[n] = '\0'; diff --git a/plugins/protocol_post_demo.c b/plugins/protocol_post_demo.c index 6be73fbd5..b5d5e8280 100644 --- a/plugins/protocol_post_demo.c +++ b/plugins/protocol_post_demo.c @@ -149,7 +149,7 @@ callback_post_demo(struct lws *wsi, enum lws_callback_reasons reason, "

Form results (after urldecoding)

" ""); - for (n = 0; n < ARRAY_SIZE(param_names); n++) + for (n = 0; n < (int)ARRAY_SIZE(param_names); n++) p += lws_snprintf((char *)p, end - p, "", param_names[n], diff --git a/plugins/ssh-base/kex-25519.c b/plugins/ssh-base/kex-25519.c index 7223ac194..3e9eaa7d8 100644 --- a/plugins/ssh-base/kex-25519.c +++ b/plugins/ssh-base/kex-25519.c @@ -146,7 +146,7 @@ ed25519_key_parse(uint8_t *p, size_t len, char *type, size_t type_len, return 6; publ = lws_g32(&p); /* length of pubkey block */ - if ((p - op) + publ >= len) + if ((size_t)((p - op) + publ) >= len) return 7; l = lws_g32(&p); /* key type length */ @@ -166,7 +166,7 @@ ed25519_key_parse(uint8_t *p, size_t len, char *type, size_t type_len, p += l; publ = lws_g32(&p); /* length of private key block */ - if ((p - op) + publ != len) + if ((size_t)((p - op) + publ) != len) return 11; l = lws_g32(&p); /* checkint 1 */ @@ -363,7 +363,7 @@ kex_ecdh(struct per_session_data__sshd *pss, uint8_t *reply, uint32_t *plen) crypto_scalarmult_curve25519(kex->Q_S, kex->eph_pri_key, basepoint); a = 0; - for (r = 0; r < sizeof(kex->Q_S); r++) + for (r = 0; r < (int)sizeof(kex->Q_S); r++) a |= kex->Q_S[r]; if (!a) { lwsl_notice("all zero pubkey\n"); diff --git a/plugins/ssh-base/sshd.c b/plugins/ssh-base/sshd.c index c4b0e0ff2..751d52b42 100644 --- a/plugins/ssh-base/sshd.c +++ b/plugins/ssh-base/sshd.c @@ -1332,6 +1332,7 @@ again: if (!m) { /* the decrypted sig is in ASN1 format */ m = 0; + while (m < olen) { /* sig payload */ if (otmp[m] == 0x04 && @@ -2271,7 +2272,7 @@ lws_callback_raw_sshd(struct lws *wsi, enum lws_callback_reasons reason, * string public key blob from the request */ n = 74 + pss->ua->pubkey_len; - if (n > sizeof(buf) - LWS_PRE) { + if (n > (int)sizeof(buf) - LWS_PRE) { lwsl_notice("pubkey too large\n"); goto bail; } diff --git a/test-apps/fuzxy.c b/test-apps/fuzxy.c index c6a0f0db1..555e32fb1 100644 --- a/test-apps/fuzxy.c +++ b/test-apps/fuzxy.c @@ -354,7 +354,7 @@ fuzxy_tok(const char **src, unsigned char **buf, int *len) return -1; rlen = *buf - start; while (count--) { - if (*len < rlen) { + if (*len < (int)rlen) { lwsl_err("out of space\n"); return -1; } @@ -587,7 +587,7 @@ inject: case FZY_FP_INJECT: out[m++] = s->buf[s->fuzc++]; - if (s->fuzc == s->inject_len) + if (s->fuzc == (int)s->inject_len) s->fp = FZY_FP_PENDING; break; diff --git a/test-apps/test-client.c b/test-apps/test-client.c index ea7d0826f..40134680b 100644 --- a/test-apps/test-client.c +++ b/test-apps/test-client.c @@ -125,7 +125,7 @@ callback_dumb_increment(struct lws *wsi, enum lws_callback_reasons reason, wsi_mirror = NULL; } - for (n = 0; n < ARRAY_SIZE(wsi_multi); n++) + for (n = 0; n < (int)ARRAY_SIZE(wsi_multi); n++) if (wsi == wsi_multi[n]) { sprintf(which_wsi, "multi %d", n); which = which_wsi; @@ -657,7 +657,7 @@ int main(int argc, char **argv) while (!force_exit) { if (do_multi) { - for (n = 0; n < ARRAY_SIZE(wsi_multi); n++) { + for (n = 0; n < (int)ARRAY_SIZE(wsi_multi); n++) { if (!wsi_multi[n] && ratelimit_connects(&rl_multi[n], 2u)) { lwsl_notice("dumb %d: connecting\n", n); i.protocol = protocols[PROTOCOL_DUMB_INCREMENT].name; diff --git a/test-apps/test-echo.c b/test-apps/test-echo.c index 1b1115fc3..0691b04bb 100644 --- a/test-apps/test-echo.c +++ b/test-apps/test-echo.c @@ -496,7 +496,7 @@ int main(int argc, char **argv) if (client && !versa && times) { gettimeofday(&tv, NULL); - if (((((unsigned long long)tv.tv_sec * 1000000) + tv.tv_usec) - oldus) > rate_us) { + if ((int)((((unsigned long long)tv.tv_sec * 1000000) + tv.tv_usec) - oldus) > rate_us) { lws_callback_on_writable_all_protocol(context, &protocols[0]); oldus = ((unsigned long long)tv.tv_sec * 1000000) + tv.tv_usec; diff --git a/test-apps/test-ping.c b/test-apps/test-ping.c index 391778112..87307ec65 100644 --- a/test-apps/test-ping.c +++ b/test-apps/test-ping.c @@ -275,7 +275,7 @@ callback_lws_mirror(struct lws *wsi, enum lws_callback_reasons reason, } if (flood && - (psd->ping_index - psd->rx_count) < (screen_width - 1)) + (int)(psd->ping_index - psd->rx_count) < (screen_width - 1)) fprintf(stderr, "."); break; diff --git a/test-apps/test-server-http.c b/test-apps/test-server-http.c index 2e8126b4a..3507d3c0c 100644 --- a/test-apps/test-server-http.c +++ b/test-apps/test-server-http.c @@ -80,7 +80,7 @@ dump_handshake_info(struct lws *wsi) } len = lws_hdr_total_length(wsi, n); - if (!len || len > sizeof(buf) - 1) { + if (!len || len > (int)sizeof(buf) - 1) { n++; continue; } @@ -471,7 +471,7 @@ int callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user, "

Form results (after urldecoding)

" "
NameLengthValue
%s%d%s
"); - for (n = 0; n < ARRAY_SIZE(param_names); n++) + for (n = 0; n < (int)ARRAY_SIZE(param_names); n++) p += lws_snprintf((char *)p, end - p, "", param_names[n], diff --git a/test-apps/test-sshd.c b/test-apps/test-sshd.c index a881f2844..add5e2312 100644 --- a/test-apps/test-sshd.c +++ b/test-apps/test-sshd.c @@ -483,7 +483,7 @@ ssh_ops_child_process_io(void *_priv, struct lws *wsi, n = bytes / 2; else n = 1; - if (n > sizeof(buf)) + if (n > (int)sizeof(buf)) n = sizeof(buf); if (!n) @@ -513,7 +513,7 @@ ssh_ops_child_process_io(void *_priv, struct lws *wsi, *p++ = *d++; } n = (void *)p - rp; - if (n < bytes && priv->insert_lf) { + if (n < (int)bytes && priv->insert_lf) { priv->insert_lf = 0; *p++ = 0x0d; n++;
NameLengthValue
%s%d%s