* we do not care about how it went, we are closing
* immediately afterwards
*/
- lws_write(wsi, (unsigned char *)
- &wsi->u.ws.rx_ubuf[
- LWS_PRE],
- wsi->u.ws.rx_ubuf_head, LWS_WRITE_CLOSE);
+ lws_write(wsi,
+ (unsigned char *)&wsi->u.ws.rx_ubuf[LWS_PRE],
+ wsi->u.ws.rx_ubuf_head, LWS_WRITE_CLOSE);
wsi->state = LWSS_RETURNED_CLOSE_ALREADY;
/* close the connection */
return -1;
if (addr4.sin_family == AF_UNSPEC)
return -1;
- lws_plat_inet_ntop(AF_INET, &addr4.sin_addr, rip, rip_len);
+ if (lws_plat_inet_ntop(AF_INET, &addr4.sin_addr, rip, rip_len) == NULL)
+ return -1;
return 0;
#else
#if defined(__GNUC__)
#define LWS_VISIBLE __attribute__((visibility("default")))
+#define LWS_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
#else
#define LWS_VISIBLE
+#define LWS_WARN_UNUSED_RESULT
#endif
#if defined(__ANDROID__)
lws_cancel_service(struct lws_context *context);
LWS_VISIBLE LWS_EXTERN int
-lws_interface_to_sa(int ipv6, const char *ifname, struct sockaddr_in *addr, size_t addrlen);
+lws_interface_to_sa(int ipv6, const char *ifname, struct sockaddr_in *addr,
+ size_t addrlen);
LWS_VISIBLE LWS_EXTERN const unsigned char *
lws_token_to_string(enum lws_token_indexes token);
lws_get_peer_write_allowance(struct lws *wsi);
/* deprecated, use lws_client_connect_via_info() */
-LWS_VISIBLE LWS_EXTERN struct lws *
+LWS_VISIBLE LWS_EXTERN struct lws * LWS_WARN_UNUSED_RESULT
lws_client_connect(struct lws_context *clients, const char *address,
int port, int ssl_connection, const char *path,
const char *host, const char *origin, const char *protocol,
int ietf_version_or_minus_one);
/* deprecated, use lws_client_connect_via_info() */
-LWS_VISIBLE LWS_EXTERN struct lws *
+LWS_VISIBLE LWS_EXTERN struct lws * LWS_WARN_UNUSED_RESULT
lws_client_connect_extended(struct lws_context *clients, const char *address,
int port, int ssl_connection, const char *path,
const char *host, const char *origin,
const char *protocol, int ietf_version_or_minus_one,
void *userdata);
-LWS_VISIBLE LWS_EXTERN struct lws *
+LWS_VISIBLE LWS_EXTERN struct lws * LWS_WARN_UNUSED_RESULT
lws_client_connect_via_info(struct lws_client_connect_info * ccinfo);
-LWS_VISIBLE LWS_EXTERN const char *
+LWS_VISIBLE LWS_EXTERN const char * LWS_WARN_UNUSED_RESULT
lws_canonical_hostname(struct lws_context *context);
LWS_VISIBLE LWS_EXTERN int
lws_get_random(struct lws_context *context, void *buf, int len);
-LWS_VISIBLE LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_daemonize(const char *_lock_path);
-LWS_VISIBLE LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_send_pipe_choked(struct lws *wsi);
-LWS_VISIBLE LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_partial_buffered(struct lws *wsi);
-LWS_VISIBLE LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_frame_is_binary(struct lws *wsi);
LWS_VISIBLE LWS_EXTERN int
LWS_VISIBLE LWS_EXTERN int
lws_b64_decode_string(const char *in, char *out, int out_size);
-LWS_VISIBLE LWS_EXTERN const char *
+LWS_VISIBLE LWS_EXTERN const char * LWS_WARN_UNUSED_RESULT
lws_get_library_version(void);
-LWS_VISIBLE LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_parse_uri(char *p, const char **prot, const char **ads, int *port,
const char **path);
* will fail with a nonzero return code.
*/
-LWS_VISIBLE LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_hdr_total_length(struct lws *wsi, enum lws_token_indexes h);
-LWS_VISIBLE LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_hdr_fragment_length(struct lws *wsi, enum lws_token_indexes h, int frag_idx);
/*
/*
* copies only fragment frag_idx of a header. Normally this is only useful
- * to parse URI arguments like ?x=1&y=2, oken index WSI_TOKEN_HTTP_URI_ARGS
+ * to parse URI arguments like ?x=1&y=2, token index WSI_TOKEN_HTTP_URI_ARGS
* fragment 0 will contain "x=1" and fragment 1 "y=2"
*/
LWS_VISIBLE LWS_EXTERN int
/* get the active file operations struct */
-LWS_VISIBLE LWS_EXTERN struct lws_plat_file_ops *
+LWS_VISIBLE LWS_EXTERN struct lws_plat_file_ops * LWS_WARN_UNUSED_RESULT
lws_get_fops(struct lws_context *context);
-LWS_VISIBLE LWS_EXTERN struct lws_context *
+LWS_VISIBLE LWS_EXTERN struct lws_context * LWS_WARN_UNUSED_RESULT
lws_get_context(const struct lws *wsi);
-LWS_VISIBLE LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_get_count_threads(struct lws_context *context);
/*
* without having to deal with differences between platforms.
*/
-static LWS_INLINE lws_filefd_type
+static LWS_INLINE lws_filefd_type LWS_WARN_UNUSED_RESULT
lws_plat_file_open(struct lws *wsi, const char *filename,
unsigned long *filelen, int flags)
{
return lws_get_fops(lws_get_context(wsi))->seek_cur(wsi, fd, offset);
}
-static LWS_INLINE int
+static LWS_INLINE int LWS_WARN_UNUSED_RESULT
lws_plat_file_read(struct lws *wsi, lws_filefd_type fd, unsigned long *amount,
unsigned char *buf, unsigned long len)
{
len);
}
-static LWS_INLINE int
+static LWS_INLINE int LWS_WARN_UNUSED_RESULT
lws_plat_file_write(struct lws *wsi, lws_filefd_type fd, unsigned long *amount,
unsigned char *buf, unsigned long len)
{
#ifndef LWS_NO_EXTENSIONS
/* deprecated */
#define lws_get_internal_extensions() NULL
-LWS_VISIBLE LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_ext_parse_options(const struct lws_extension *ext, struct lws *wsi,
void *ext_user, const struct lws_ext_options *opts, const char *o, int len);
#endif
if (wsi->protocol->callback)
/* ignore callback returned value */
- user_callback_handle_rxflow(
- wsi->protocol->callback, wsi,
- LWS_CALLBACK_HTTP_FILE_COMPLETION,
- wsi->user_space, NULL, 0);
+ if (user_callback_handle_rxflow(
+ wsi->protocol->callback, wsi,
+ LWS_CALLBACK_HTTP_FILE_COMPLETION,
+ wsi->user_space, NULL, 0) < 0)
+ return -1;
return 1; /* >0 indicates completed */
}
}
#define FAIL_CHAR 0x08
-int lextable_decode(int pos, char c)
+int
+LWS_WARN_UNUSED_RESULT lextable_decode(int pos, char c)
{
if (c >= 'A' && c <= 'Z')
c += 'a' - 'A';
}
}
-int lws_allocate_header_table(struct lws *wsi)
+int
+LWS_WARN_UNUSED_RESULT lws_allocate_header_table(struct lws *wsi)
{
struct lws_context *context = wsi->context;
int n;
return -1;
}
-static int issue_char(struct lws *wsi, unsigned char c)
+static int LWS_WARN_UNUSED_RESULT
+issue_char(struct lws *wsi, unsigned char c)
{
unsigned short frag_len;
return 1;
}
-int lws_parse(struct lws *wsi, unsigned char c)
+int LWS_WARN_UNUSED_RESULT
+lws_parse(struct lws *wsi, unsigned char c)
{
static const unsigned char methods[] = {
WSI_TOKEN_GET_URI,
case URIES_SEEN_PERCENT_H1:
if (char_to_hex(c) < 0) {
/* regurgitate */
- issue_char(wsi, '%');
+ if (issue_char(wsi, '%') < 0)
+ return -1;
wsi->u.hdr.ues = URIES_IDLE;
/* regurgitate + assess */
if (lws_parse(wsi, wsi->u.hdr.esc_stash) < 0)
LWS_EXTERN void
lws_set_protocol_write_pending(struct lws *wsi,
enum lws_pending_protocol_send pend);
-LWS_EXTERN int
+LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_client_rx_sm(struct lws *wsi, unsigned char c);
-LWS_EXTERN int
+LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_parse(struct lws *wsi, unsigned char c);
-LWS_EXTERN int
+LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_http_action(struct lws *wsi);
LWS_EXTERN int
#define delete_from_fd(A,B) A->lws_lookup[B]=0
#endif
-LWS_EXTERN int
+LWS_EXTERN int LWS_WARN_UNUSED_RESULT
insert_wsi_socket_into_fds(struct lws_context *context, struct lws *wsi);
-LWS_EXTERN int
+LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_issue_raw(struct lws *wsi, unsigned char *buf, size_t len);
-LWS_EXTERN int
+LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_service_timeout_check(struct lws *wsi, unsigned int sec);
-LWS_EXTERN struct lws *
+LWS_EXTERN struct lws * LWS_WARN_UNUSED_RESULT
lws_client_connect_2(struct lws *wsi);
-LWS_VISIBLE struct lws *
-lws_client_reset(struct lws *wsi, int ssl, const char *address, int port, const char *path, const char *host);
+LWS_VISIBLE struct lws * LWS_WARN_UNUSED_RESULT
+lws_client_reset(struct lws *wsi, int ssl, const char *address, int port,
+ const char *path, const char *host);
-
-LWS_EXTERN struct lws *
+LWS_EXTERN struct lws * LWS_WARN_UNUSED_RESULT
lws_create_new_server_wsi(struct lws_context *context);
-LWS_EXTERN char *
+LWS_EXTERN char * LWS_WARN_UNUSED_RESULT
lws_generate_client_handshake(struct lws *wsi, char *pkt);
LWS_EXTERN int
lws_context_init_extensions(struct lws_context_creation_info *info,
struct lws_context *context);
LWS_EXTERN int
-lws_any_extension_handled(struct lws *wsi,
- enum lws_extension_callback_reasons r,
+lws_any_extension_handled(struct lws *wsi, enum lws_extension_callback_reasons r,
void *v, size_t len);
LWS_EXTERN int
-lws_ext_cb_active(struct lws *wsi, int reason,
- void *buf, int len);
+lws_ext_cb_active(struct lws *wsi, int reason, void *buf, int len);
LWS_EXTERN int
-lws_ext_cb_all_exts(struct lws_context *context,
- struct lws *wsi, int reason,
- void *arg, int len);
+lws_ext_cb_all_exts(struct lws_context *context, struct lws *wsi, int reason,
+ void *arg, int len);
#else
#define lws_any_extension_handled(_a, _b, _c, _d) (0)
#define lws_context_init_extensions(_a, _b)
#endif
-LWS_EXTERN int
+LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_client_interpret_server_handshake(struct lws *wsi);
-LWS_EXTERN int
+LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_rx_sm(struct lws *wsi, unsigned char c);
-LWS_EXTERN int
+LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_issue_raw_ext_access(struct lws *wsi, unsigned char *buf, size_t len);
LWS_EXTERN void
lws_union_transition(struct lws *wsi, enum connection_mode mode);
-LWS_EXTERN int
+LWS_EXTERN int LWS_WARN_UNUSED_RESULT
user_callback_handle_rxflow(lws_callback_function, struct lws *wsi,
enum lws_callback_reasons reason, void *user,
void *in, size_t len);
LWS_EXTERN int
lws_plat_set_socket_options(struct lws_context *context, lws_sockfd_type fd);
-LWS_EXTERN int
+LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_allocate_header_table(struct lws *wsi);
LWS_EXTERN int
lws_free_header_table(struct lws *wsi);
-LWS_EXTERN char *
+LWS_EXTERN char * LWS_WARN_UNUSED_RESULT
lws_hdr_simple_ptr(struct lws *wsi, enum lws_token_indexes h);
-LWS_EXTERN int
+LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_hdr_simple_create(struct lws *wsi, enum lws_token_indexes h, const char *s);
LWS_EXTERN int
struct lws_context *context);
LWS_EXTERN int
handshake_0405(struct lws_context *context, struct lws *wsi);
-LWS_EXTERN int
+LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_interpret_incoming_packet(struct lws *wsi, unsigned char **buf, size_t len);
LWS_EXTERN void
lws_server_get_canonical_hostname(struct lws_context *context,
#endif
#if !defined(MBED_OPERATORS)
-LWS_EXTERN int
+LWS_EXTERN int LWS_WARN_UNUSED_RESULT
interface_to_sa(struct lws_context *context, const char *ifname,
struct sockaddr_in *addr, size_t addrlen);
#endif
#else
#define LWS_SSL_ENABLED(context) (context->use_ssl)
LWS_EXTERN int openssl_websocket_private_data_index;
-LWS_EXTERN int
+LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, int len);
-LWS_EXTERN int
+LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_ssl_capable_write(struct lws *wsi, unsigned char *buf, int len);
-LWS_EXTERN int
+LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_ssl_pending(struct lws *wsi);
-LWS_EXTERN int
+LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_server_socket_service_ssl(struct lws **wsi, struct lws *new_wsi,
lws_sockfd_type accept_fd,
struct lws_pollfd *pollfd);
#endif
#endif
-LWS_EXTERN int
+LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_ssl_capable_read_no_ssl(struct lws *wsi, unsigned char *buf, int len);
-LWS_EXTERN int
+LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_ssl_capable_write_no_ssl(struct lws *wsi, unsigned char *buf, int len);
-LWS_EXTERN int
+LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_ssl_pending_no_ssl(struct lws *wsi);
#ifndef LWS_NO_CLIENT
#else
#define lws_context_init_client_ssl(_a, _b) (0)
#endif
-LWS_EXTERN int
+LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_handshake_client(struct lws *wsi, unsigned char **buf, size_t len);
LWS_EXTERN void
lws_decode_ssl_error(void);
/*
* custom allocator
*/
-LWS_EXTERN void*
+LWS_EXTERN void *
lws_realloc(void *ptr, size_t size);
-LWS_EXTERN void*
+LWS_EXTERN void * LWS_WARN_UNUSED_RESULT
lws_zalloc(size_t size);
#define lws_malloc(S) lws_realloc(NULL, S)
lws_plat_drop_app_privileges(struct lws_context_creation_info *info);
LWS_EXTERN unsigned long long
time_in_microseconds(void);
-LWS_EXTERN const char *
+LWS_EXTERN const char * LWS_WARN_UNUSED_RESULT
lws_plat_inet_ntop(int af, const void *src, char *dst, int cnt);
-LWS_EXTERN int
+LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_check_utf8(unsigned char *state, unsigned char *buf, size_t len);
#ifdef __cplusplus
if (context->lserv_fd)
idx = wsi_from_fd(context, context->lserv_fd)->position_in_fds_table;
#endif
- /*
+ /*
* you can call us with pollfd = NULL to just allow the once-per-second
* global timeout checks; if less than a second since the last check
* it returns immediately then.