wsi->act_ext_user[wsi->count_act_ext],
NULL, 0)) {
lwsl_err("%s: ext %s rejects server options %s",
- ext->name, a);
+ __func__, ext->name, a);
cce = "HS: EXT: Rejects server options";
goto bail2;
}
lws_context_init_extensions(info, context);
- lwsl_notice(" mem: per-conn: %5u bytes + protocol rx buf\n",
- sizeof(struct lws));
+ lwsl_notice(" mem: per-conn: %5lu bytes + protocol rx buf\n",
+ (unsigned long)sizeof(struct lws));
strcpy(context->canonical_hostname, "unknown");
lws_server_get_canonical_hostname(context, info);
#define LWS_VISIBLE
#define LWS_WARN_UNUSED_RESULT
#define LWS_WARN_DEPRECATED
+#define LWS_FORMAT(string_index)
#ifdef LWS_DLL
#ifdef LWS_INTERNAL
#define LWS_VISIBLE __attribute__((visibility("default")))
#define LWS_WARN_DEPRECATED __attribute__ ((deprecated))
+#define LWS_FORMAT(string_index) __attribute__ ((format(printf, string_index, string_index+1)))
#else
#define LWS_VISIBLE
#define LWS_WARN_UNUSED_RESULT
#define LWS_WARN_DEPRECATED
+#define LWS_FORMAT(string_index)
#endif
#if defined(__ANDROID__)
LLL_COUNT = 11 /* set to count of valid flags */
};
-LWS_VISIBLE LWS_EXTERN void _lws_log(int filter, const char *format, ...);
+LWS_VISIBLE LWS_EXTERN void _lws_log(int filter, const char *format, ...) LWS_FORMAT(2);
LWS_VISIBLE LWS_EXTERN void _lws_logv(int filter, const char *format, va_list vl);
/**
* lwsl_timestamp: generate logging timestamp string
#include <osapi.h>
#include "ets_sys.h"
-int ets_snprintf(char *str, size_t size, const char *format, ...);
+int ets_snprintf(char *str, size_t size, const char *format, ...) LWS_FORMAT(3);
#define snprintf ets_snprintf
typedef os_timer_t uv_timer_t;
* reach the limit the reported length doesn't exceed the limit.
*/
LWS_VISIBLE LWS_EXTERN int
-lws_snprintf(char *str, size_t size, const char *format, ...);
+lws_snprintf(char *str, size_t size, const char *format, ...) LWS_FORMAT(3);
/**
* lws_get_random(): fill a buffer with platform random data
return 1;
}
- lwsl_notice(" mem: platform fd map: %5u bytes\n",
- sizeof(struct lws *) * context->max_fds);
+ lwsl_notice(" mem: platform fd map: %5lu bytes\n",
+ (unsigned long)(sizeof(struct lws *) * context->max_fds));
fd = open(SYSTEM_RANDOM_FILEPATH, O_RDONLY);
context->fd_random = fd;
strncpy(dump, (char *)buf, sizeof(dump) - 1);
dump[sizeof(dump) - 1] = '\0';
#if defined(LWS_WITH_ESP8266)
- lwsl_err("****** %p: Sending new %d (%s), pending truncated ...\n",
- wsi, len, dump);
+ lwsl_err("****** %p: Sending new %lu (%s), pending truncated ...\n",
+ wsi, (unsigned long)len, dump);
#else
- lwsl_err("****** %p: Sending new %d (%s), pending truncated ...\n"
+ lwsl_err("****** %p: Sending new %lu (%s), pending truncated ...\n"
" It's illegal to do an lws_write outside of\n"
" the writable callback: fix your code",
- wsi, len, dump);
+ wsi, (unsigned long)len, dump);
#endif
assert(0);
* Newly truncated send. Buffer the remainder (it will get
* first priority next time the socket is writable)
*/
- lwsl_notice("%p new partial sent %d from %d total\n", wsi, n, real_len);
+ lwsl_notice("%p new partial sent %d from %lu total\n", wsi, n,
+ (unsigned long)real_len);
/*
* - if we still have a suitable malloc lying around, use it
wsi->trunc_alloc_len = real_len - n;
wsi->trunc_alloc = lws_malloc(real_len - n);
if (!wsi->trunc_alloc) {
- lwsl_err("truncated send: unable to malloc %d\n",
- real_len - n);
+ lwsl_err("truncated send: unable to malloc %lu\n",
+ (unsigned long)(real_len - n));
return -1;
}
}
n = lws_write(wsi, start, p - start,
LWS_WRITE_HTTP_HEADERS);
if (n != (p - start)) {
- lwsl_err("_write returned %d from %d\n", n, p - start);
+ lwsl_err("_write returned %d from %ld\n", n,
+ (long)(p - start));
return -1;
}
ret = lws_write(wsi, response, p - response, LWS_WRITE_HTTP_HEADERS);
if (ret != (p - response)) {
- lwsl_err("_write returned %d from %d\n", ret, (p - response));
+ lwsl_err("_write returned %d from %ld\n", ret, (long)(p - response));
return -1;
}
lws_spa_process(struct lws_spa *ludspa, const char *in, int len)
{
if (!ludspa) {
- lwsl_err("%s: NULL spa\n");
+ lwsl_err("%s: NULL spa\n", __func__);
return -1;
}
return lws_urldecode_s_process(ludspa->s, in, len);
* Keep amount spilled small to minimize chance of this
*/
if (n != eff_buf.token_len) {
- lwsl_err("Unable to spill ext %d vs %s\n",
+ lwsl_err("Unable to spill ext %d vs %d\n",
eff_buf.token_len, n);
return -1;
}
#else
#if defined(LWS_USE_MBEDTLS)
#else
- n = ERR_get_error();
+ unsigned long error = ERR_get_error();
- if (n != SSL_ERROR_NONE) {
+ if (error != SSL_ERROR_NONE) {
struct lws_context_per_thread *pt = &context->pt[(int)wsi->tsi];
char *p = (char *)&pt->serv_buf[0];
char *sb = p;
lwsl_err("SSL connect error %lu: %s\n",
- n, ERR_error_string(n, sb));
+ error, ERR_error_string(error, sb));
return -1;
}
#endif
#else
#if defined(LWS_USE_MBEDTLS)
#else
- n = ERR_get_error();
- if (n != SSL_ERROR_NONE) {
+ unsigned long error = ERR_get_error();
+ if (error != SSL_ERROR_NONE) {
lwsl_err("SSL connect error %lu: %s\n",
- n, ERR_error_string(n, sb));
+ error, ERR_error_string(error, sb));
return -1;
}
#endif
#else
SSL_METHOD *method;
struct lws wsi;
- int error;
+ unsigned long error;
int n;
if (!lws_check_opt(info->options, LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT))
{
struct lws_context *context = vhost->context;
struct lws wsi;
- int error;
+ unsigned long error;
int n;
if (!lws_check_opt(info->options, LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT)) {
wsi_multi[n] = NULL;
}
- lwsl_err("CLIENT_CONNECTION_ERROR: %s: %s %p\n", which, in);
+ lwsl_err("CLIENT_CONNECTION_ERROR: %s: %s\n", which,
+ in ? (char *)in : "(null)");
break;
case LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED:
* have a use for this.
*/
case LWS_CALLBACK_WS_PEER_INITIATED_CLOSE:
- lwsl_notice("LWS_CALLBACK_WS_PEER_INITIATED_CLOSE: len %d\n",
- len);
+ lwsl_notice("LWS_CALLBACK_WS_PEER_INITIATED_CLOSE: len %lu\n",
+ (unsigned long)len);
for (n = 0; n < (int)len; n++)
lwsl_notice(" %d: 0x%02X\n", n,
((unsigned char *)in)[n]);
break;
case LWS_CALLBACK_WS_PEER_INITIATED_CLOSE:
- lwsl_notice("LWS_CALLBACK_WS_PEER_INITIATED_CLOSE: len %d\n",
- len);
+ lwsl_notice("LWS_CALLBACK_WS_PEER_INITIATED_CLOSE: len %lu\n",
+ (unsigned long)len);
for (n = 0; n < (int)len; n++)
lwsl_notice(" %d: 0x%02X\n", n,
((unsigned char *)in)[n]);
case 'j':
threads = atoi(optarg);
if (threads > ARRAY_SIZE(pthread_service)) {
- lwsl_err("Max threads %d\n",
- ARRAY_SIZE(pthread_service));
+ lwsl_err("Max threads %lu\n",
+ (unsigned long)ARRAY_SIZE(pthread_service));
return 1;
}
break;