mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
build: enable signed vs unsigned warnings on gcc
This enables selected things from -Wextra, can't use -Wextra because it is fussy enough to complain about unused params on functions... they are there for a reason. -Wsign-compare -Wignored-qualifiers not -Wimplicit-fallthrough=3 ... only on gcc 7 -Wtype-limits -Wuninitialized not -Wclobbered ... only on gcc 7ish fix the warnings everywhere they were found.
This commit is contained in:
parent
89cb55ea58
commit
1c70181ca2
34 changed files with 85 additions and 83 deletions
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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:
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -149,7 +149,7 @@ callback_post_demo(struct lws *wsi, enum lws_callback_reasons reason,
|
|||
"<html><body><h1>Form results (after urldecoding)</h1>"
|
||||
"<table><tr><td>Name</td><td>Length</td><td>Value</td></tr>");
|
||||
|
||||
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,
|
||||
"<tr><td><b>%s</b></td><td>%d</td><td>%s</td></tr>",
|
||||
param_names[n],
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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,
|
|||
"<html><body><h1>Form results (after urldecoding)</h1>"
|
||||
"<table><tr><td>Name</td><td>Length</td><td>Value</td></tr>");
|
||||
|
||||
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,
|
||||
"<tr><td><b>%s</b></td><td>%d</td><td>%s</td></tr>",
|
||||
param_names[n],
|
||||
|
|
|
@ -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++;
|
||||
|
|
Loading…
Add table
Reference in a new issue