aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Green <andy@warmcat.com>2019-06-07 11:11:46 +0100
committerAndy Green <andy@warmcat.com>2019-06-07 11:11:46 +0100
commit4692c1a7ee27449f14a28b87f74d1afa3010dc9b (patch)
treeb3eaac0caef8aad28f5b7cbb07b896ba49ff1f92
parent892cde2c71a7342cc7fbc98858a35a1e784be221 (diff)
downloadlibwebsockets-4692c1a7ee27449f14a28b87f74d1afa3010dc9b.tar.gz
rtos: clean warnings where uint32_t is an unsigned long
-rw-r--r--.gitignore1
-rw-r--r--include/libwebsockets.h1
-rw-r--r--lib/core-net/close.c9
-rw-r--r--lib/core-net/private.h4
-rw-r--r--lib/core-net/service.c14
-rw-r--r--lib/core-net/wsi.c10
-rw-r--r--lib/core/buflist.c3
-rw-r--r--lib/core/context.c9
-rw-r--r--lib/core/private.h9
-rw-r--r--lib/misc/dir.c3
-rw-r--r--lib/plat/esp32/esp32-service.c23
-rw-r--r--lib/plat/esp32/private.h10
-rw-r--r--lib/roles/cgi/cgi-server.c2
-rw-r--r--lib/roles/http/client/client-handshake.c4
-rw-r--r--lib/roles/http/client/client.c14
-rw-r--r--lib/roles/http/server/parsers.c33
-rw-r--r--lib/roles/listen/ops-listen.c5
-rw-r--r--minimal-examples/api-tests/api-test-gencrypto/CMakeLists.txt2
-rw-r--r--test-apps/test-server.c9
19 files changed, 111 insertions, 54 deletions
diff --git a/.gitignore b/.gitignore
index 3dfa3cb1..21289f3c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -54,3 +54,4 @@ doc
/build-mtls/
/build-mingw64/
/n9/
+/bb/
diff --git a/include/libwebsockets.h b/include/libwebsockets.h
index ab36ed89..6c7f91ac 100644
--- a/include/libwebsockets.h
+++ b/include/libwebsockets.h
@@ -150,7 +150,6 @@ typedef unsigned long long lws_intptr_t;
#if defined(__ANDROID__)
#include <netinet/in.h>
#include <unistd.h>
-#define getdtablesize() sysconf(_SC_OPEN_MAX)
#endif
#endif
diff --git a/lib/core-net/close.c b/lib/core-net/close.c
index 7ddc58b8..236d3ac8 100644
--- a/lib/core-net/close.c
+++ b/lib/core-net/close.c
@@ -137,6 +137,9 @@ __lws_close_free_wsi(struct lws *wsi, enum lws_close_status reason,
struct lws_context_per_thread *pt;
struct lws *wsi1, *wsi2;
struct lws_context *context;
+#if !defined(LWS_NO_CLIENT)
+ long rl = (long)(int)reason;
+#endif
int n;
lwsl_info("%s: %p: caller: %s\n", __func__, wsi, caller);
@@ -164,7 +167,7 @@ __lws_close_free_wsi(struct lws *wsi, enum lws_close_status reason,
lws_dll_remove_track_tail(&wsi->dll_cli_active_conns,
&wsi->vhost->dll_cli_active_conns_head);
- if ((int)reason != -1)
+ if (rl != -1l)
lws_vhost_lock(wsi->vhost);
lws_dll2_foreach_safe(&wsi->dll2_cli_txn_queue_owner, NULL,
@@ -174,13 +177,13 @@ __lws_close_free_wsi(struct lws *wsi, enum lws_close_status reason,
* !!! If we are closing, but we have pending pipelined
* transaction results we already sent headers for, that's going
* to destroy sync for HTTP/1 and leave H2 stream with no live
- * swsi.
+ * swsi.`
*
* However this is normal if we are being closed because the
* transaction queue leader is closing.
*/
lws_dll2_remove(&wsi->dll2_cli_txn_queue);
- if ((int)reason !=-1)
+ if (rl != -1l)
lws_vhost_unlock(wsi->vhost);
}
#endif
diff --git a/lib/core-net/private.h b/lib/core-net/private.h
index 8779f29d..c4285a4c 100644
--- a/lib/core-net/private.h
+++ b/lib/core-net/private.h
@@ -22,6 +22,10 @@
#if !defined(__LWS_CORE_NET_PRIVATE_H__)
#define __LWS_CORE_NET_PRIVATE_H__
+#if !defined(_POSIX_C_SOURCE)
+#define _POSIX_C_SOURCE 200112L
+#endif
+
#include "roles/private.h"
#ifdef LWS_WITH_IPV6
diff --git a/lib/core-net/service.c b/lib/core-net/service.c
index 12490d00..190bc23f 100644
--- a/lib/core-net/service.c
+++ b/lib/core-net/service.c
@@ -194,8 +194,8 @@ user_service_go_again:
goto bail_ok;
}
- lwsl_debug("%s: %p: non mux: wsistate 0x%x, ops %s\n", __func__, wsi,
- wsi->wsistate, wsi->role_ops->name);
+ lwsl_debug("%s: %p: non mux: wsistate 0x%lx, ops %s\n", __func__, wsi,
+ (unsigned long)wsi->wsistate, wsi->role_ops->name);
vwsi = (volatile struct lws *)wsi;
vwsi->leave_pollout_active = 0;
@@ -503,9 +503,9 @@ lws_service_do_ripe_rxflow(struct lws_context_per_thread *pt)
pfd.revents = LWS_POLLIN;
pfd.fd = -1;
- lwsl_debug("%s: rxflow processing: %p fc=%d, 0x%x\n", __func__,
- wsi, lws_is_flowcontrolled(wsi),
- wsi->wsistate);
+ lwsl_debug("%s: rxflow processing: %p fc=%d, 0x%lx\n", __func__,
+ wsi, lws_is_flowcontrolled(wsi),
+ (unsigned long)wsi->wsistate);
if (!lws_is_flowcontrolled(wsi) &&
lwsi_state(wsi) != LRS_DEFERRING_ACTION &&
@@ -728,8 +728,8 @@ lws_service_periodic_checks(struct lws_context *context,
#endif
lwsl_notice("ah excessive hold: wsi %p\n"
" peer address: %s\n"
- " ah pos %u\n",
- wsi, buf, ah->pos);
+ " ah pos %lu\n",
+ wsi, buf, (unsigned long)ah->pos);
buf[0] = '\0';
m = 0;
do {
diff --git a/lib/core-net/wsi.c b/lib/core-net/wsi.c
index 1fc1dbf3..3b8c6620 100644
--- a/lib/core-net/wsi.c
+++ b/lib/core-net/wsi.c
@@ -26,14 +26,16 @@ void lwsi_set_role(struct lws *wsi, lws_wsi_state_t role)
{
wsi->wsistate = (wsi->wsistate & (~LWSI_ROLE_MASK)) | role;
- lwsl_debug("lwsi_set_role(%p, 0x%x)\n", wsi, wsi->wsistate);
+ lwsl_debug("lwsi_set_role(%p, 0x%lx)\n", wsi,
+ (unsigned long)wsi->wsistate);
}
void lwsi_set_state(struct lws *wsi, lws_wsi_state_t lrs)
{
wsi->wsistate = (wsi->wsistate & (~LRS_MASK)) | lrs;
- lwsl_debug("lwsi_set_state(%p, 0x%x)\n", wsi, wsi->wsistate);
+ lwsl_debug("lwsi_set_state(%p, 0x%lx)\n", wsi,
+ (unsigned long)wsi->wsistate);
}
#endif
@@ -440,8 +442,8 @@ lws_role_transition(struct lws *wsi, enum lwsi_role role, enum lwsi_state state,
#if defined(_DEBUG)
if (wsi->role_ops)
name = wsi->role_ops->name;
- lwsl_debug("%s: %p: wsistate 0x%x, ops %s\n", __func__, wsi,
- wsi->wsistate, name);
+ lwsl_debug("%s: %p: wsistate 0x%lx, ops %s\n", __func__, wsi,
+ (unsigned long)wsi->wsistate, name);
#endif
}
diff --git a/lib/core/buflist.c b/lib/core/buflist.c
index 6d8190fa..c49f5d82 100644
--- a/lib/core/buflist.c
+++ b/lib/core/buflist.c
@@ -52,7 +52,8 @@ lws_buflist_append_segment(struct lws_buflist **head, const uint8_t *buf,
head = &((*head)->next);
}
- lwsl_info("%s: len %u first %d %p\n", __func__, (uint32_t)len, first, p);
+ lwsl_info("%s: len %u first %d %p\n", __func__, (unsigned int)len,
+ first, p);
nbuf = (struct lws_buflist *)lws_malloc(sizeof(**head) + len, __func__);
if (!nbuf) {
diff --git a/lib/core/context.c b/lib/core/context.c
index 942b1ef8..67aabe4c 100644
--- a/lib/core/context.c
+++ b/lib/core/context.c
@@ -177,14 +177,19 @@ lwsl_info("context created\n");
}
#endif
#if defined(__ANDROID__)
- n = getrlimit ( RLIMIT_NOFILE,&rt);
- if (-1 == n) {
+ n = getrlimit(RLIMIT_NOFILE, &rt);
+ if (n == -1) {
lwsl_err("Get RLIMIT_NOFILE failed!\n");
+
return NULL;
}
context->max_fds = rt.rlim_cur;
#else
+#if defined(WIN32) || defined(_WIN32) || defined(LWS_AMAZON_RTOS)
context->max_fds = getdtablesize();
+#else
+ context->max_fds = sysconf(_SC_OPEN_MAX);
+#endif
#endif
if (info->count_threads)
diff --git a/lib/core/private.h b/lib/core/private.h
index 2103fb68..12564040 100644
--- a/lib/core/private.h
+++ b/lib/core/private.h
@@ -22,10 +22,17 @@
#include "lws_config.h"
#include "lws_config_private.h"
-#if defined(LWS_WITH_CGI) && defined(LWS_HAVE_VFORK)
+#if defined(LWS_WITH_CGI) && defined(LWS_HAVE_VFORK) && \
+ !defined(NO_GNU_SOURCE_THIS_TIME)
#define _GNU_SOURCE
#endif
+/*
+#if !defined(_POSIX_C_SOURCE)
+#define _POSIX_C_SOURCE 200112L
+#endif
+*/
+
#if defined(__COVERITY__) && !defined(LWS_COVERITY_WORKAROUND)
#define LWS_COVERITY_WORKAROUND
typedef float _Float32;
diff --git a/lib/misc/dir.c b/lib/misc/dir.c
index e8e59022..fdd73236 100644
--- a/lib/misc/dir.c
+++ b/lib/misc/dir.c
@@ -19,6 +19,9 @@
* MA 02110-1301 USA
*/
+#define NO_GNU_SOURCE_THIS_TIME
+#define _DARWIN_C_SOURCE
+
#include <libwebsockets.h>
#include "core/private.h"
#include <string.h>
diff --git a/lib/plat/esp32/esp32-service.c b/lib/plat/esp32/esp32-service.c
index 62b9d74c..00dea708 100644
--- a/lib/plat/esp32/esp32-service.c
+++ b/lib/plat/esp32/esp32-service.c
@@ -59,13 +59,18 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
#else
n = esp_get_free_heap_size();
#endif
- if (n != context->last_free_heap) {
- if (n > context->last_free_heap)
- lwsl_notice(" heap :%d (+%d)\n", n,
- n - context->last_free_heap);
+ if ((unsigned int)n != context->last_free_heap) {
+ if ((unsigned int)n > context->last_free_heap)
+ lwsl_notice(" heap :%ld (+%ld)\n",
+ (unsigned long)n,
+ (unsigned long)(n -
+ context->last_free_heap));
else
- lwsl_notice(" heap :%d (-%d)\n", n,
- context->last_free_heap - n);
+ lwsl_notice(" heap :%ld (-%ld)\n",
+ (unsigned long)n,
+ (unsigned long)(
+ context->last_free_heap -
+ n));
context->last_free_heap = n;
}
}
@@ -117,7 +122,7 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
FD_ZERO(&writefds);
FD_ZERO(&errfds);
- for (n = 0; n < pt->fds_count; n++) {
+ for (n = 0; n < (int)pt->fds_count; n++) {
pt->fds[n].revents = 0;
if (pt->fds[n].fd >= max_fd)
max_fd = pt->fds[n].fd;
@@ -130,7 +135,7 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
n = select(max_fd + 1, &readfds, &writefds, &errfds, ptv);
n = 0;
- for (m = 0; m < pt->fds_count; m++) {
+ for (m = 0; m < (int)pt->fds_count; m++) {
c = 0;
if (FD_ISSET(pt->fds[m].fd, &readfds)) {
pt->fds[m].revents |= LWS_POLLIN;
@@ -180,7 +185,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;
diff --git a/lib/plat/esp32/private.h b/lib/plat/esp32/private.h
index d3e0d826..7b256e85 100644
--- a/lib/plat/esp32/private.h
+++ b/lib/plat/esp32/private.h
@@ -24,7 +24,10 @@
#define MSG_NOSIGNAL 0
#define SOMAXCONN 3
-#if !defined(LWS_AMAZON_RTOS)
+#if defined(LWS_AMAZON_RTOS)
+ int
+ open(const char *path, int oflag, ...);
+#else
#include <fcntl.h>
#endif
@@ -40,7 +43,10 @@
#endif
#include <netdb.h>
#include <signal.h>
-#if !defined(LWS_AMAZON_RTOS)
+#if defined(LWS_AMAZON_RTOS)
+const char *
+gai_strerror(int);
+#else
#include <sys/socket.h>
#endif
diff --git a/lib/roles/cgi/cgi-server.c b/lib/roles/cgi/cgi-server.c
index 85d36861..ef2d2629 100644
--- a/lib/roles/cgi/cgi-server.c
+++ b/lib/roles/cgi/cgi-server.c
@@ -19,6 +19,8 @@
* MA 02110-1301 USA
*/
+#define _GNU_SOURCE
+
#include "core/private.h"
#if defined(WIN32) || defined(_WIN32)
diff --git a/lib/roles/http/client/client-handshake.c b/lib/roles/http/client/client-handshake.c
index d77b8d50..431032ff 100644
--- a/lib/roles/http/client/client-handshake.c
+++ b/lib/roles/http/client/client-handshake.c
@@ -315,8 +315,8 @@ lws_client_connect_2(struct lws *wsi)
}
#endif
- lwsl_info("applying %p to txn queue on %p state 0x%x\n",
- wsi, w, w->wsistate);
+ lwsl_info("apply %p to txn queue on %p state 0x%lx\n",
+ wsi, w, (unsigned long)w->wsistate);
/*
* ...let's add ourselves to his transaction queue...
* we are adding ourselves at the HEAD
diff --git a/lib/roles/http/client/client.c b/lib/roles/http/client/client.c
index ee4294ce..980f6a0c 100644
--- a/lib/roles/http/client/client.c
+++ b/lib/roles/http/client/client.c
@@ -102,8 +102,8 @@ lws_client_socket_service(struct lws *wsi, struct lws_pollfd *pollfd,
struct lws *w = lws_container_of(d, struct lws,
dll2_cli_txn_queue);
- lwsl_debug("%s: %p states 0x%x\n", __func__, w,
- w->wsistate);
+ lwsl_debug("%s: %p states 0x%lx\n", __func__, w,
+ (unsigned long)w->wsistate);
if (lwsi_state(w) == LRS_H1C_ISSUE_HANDSHAKE2)
wfound = w;
} lws_end_foreach_dll_safe(d, d1);
@@ -388,8 +388,10 @@ start_ws_handshake:
w = _lws_client_wsi_master(wsi);
lwsl_info("%s: HANDSHAKE2: %p: sending headers on %p "
- "(wsistate 0x%x 0x%x), w sock %d, wsi sock %d\n", __func__, wsi, w,
- wsi->wsistate, w->wsistate, w->desc.sockfd, wsi->desc.sockfd);
+ "(wsistate 0x%lx 0x%lx), w sock %d, wsi sock %d\n",
+ __func__, wsi, w, (unsigned long)wsi->wsistate,
+ (unsigned long)w->wsistate, w->desc.sockfd,
+ wsi->desc.sockfd);
n = lws_ssl_capable_write(w, (unsigned char *)sb, (int)(p - sb));
lws_latency(context, wsi, "send lws_issue_raw", n,
@@ -576,8 +578,8 @@ lws_http_transaction_completed_client(struct lws *wsi)
if (user_callback_handle_rxflow(wsi_eff->protocol->callback, wsi_eff,
LWS_CALLBACK_COMPLETED_CLIENT_HTTP,
wsi_eff->user_space, NULL, 0)) {
- lwsl_debug("%s: Completed call returned nonzero (role 0x%x)\n",
- __func__, lwsi_role(wsi_eff));
+ lwsl_debug("%s: Completed call returned nonzero (role 0x%lx)\n",
+ __func__, (unsigned long)lwsi_role(wsi_eff));
return -1;
}
diff --git a/lib/roles/http/server/parsers.c b/lib/roles/http/server/parsers.c
index 0ce2a2ba..5cfa144b 100644
--- a/lib/roles/http/server/parsers.c
+++ b/lib/roles/http/server/parsers.c
@@ -94,8 +94,8 @@ _lws_create_ah(struct lws_context_per_thread *pt, ah_data_idx_t data_size)
ah->data_length = data_size;
pt->http.ah_pool_length++;
- lwsl_info("%s: created ah %p (size %d): pool length %d\n", __func__,
- ah, (int)data_size, pt->http.ah_pool_length);
+ lwsl_info("%s: created ah %p (size %d): pool length %ld\n", __func__,
+ ah, (int)data_size, (unsigned long)pt->http.ah_pool_length);
return ah;
}
@@ -107,8 +107,9 @@ _lws_destroy_ah(struct lws_context_per_thread *pt, struct allocated_headers *ah)
if ((*a) == ah) {
*a = ah->next;
pt->http.ah_pool_length--;
- lwsl_info("%s: freed ah %p : pool length %d\n",
- __func__, ah, pt->http.ah_pool_length);
+ lwsl_info("%s: freed ah %p : pool length %ld\n",
+ __func__, ah,
+ (unsigned long)pt->http.ah_pool_length);
if (ah->data)
lws_free(ah->data);
lws_free(ah);
@@ -359,9 +360,9 @@ int __lws_header_table_detach(struct lws *wsi, int autoservice)
* we're detaching the ah, but it was held an
* unreasonably long time
*/
- lwsl_debug("%s: wsi %p: ah held %ds, role/state 0x%x 0x%x,"
+ lwsl_debug("%s: wsi %p: ah held %ds, role/state 0x%lx 0x%x,"
"\n", __func__, wsi, (int)(now - ah->assigned),
- lwsi_role(wsi), lwsi_state(wsi));
+ (unsigned long)lwsi_role(wsi), lwsi_state(wsi));
}
ah->assigned = 0;
@@ -414,7 +415,8 @@ int __lws_header_table_detach(struct lws *wsi, int autoservice)
goto nobody_usable_waiting;
lwsl_info("%s: transferring ah to last eligible wsi in wait list "
- "%p (wsistate 0x%x)\n", __func__, wsi, wsi->wsistate);
+ "%p (wsistate 0x%lx)\n", __func__, wsi,
+ (unsigned long)wsi->wsistate);
wsi->http.ah = ah;
ah->wsi = wsi; /* new owner */
@@ -693,8 +695,9 @@ lws_pos_in_bounds(struct lws *wsi)
* with these tests everywhere, it should never be able to exceed
* the limit, only meet it
*/
- lwsl_err("%s: pos %d, limit %d\n", __func__, wsi->http.ah->pos,
- wsi->context->max_http_header_data);
+ lwsl_err("%s: pos %ld, limit %ld\n", __func__,
+ (unsigned long)wsi->http.ah->pos,
+ (unsigned long)wsi->context->max_http_header_data);
assert(0);
return 1;
@@ -754,9 +757,9 @@ issue_char(struct lws *wsi, unsigned char c)
return -1;
wsi->http.ah->data[wsi->http.ah->pos++] = '\0';
- lwsl_warn("header %i exceeds limit %d\n",
- wsi->http.ah->parser_state,
- wsi->http.ah->current_token_limit);
+ lwsl_warn("header %li exceeds limit %ld\n",
+ (long)wsi->http.ah->parser_state,
+ (long)wsi->http.ah->current_token_limit);
}
return 1;
@@ -1098,8 +1101,10 @@ swallow:
/* collecting and checking a name part */
case WSI_TOKEN_NAME_PART:
- lwsl_parser("WSI_TOKEN_NAME_PART '%c' 0x%02X (role=0x%x) "
- "wsi->lextable_pos=%d\n", c, c, lwsi_role(wsi),
+ lwsl_parser("WSI_TOKEN_NAME_PART '%c' 0x%02X "
+ "(role=0x%lx) "
+ "wsi->lextable_pos=%d\n", c, c,
+ (unsigned long)lwsi_role(wsi),
ah->lextable_pos);
if (c >= 'A' && c <= 'Z')
diff --git a/lib/roles/listen/ops-listen.c b/lib/roles/listen/ops-listen.c
index 82af67d5..2f71fee5 100644
--- a/lib/roles/listen/ops-listen.c
+++ b/lib/roles/listen/ops-listen.c
@@ -152,8 +152,9 @@ rops_handle_POLLIN_listen(struct lws_context_per_thread *pt, struct lws *wsi,
return LWS_HPI_RET_WSI_ALREADY_DIED;
}
- lwsl_info("%s: new wsi %p: wsistate 0x%x, role_ops %s\n",
- __func__, cwsi, cwsi->wsistate, cwsi->role_ops->name);
+ lwsl_info("%s: new wsi %p: wsistate 0x%lx, role_ops %s\n",
+ __func__, cwsi, (unsigned long)cwsi->wsistate,
+ cwsi->role_ops->name);
*/
} while (pt->fds_count < context->fd_limit_per_thread - 1 &&
diff --git a/minimal-examples/api-tests/api-test-gencrypto/CMakeLists.txt b/minimal-examples/api-tests/api-test-gencrypto/CMakeLists.txt
index f2a84803..4e972521 100644
--- a/minimal-examples/api-tests/api-test-gencrypto/CMakeLists.txt
+++ b/minimal-examples/api-tests/api-test-gencrypto/CMakeLists.txt
@@ -63,6 +63,8 @@ ENDMACRO()
set(requirements 1)
require_lws_config(LWS_WITH_GENCRYPTO 1 requirements)
+require_lws_config(LWS_WITH_JOSE 1 requirements)
+
if (requirements)
diff --git a/test-apps/test-server.c b/test-apps/test-server.c
index 532a69f4..00393891 100644
--- a/test-apps/test-server.c
+++ b/test-apps/test-server.c
@@ -26,6 +26,11 @@
#endif
#include <signal.h>
+#if defined(WIN32) || defined(_WIN32)
+#else
+#include <unistd.h>
+#endif
+
int close_testing;
int max_poll_elements;
int debug_level = LLL_USER | 7;
@@ -478,7 +483,11 @@ int main(int argc, char **argv)
printf("Using resource path \"%s\"\n", resource_path);
#ifdef EXTERNAL_POLL
+#if !defined(WIN32) && !defined(_WIN32)
max_poll_elements = getdtablesize();
+#else
+ max_poll_elements = sysconf(_SC_OPEN_MAX);
+#endif
pollfds = malloc(max_poll_elements * sizeof (struct lws_pollfd));
fd_lookup = malloc(max_poll_elements * sizeof (int));
if (pollfds == NULL || fd_lookup == NULL) {