mbed3 warning cleaning

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2015-11-02 13:10:33 +08:00
parent 3b19386b10
commit 2cd3074746
11 changed files with 67 additions and 29 deletions

View file

@ -151,8 +151,8 @@ int
lws_b64_selftest(void)
{
char buf[64];
int n;
int test;
unsigned int n;
unsigned int test;
static const char * const plaintext[] = {
"sanity check base 64"
};

View file

@ -1,7 +1,7 @@
/*
* libwebsockets - small server side websockets and web server implementation
*
* Copyright (C) 2010-2014 Andy Green <andy@warmcat.com>
* Copyright (C) 2010-2015 Andy Green <andy@warmcat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -40,6 +40,9 @@ int lws_add_http_header_by_name(struct libwebsocket_context *context,
#ifdef LWS_USE_HTTP2
if (wsi->mode == LWS_CONNMODE_HTTP2_SERVING)
return lws_add_http2_header_by_name(context, wsi, name, value, length, p, end);
#else
(void)wsi;
(void)context;
#endif
if (name) {
while (*p < end && *name)
@ -63,9 +66,12 @@ int lws_finalize_http_header(struct libwebsocket_context *context,
unsigned char **p,
unsigned char *end)
{
(void)context;
#ifdef LWS_USE_HTTP2
if (wsi->mode == LWS_CONNMODE_HTTP2_SERVING)
return 0;
#else
(void)wsi;
#endif
if ((long)(end - *p) < 3)
return 1;

View file

@ -845,6 +845,7 @@ lws_is_ssl(struct libwebsocket *wsi)
#ifdef LWS_OPENSSL_SUPPORT
return wsi->use_ssl;
#else
(void)wsi;
return 0;
#endif
}
@ -898,6 +899,7 @@ lws_get_peer_write_allowance(struct libwebsocket *wsi)
return wsi->u.http2.tx_credit;
#else
(void)wsi;
return -1;
#endif
}

View file

@ -25,6 +25,16 @@
#ifdef __cplusplus
#include <cstddef>
#include <cstdarg>
#ifdef MBED_OPERATORS
#include "mbed-drivers/mbed.h"
#include "sal-iface-eth/EthernetInterface.h"
#include "sockets/TCPListener.h"
#include "sal-stack-lwip/lwipv4_init.h"
#define LWS_POSIX 0
#else
#define LWS_POSIX 1
#endif
extern "C" {
#else
#include <stdarg.h>
@ -155,13 +165,13 @@ LWS_VISIBLE LWS_EXTERN void lwsl_hexdump(void *buf, size_t len);
#else /* no debug */
#define lwsl_info(...)
#define lwsl_debug(...)
#define lwsl_parser(...)
#define lwsl_header(...)
#define lwsl_ext(...)
#define lwsl_client(...)
#define lwsl_latency(...)
#define lwsl_info(...) {}
#define lwsl_debug(...) {}
#define lwsl_parser(...) {}
#define lwsl_header(...) {}
#define lwsl_ext(...) {}
#define lwsl_client(...) {}
#define lwsl_latency(...) {}
#define lwsl_hexdump(a, b)
#endif
@ -1262,6 +1272,14 @@ libwebsocket_set_timeout(struct libwebsocket *wsi,
// they recommend that structures larger than 16 bytes be aligned to 16-byte
// boundaries.
//
#if !defined(LWS_SIZEOFPTR)
#define LWS_SIZEOFPTR (sizeof (void *))
#endif
#if !defined(u_int64_t)
#define u_int64_t unsigned long long
#endif
#if __x86_64__
#define _LWS_PAD_SIZE 16 // Intel recommended for best performance.
#else

View file

@ -128,7 +128,7 @@ int lws_issue_raw(struct libwebsocket *wsi, unsigned char *buf, size_t len)
*/
lws_latency_pre(context, wsi);
n = lws_ssl_capable_write(wsi, buf, len);
lws_latency(context, wsi, "send lws_issue_raw", n, n == len);
lws_latency(context, wsi, "send lws_issue_raw", n, (unsigned int)n == len);
switch (n) {
case LWS_SSL_CAPABLE_ERROR:
@ -167,7 +167,7 @@ handle_truncated_send:
return n;
}
if (n == real_len)
if ((unsigned int)n == real_len)
/* what we just sent went out cleanly */
return n;
@ -498,7 +498,7 @@ send_raw:
if (n <= 0)
return n;
if (n == len + pre + post) {
if (n == (int)len + pre + post) {
/* everything in the buffer was handled (or rebuffered...) */
wsi->u.ws.inside_frame = 0;
return orig_len;
@ -583,6 +583,8 @@ lws_ssl_capable_read_no_ssl(struct libwebsocket_context *context,
{
int n;
(void)context;
n = recv(wsi->sock, (char *)buf, len, 0);
if (n >= 0)
return n;
@ -620,5 +622,6 @@ lws_ssl_capable_write_no_ssl(struct libwebsocket *wsi, unsigned char *buf, int l
LWS_VISIBLE int
lws_ssl_pending_no_ssl(struct libwebsocket *wsi)
{
(void)wsi;
return 0;
}

View file

@ -210,7 +210,7 @@ int libwebsocket_parse(
WSI_TOKEN_PATCH_URI,
WSI_TOKEN_DELETE_URI,
};
int n, m;
unsigned int n, m;
switch (wsi->u.hdr.parser_state) {
default:
@ -387,7 +387,7 @@ check_eol:
}
n = issue_char(wsi, c);
if (n < 0)
if ((int)n < 0)
return -1;
if (n > 0)
wsi->u.hdr.parser_state = WSI_TOKEN_SKIPPING;

View file

@ -32,7 +32,7 @@ insert_wsi_socket_into_fds(struct libwebsocket_context *context,
return 1;
}
#ifndef _WIN32
#if !defined(_WIN32) && !defined(MBED_OPERATORS)
if (wsi->sock >= context->max_fds) {
lwsl_err("Socket fd %d is too high (%d)\n",
wsi->sock, context->max_fds);

View file

@ -149,9 +149,15 @@
#define compatible_file_read(amount, fd, buf, len) \
amount = read(fd, buf, len);
#define lws_set_blocking_send(wsi)
#ifdef MBED_OPERATORS
#define lws_socket_is_valid(x) ((x) != NULL)
#define LWS_SOCK_INVALID (NULL)
#else
#define lws_socket_is_valid(x) (x >= 0)
#define LWS_SOCK_INVALID (-1)
#endif
#endif
#ifndef LWS_HAVE_BZERO
#ifndef bzero
@ -619,8 +625,8 @@ struct _lws_http_mode_related {
enum http_version request_version;
enum http_connection_type connection_type;
int content_length;
int content_remain;
unsigned int content_length;
unsigned int content_remain;
};
@ -790,7 +796,7 @@ struct _lws_header_related {
struct _lws_websocket_related {
char *rx_user_buffer;
int rx_user_buffer_head;
unsigned int rx_user_buffer_head;
unsigned char frame_masking_nonce_04[4];
unsigned char frame_mask_index;
size_t rx_packet_length;
@ -901,9 +907,9 @@ lws_rxflow_cache(struct libwebsocket *wsi, unsigned char *buf, int n, int len);
#ifndef LWS_LATENCY
static inline void lws_latency(struct libwebsocket_context *context,
struct libwebsocket *wsi, const char *action,
int ret, int completion) { do { } while (0); }
int ret, int completion) { do { (void)context; (void)wsi; (void)action; (void)ret; (void)completion; } while (0); }
static inline void lws_latency_pre(struct libwebsocket_context *context,
struct libwebsocket *wsi) { do { } while (0); }
struct libwebsocket *wsi) { do { (void)context; (void)wsi; } while (0); }
#else
#define lws_latency_pre(_context, _wsi) lws_latency(_context, _wsi, NULL, 0, 0)
extern void
@ -928,7 +934,7 @@ lws_http_action(struct libwebsocket_context *context, struct libwebsocket *wsi);
LWS_EXTERN int
lws_b64_selftest(void);
#ifdef _WIN32
#if defined(_WIN32) || defined(MBED_OPERATORS)
LWS_EXTERN struct libwebsocket *
wsi_from_fd(struct libwebsocket_context *context, lws_sockfd_type fd);
@ -1111,9 +1117,10 @@ LWS_EXTERN int get_daemonize_pid();
#define get_daemonize_pid() (0)
#endif
#if !defined(MBED_OPERATORS)
LWS_EXTERN int interface_to_sa(struct libwebsocket_context *context,
const char *ifname, struct sockaddr_in *addr, size_t addrlen);
#endif
LWS_EXTERN void lwsl_emit_stderr(int level, const char *line);
#ifdef _WIN32

View file

@ -27,15 +27,17 @@ int lws_context_init_server(struct lws_context_creation_info *info,
{
int n;
lws_sockfd_type sockfd;
#if LWS_POSIX
struct sockaddr_in sin;
socklen_t len = sizeof(sin);
int opt = 1;
struct libwebsocket *wsi;
#ifdef LWS_USE_IPV6
struct sockaddr_in6 serv_addr6;
#endif
struct sockaddr_in serv_addr4;
struct sockaddr *v;
#endif
int opt = 1;
struct libwebsocket *wsi;
/* set up our external listening socket we serve on */
@ -182,7 +184,7 @@ int lws_http_action(struct libwebsocket_context *context,
char content_length_str[32];
char http_version_str[10];
char http_conn_str[20];
int n, count = 0;
unsigned int n, count = 0;
static const unsigned char methods[] = {
WSI_TOKEN_GET_URI,
WSI_TOKEN_POST_URI,
@ -457,7 +459,7 @@ upgrade_ws:
hit = 0;
while (*p && !hit) {
n = 0;
unsigned int n = 0;
while (n < sizeof(protocol_name) - 1 && *p && *p !=',')
protocol_name[n++] = *p++;
protocol_name[n] = '\0';

View file

@ -297,7 +297,7 @@ libwebsocket_service_timeout_check(struct libwebsocket_context *context,
* if we went beyond the allowed time, kill the
* connection
*/
if (sec > wsi->pending_timeout_limit) {
if ((time_t)sec > wsi->pending_timeout_limit) {
lwsl_info("TIMEDOUT WAITING on %d\n", wsi->pending_timeout);
/*
* Since he failed a timeout, he already had a chance to do
@ -371,7 +371,7 @@ libwebsocket_service_fd(struct libwebsocket_context *context,
char draining_flow = 0;
int more;
struct lws_tokens eff_buf;
int pending = 0;
unsigned int pending = 0;
if (context->listen_service_fd)
listen_socket_fds_index = wsi_from_fd(context,context->listen_service_fd)->position_in_fds_table;