mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-16 00:00:07 +01:00
x64
warning C4267: '=' : conversion from 'size_t' to '*', possible loss of data
This commit is contained in:
parent
f1a87a9600
commit
e0a50ec5b7
13 changed files with 46 additions and 47 deletions
|
@ -325,7 +325,7 @@ spill:
|
|||
|
||||
eff_buf.token = &wsi->u.ws.rx_user_buffer[
|
||||
LWS_SEND_BUFFER_PRE_PADDING];
|
||||
eff_buf.token_len = wsi->u.ws.rx_user_buffer_head;
|
||||
eff_buf.token_len = (int)wsi->u.ws.rx_user_buffer_head;
|
||||
|
||||
if (lws_ext_callback_for_each_active(wsi,
|
||||
LWS_EXT_CALLBACK_EXTENDED_PAYLOAD_RX,
|
||||
|
@ -351,7 +351,7 @@ spill:
|
|||
|
||||
eff_buf.token = &wsi->u.ws.rx_user_buffer[
|
||||
LWS_SEND_BUFFER_PRE_PADDING];
|
||||
eff_buf.token_len = wsi->u.ws.rx_user_buffer_head;
|
||||
eff_buf.token_len = (int)wsi->u.ws.rx_user_buffer_head;
|
||||
|
||||
if (lws_ext_callback_for_each_active(wsi,
|
||||
LWS_EXT_CALLBACK_PAYLOAD_RX,
|
||||
|
|
|
@ -555,7 +555,7 @@ lws_client_interpret_server_handshake(struct libwebsocket_context *context,
|
|||
}
|
||||
|
||||
p = lws_hdr_simple_ptr(wsi, WSI_TOKEN_PROTOCOL);
|
||||
len = strlen(p);
|
||||
len = (int)strlen(p);
|
||||
|
||||
while (*pc && !okay) {
|
||||
if (!strncmp(pc, p, len) &&
|
||||
|
@ -741,7 +741,7 @@ check_accept:
|
|||
* use a big default for compatibility
|
||||
*/
|
||||
|
||||
n = wsi->protocol->rx_buffer_size;
|
||||
n = (int)wsi->protocol->rx_buffer_size;
|
||||
if (!n)
|
||||
n = LWS_MAX_SOCKET_IO_BUF;
|
||||
n += LWS_SEND_BUFFER_PRE_PADDING + LWS_SEND_BUFFER_POST_PADDING;
|
||||
|
|
|
@ -145,11 +145,11 @@ bail:
|
|||
conn->zs_in.next_in[total_payload + 2] = 0xff;
|
||||
conn->zs_in.next_in[total_payload + 3] = 0xff;
|
||||
|
||||
conn->zs_in.avail_in = total_payload + 4;
|
||||
conn->zs_in.avail_in = (uInt)(total_payload + 4);
|
||||
|
||||
conn->zs_in.next_out =
|
||||
conn->buf_in + LWS_SEND_BUFFER_PRE_PADDING;
|
||||
conn->zs_in.avail_out = conn->buf_in_length;
|
||||
conn->zs_in.avail_out = (uInt)conn->buf_in_length;
|
||||
|
||||
while (1) {
|
||||
n = inflate(&conn->zs_in, Z_SYNC_FLUSH);
|
||||
|
@ -194,7 +194,7 @@ bail:
|
|||
conn->zs_in.next_out = conn->buf_in +
|
||||
LWS_SEND_BUFFER_PRE_PADDING + len_so_far;
|
||||
conn->zs_in.avail_out =
|
||||
conn->buf_in_length - len_so_far;
|
||||
(uInt)(conn->buf_in_length - len_so_far);
|
||||
}
|
||||
|
||||
/* rewrite the buffer pointers and length */
|
||||
|
@ -212,11 +212,11 @@ bail:
|
|||
current_payload = eff_buf->token_len;
|
||||
|
||||
conn->zs_out.next_in = (unsigned char *)eff_buf->token;
|
||||
conn->zs_out.avail_in = current_payload;
|
||||
conn->zs_out.avail_in = (uInt)current_payload;
|
||||
|
||||
conn->zs_out.next_out =
|
||||
conn->buf_out + LWS_SEND_BUFFER_PRE_PADDING;
|
||||
conn->zs_out.avail_out = conn->buf_out_length;
|
||||
conn->zs_out.avail_out = (uInt)conn->buf_out_length;
|
||||
|
||||
while (1) {
|
||||
n = deflate(&conn->zs_out, Z_SYNC_FLUSH);
|
||||
|
@ -259,7 +259,7 @@ bail:
|
|||
conn->zs_out.next_out = (conn->buf_out +
|
||||
LWS_SEND_BUFFER_PRE_PADDING + len_so_far);
|
||||
conn->zs_out.avail_out =
|
||||
(conn->buf_out_length - len_so_far);
|
||||
(uInt)(conn->buf_out_length - len_so_far);
|
||||
}
|
||||
|
||||
conn->compressed_out = 1;
|
||||
|
|
|
@ -104,7 +104,7 @@ lws_issue_raw_ext_access(struct libwebsocket *wsi,
|
|||
int n = 0;
|
||||
|
||||
eff_buf.token = (char *)buf;
|
||||
eff_buf.token_len = len;
|
||||
eff_buf.token_len = (int)len;
|
||||
|
||||
/*
|
||||
* while we have original buf to spill ourselves, or extensions report
|
||||
|
@ -184,7 +184,7 @@ lws_issue_raw_ext_access(struct libwebsocket *wsi,
|
|||
ret = 0;
|
||||
}
|
||||
|
||||
return len;
|
||||
return (int)len;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
32
lib/output.c
32
lib/output.c
|
@ -102,7 +102,7 @@ int lws_issue_raw(struct libwebsocket *wsi, unsigned char *buf, size_t len)
|
|||
/* just ignore sends after we cleared the truncation buffer */
|
||||
if (wsi->state == WSI_STATE_FLUSHING_STORED_SEND_BEFORE_CLOSE &&
|
||||
!wsi->truncated_send_len)
|
||||
return len;
|
||||
return (int)len;
|
||||
|
||||
if (wsi->truncated_send_len && (buf < wsi->truncated_send_malloc ||
|
||||
buf > (wsi->truncated_send_malloc +
|
||||
|
@ -113,7 +113,7 @@ int lws_issue_raw(struct libwebsocket *wsi, unsigned char *buf, size_t len)
|
|||
}
|
||||
|
||||
m = lws_ext_callback_for_each_active(wsi,
|
||||
LWS_EXT_CALLBACK_PACKET_TX_DO_SEND, &buf, len);
|
||||
LWS_EXT_CALLBACK_PACKET_TX_DO_SEND, &buf, (int)len);
|
||||
if (m < 0)
|
||||
return -1;
|
||||
if (m) /* handled */ {
|
||||
|
@ -127,7 +127,7 @@ int lws_issue_raw(struct libwebsocket *wsi, unsigned char *buf, size_t len)
|
|||
* nope, send it on the socket directly
|
||||
*/
|
||||
lws_latency_pre(context, wsi);
|
||||
n = lws_ssl_capable_write(wsi, buf, len);
|
||||
n = lws_ssl_capable_write(wsi, buf, (int)len);
|
||||
lws_latency(context, wsi, "send lws_issue_raw", n, n == len);
|
||||
|
||||
switch (n) {
|
||||
|
@ -152,7 +152,7 @@ handle_truncated_send:
|
|||
if (!wsi->truncated_send_len) {
|
||||
lwsl_info("***** %x partial send completed\n", wsi);
|
||||
/* done with it, but don't free it */
|
||||
n = real_len;
|
||||
n = (int)real_len;
|
||||
if (wsi->state == WSI_STATE_FLUSHING_STORED_SEND_BEFORE_CLOSE) {
|
||||
lwsl_info("***** %x signalling to close now\n", wsi);
|
||||
return -1; /* retry closing now */
|
||||
|
@ -196,7 +196,7 @@ handle_truncated_send:
|
|||
if (wsi->truncated_send_malloc)
|
||||
free(wsi->truncated_send_malloc);
|
||||
|
||||
wsi->truncated_send_allocation = real_len - n;
|
||||
wsi->truncated_send_allocation = (unsigned int)(real_len - n);
|
||||
wsi->truncated_send_malloc = malloc(real_len - n);
|
||||
if (!wsi->truncated_send_malloc) {
|
||||
lwsl_err("truncated send: unable to malloc %d\n",
|
||||
|
@ -205,13 +205,13 @@ handle_truncated_send:
|
|||
}
|
||||
}
|
||||
wsi->truncated_send_offset = 0;
|
||||
wsi->truncated_send_len = real_len - n;
|
||||
wsi->truncated_send_len = (unsigned int)(real_len - n);
|
||||
memcpy(wsi->truncated_send_malloc, buf + n, real_len - n);
|
||||
|
||||
/* since something buffered, force it to get another chance to send */
|
||||
libwebsocket_callback_on_writable(wsi->protocol->owning_server, wsi);
|
||||
|
||||
return real_len;
|
||||
return (int)real_len;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -282,7 +282,7 @@ LWS_VISIBLE int libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf,
|
|||
* pre-TX mangling is not allowed to truncate
|
||||
*/
|
||||
eff_buf.token = (char *)buf;
|
||||
eff_buf.token_len = len;
|
||||
eff_buf.token_len = (int)len;
|
||||
|
||||
switch (protocol) {
|
||||
case LWS_WRITE_PING:
|
||||
|
@ -363,14 +363,14 @@ LWS_VISIBLE int libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf,
|
|||
if (len < 126) {
|
||||
pre += 2;
|
||||
buf[-pre] = n;
|
||||
buf[-pre + 1] = len | is_masked_bit;
|
||||
buf[-pre + 1] = ((unsigned char)len) | is_masked_bit;
|
||||
} else {
|
||||
if (len < 65536) {
|
||||
pre += 4;
|
||||
buf[-pre] = n;
|
||||
buf[-pre + 1] = 126 | is_masked_bit;
|
||||
buf[-pre + 2] = len >> 8;
|
||||
buf[-pre + 3] = len;
|
||||
buf[-pre + 2] =(unsigned char)( len >> 8);
|
||||
buf[-pre + 3] = (unsigned char)len;
|
||||
} else {
|
||||
pre += 10;
|
||||
buf[-pre] = n;
|
||||
|
@ -386,10 +386,10 @@ LWS_VISIBLE int libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf,
|
|||
buf[-pre + 4] = 0;
|
||||
buf[-pre + 5] = 0;
|
||||
#endif
|
||||
buf[-pre + 6] = len >> 24;
|
||||
buf[-pre + 7] = len >> 16;
|
||||
buf[-pre + 8] = len >> 8;
|
||||
buf[-pre + 9] = len;
|
||||
buf[-pre + 6] = (unsigned char)(len >> 24);
|
||||
buf[-pre + 7] = (unsigned char)(len >> 16);
|
||||
buf[-pre + 8] = (unsigned char)(len >> 8);
|
||||
buf[-pre + 9] = (unsigned char)(len);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -465,7 +465,7 @@ send_raw:
|
|||
if (n == len + pre + post) {
|
||||
/* everything in the buffer was handled (or rebuffered...) */
|
||||
wsi->u.ws.inside_frame = 0;
|
||||
return orig_len;
|
||||
return (int)orig_len;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -961,7 +961,7 @@ ping_drop:
|
|||
|
||||
eff_buf.token = &wsi->u.ws.rx_user_buffer[
|
||||
LWS_SEND_BUFFER_PRE_PADDING];
|
||||
eff_buf.token_len = wsi->u.ws.rx_user_buffer_head;
|
||||
eff_buf.token_len = (int)wsi->u.ws.rx_user_buffer_head;
|
||||
|
||||
if (lws_ext_callback_for_each_active(wsi,
|
||||
LWS_EXT_CALLBACK_EXTENDED_PAYLOAD_RX,
|
||||
|
@ -981,7 +981,7 @@ ping_drop:
|
|||
|
||||
eff_buf.token = &wsi->u.ws.rx_user_buffer[
|
||||
LWS_SEND_BUFFER_PRE_PADDING];
|
||||
eff_buf.token_len = wsi->u.ws.rx_user_buffer_head;
|
||||
eff_buf.token_len = (int)wsi->u.ws.rx_user_buffer_head;
|
||||
|
||||
if (lws_ext_callback_for_each_active(wsi,
|
||||
LWS_EXT_CALLBACK_PAYLOAD_RX, &eff_buf, 0) < 0)
|
||||
|
|
|
@ -567,8 +567,8 @@ struct _lws_websocket_related {
|
|||
unsigned int clean_buffer:1; /* buffer not rewritten by extension */
|
||||
|
||||
unsigned char *ping_payload_buf; /* non-NULL if malloc'd */
|
||||
unsigned int ping_payload_alloc; /* length malloc'd */
|
||||
unsigned int ping_payload_len; /* nonzero if PONG pending */
|
||||
size_t ping_payload_alloc; /* length malloc'd */
|
||||
size_t ping_payload_len; /* nonzero if PONG pending */
|
||||
};
|
||||
|
||||
struct libwebsocket {
|
||||
|
|
|
@ -479,7 +479,7 @@ int lws_handshake_server(struct libwebsocket_context *context,
|
|||
* a big default for compatibility
|
||||
*/
|
||||
|
||||
n = wsi->protocol->rx_buffer_size;
|
||||
n = (int)wsi->protocol->rx_buffer_size;
|
||||
if (!n)
|
||||
n = LWS_MAX_SOCKET_IO_BUF;
|
||||
n += LWS_SEND_BUFFER_PRE_PADDING + LWS_SEND_BUFFER_POST_PADDING;
|
||||
|
@ -840,7 +840,6 @@ LWS_VISIBLE int libwebsockets_serve_http_file(
|
|||
{
|
||||
unsigned char *p = context->service_buffer;
|
||||
int ret = 0;
|
||||
int n;
|
||||
|
||||
wsi->u.http.fd = lws_plat_open_file(file, &wsi->u.http.filelen);
|
||||
|
||||
|
@ -855,7 +854,7 @@ LWS_VISIBLE int libwebsockets_serve_http_file(
|
|||
"HTTP/1.0 200 OK\x0d\x0aServer: libwebsockets\x0d\x0a""Content-Type: %s\x0d\x0a",
|
||||
content_type);
|
||||
if (other_headers) {
|
||||
n = strlen(other_headers);
|
||||
size_t n = strlen(other_headers);
|
||||
memcpy(p, other_headers, n);
|
||||
p += n;
|
||||
}
|
||||
|
@ -901,7 +900,7 @@ int libwebsocket_interpret_incoming_packet(struct libwebsocket *wsi,
|
|||
len - n);
|
||||
wsi->u.ws.rxflow_buffer =
|
||||
(unsigned char *)malloc(len - n);
|
||||
wsi->u.ws.rxflow_len = len - n;
|
||||
wsi->u.ws.rxflow_len = (int)(len - n);
|
||||
wsi->u.ws.rxflow_pos = 0;
|
||||
memcpy(wsi->u.ws.rxflow_buffer,
|
||||
buf + n, len - n);
|
||||
|
|
|
@ -212,14 +212,14 @@ sha1_pad(struct sha1_ctxt *ctxt)
|
|||
padlen = 64 - padstart;
|
||||
if (padlen < 8) {
|
||||
bzero(&ctxt->m.b8[padstart], padlen);
|
||||
COUNT += padlen;
|
||||
COUNT += (unsigned char)padlen;
|
||||
COUNT %= 64;
|
||||
sha1_step(ctxt);
|
||||
padstart = COUNT % 64; /* should be 0 */
|
||||
padlen = 64 - padstart; /* should be 64 */
|
||||
}
|
||||
bzero(&ctxt->m.b8[padstart], padlen - 8);
|
||||
COUNT += (padlen - 8);
|
||||
COUNT += (unsigned char)(padlen - 8);
|
||||
COUNT %= 64;
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
PUTPAD(ctxt->c.b8[0]); PUTPAD(ctxt->c.b8[1]);
|
||||
|
@ -250,7 +250,7 @@ sha1_loop(struct sha1_ctxt *ctxt, const unsigned char *input, size_t len)
|
|||
|
||||
copysiz = (gaplen < len - off) ? gaplen : len - off;
|
||||
memcpy(&ctxt->m.b8[gapstart], &input[off], copysiz);
|
||||
COUNT += copysiz;
|
||||
COUNT += (unsigned char)copysiz;
|
||||
COUNT %= 64;
|
||||
ctxt->c.b64[0] += copysiz * 8;
|
||||
if (COUNT % 64 == 0)
|
||||
|
|
|
@ -103,7 +103,7 @@ callback_fraggle(struct libwebsocket_context *context,
|
|||
for (it = 0; it < len; it++)
|
||||
psf->sum += p[it];
|
||||
|
||||
psf->total_message += len;
|
||||
psf->total_message += (int)len;
|
||||
psf->packets_left++;
|
||||
|
||||
if (libwebsocket_is_final_fragment(wsi))
|
||||
|
|
|
@ -163,7 +163,7 @@ dump_handshake_info(struct libwebsocket *wsi)
|
|||
|
||||
const char * get_mimetype(const char *file)
|
||||
{
|
||||
int n = strlen(file);
|
||||
size_t n = strlen(file);
|
||||
|
||||
if (n < 5)
|
||||
return NULL;
|
||||
|
|
|
@ -183,10 +183,10 @@ getopt_long(nargc, nargv, options, long_options, index)
|
|||
return(-1);
|
||||
}
|
||||
if ((has_equal = strchr(current_argv, '=')) != NULL) {
|
||||
current_argv_len = has_equal - current_argv;
|
||||
current_argv_len = (int)(has_equal - current_argv);
|
||||
has_equal++;
|
||||
} else
|
||||
current_argv_len = strlen(current_argv);
|
||||
current_argv_len = (int)strlen(current_argv);
|
||||
|
||||
for (i = 0; long_options[i].name; i++) {
|
||||
if (strncmp(current_argv, long_options[i].name, current_argv_len))
|
||||
|
|
|
@ -265,7 +265,7 @@ local int get_byte(s)
|
|||
if (s->z_eof) return EOF;
|
||||
if (s->stream.avail_in == 0) {
|
||||
errno = 0;
|
||||
s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file);
|
||||
s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file);
|
||||
if (s->stream.avail_in == 0) {
|
||||
s->z_eof = 1;
|
||||
if (ferror(s->file)) s->z_err = Z_ERRNO;
|
||||
|
@ -301,7 +301,7 @@ local void check_header(s)
|
|||
if (len < 2) {
|
||||
if (len) s->inbuf[0] = s->stream.next_in[0];
|
||||
errno = 0;
|
||||
len = fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file);
|
||||
len = (uInt)fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file);
|
||||
if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO;
|
||||
s->stream.avail_in += len;
|
||||
s->stream.next_in = s->inbuf;
|
||||
|
@ -437,7 +437,7 @@ int ZEXPORT gzread (file, buf, len)
|
|||
s->stream.avail_in -= n;
|
||||
}
|
||||
if (s->stream.avail_out > 0) {
|
||||
s->stream.avail_out -= fread(next_out, 1, s->stream.avail_out,
|
||||
s->stream.avail_out -= (uInt)fread(next_out, 1, s->stream.avail_out,
|
||||
s->file);
|
||||
}
|
||||
len -= s->stream.avail_out;
|
||||
|
@ -449,7 +449,7 @@ int ZEXPORT gzread (file, buf, len)
|
|||
if (s->stream.avail_in == 0 && !s->z_eof) {
|
||||
|
||||
errno = 0;
|
||||
s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file);
|
||||
s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file);
|
||||
if (s->stream.avail_in == 0) {
|
||||
s->z_eof = 1;
|
||||
if (ferror(s->file)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue