aboutsummaryrefslogtreecommitdiff
path: root/src/supplemental
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-02-14 14:50:04 -0800
committerGarrett D'Amore <garrett@damore.org>2018-02-14 18:28:36 -0800
commit45bc175ef9278c175d2fc3a0678b49b18e74c449 (patch)
treeb1838778ee898112f28b35178364068c6f48c9b4 /src/supplemental
parent8f93750ed2a6aaa1749eb689ddf119280f9aac7a (diff)
downloadnng-45bc175ef9278c175d2fc3a0678b49b18e74c449.tar.gz
nng-45bc175ef9278c175d2fc3a0678b49b18e74c449.tar.bz2
nng-45bc175ef9278c175d2fc3a0678b49b18e74c449.zip
fixes #234 Investigate enabling more verbose compiler warnings
We enabled verbose compiler warnings, and found a lot of issues. Some of these were even real bugs. As a bonus, we actually save some initialization steps in the compat layer, and avoid passing some variables we don't need.
Diffstat (limited to 'src/supplemental')
-rw-r--r--src/supplemental/base64/base64.c2
-rw-r--r--src/supplemental/http/http_client.c4
-rw-r--r--src/supplemental/http/http_conn.c16
-rw-r--r--src/supplemental/http/http_server.c4
-rw-r--r--src/supplemental/tls/mbedtls/tls.c2
-rw-r--r--src/supplemental/websocket/websocket.c4
6 files changed, 21 insertions, 11 deletions
diff --git a/src/supplemental/base64/base64.c b/src/supplemental/base64/base64.c
index 2f6b4da2..afb50e1a 100644
--- a/src/supplemental/base64/base64.c
+++ b/src/supplemental/base64/base64.c
@@ -107,7 +107,7 @@ nni_base64_encode(const uint8_t *in, size_t in_len, char *out, size_t out_len)
uint32_t v;
uint8_t ch;
- const uint8_t ENCODEMAP[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ const uint8_t ENCODEMAP[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
diff --git a/src/supplemental/http/http_client.c b/src/supplemental/http/http_client.c
index 9058b6e2..5cab15c9 100644
--- a/src/supplemental/http/http_client.c
+++ b/src/supplemental/http/http_client.c
@@ -197,6 +197,8 @@ nni_http_client_set_tls(nni_http_client *c, nng_tls_config *tls)
}
return (0);
#else
+ NNI_ARG_UNUSED(c);
+ NNI_ARG_UNUSED(tls);
return (NNG_EINVAL);
#endif
}
@@ -214,6 +216,8 @@ nni_http_client_get_tls(nni_http_client *c, nng_tls_config **tlsp)
nni_mtx_unlock(&c->mtx);
return (0);
#else
+ NNI_ARG_UNUSED(c);
+ NNI_ARG_UNUSED(tlsp);
return (NNG_ENOTSUP);
#endif
}
diff --git a/src/supplemental/http/http_conn.c b/src/supplemental/http/http_conn.c
index 726f3ea3..525bd6b5 100644
--- a/src/supplemental/http/http_conn.c
+++ b/src/supplemental/http/http_conn.c
@@ -200,10 +200,10 @@ http_rd_buf(nni_http_conn *conn, nni_aio *aio)
conn->rd_get = conn->rd_put = 0;
}
if (rv == NNG_EAGAIN) {
- nni_iov iov;
- iov.iov_buf = conn->rd_buf + conn->rd_put;
- iov.iov_len = conn->rd_bufsz - conn->rd_put;
- nni_aio_set_iov(conn->rd_aio, 1, &iov);
+ nni_iov iov1;
+ iov1.iov_buf = conn->rd_buf + conn->rd_put;
+ iov1.iov_len = conn->rd_bufsz - conn->rd_put;
+ nni_aio_set_iov(conn->rd_aio, 1, &iov1);
nni_aio_set_data(conn->rd_aio, 1, aio);
conn->rd(conn->sock, conn->rd_aio);
}
@@ -217,10 +217,10 @@ http_rd_buf(nni_http_conn *conn, nni_aio *aio)
conn->rd_get = conn->rd_put = 0;
}
if (rv == NNG_EAGAIN) {
- nni_iov iov;
- iov.iov_buf = conn->rd_buf + conn->rd_put;
- iov.iov_len = conn->rd_bufsz - conn->rd_put;
- nni_aio_set_iov(conn->rd_aio, 1, &iov);
+ nni_iov iov1;
+ iov1.iov_buf = conn->rd_buf + conn->rd_put;
+ iov1.iov_len = conn->rd_bufsz - conn->rd_put;
+ nni_aio_set_iov(conn->rd_aio, 1, &iov1);
nni_aio_set_data(conn->rd_aio, 1, aio);
conn->rd(conn->sock, conn->rd_aio);
}
diff --git a/src/supplemental/http/http_server.c b/src/supplemental/http/http_server.c
index 4c89708d..69774bd5 100644
--- a/src/supplemental/http/http_server.c
+++ b/src/supplemental/http/http_server.c
@@ -1494,6 +1494,8 @@ nni_http_server_set_tls(nni_http_server *s, nng_tls_config *tcfg)
}
return (0);
#else
+ NNI_ARG_UNUSED(s);
+ NNI_ARG_UNUSED(tcfg);
return (NNG_ENOTSUP);
#endif
}
@@ -1511,6 +1513,8 @@ nni_http_server_get_tls(nni_http_server *s, nng_tls_config **tp)
nni_mtx_unlock(&s->mtx);
return (0);
#else
+ NNI_ARG_UNUSED(s);
+ NNI_ARG_UNUSED(tp);
return (NNG_ENOTSUP);
#endif
}
diff --git a/src/supplemental/tls/mbedtls/tls.c b/src/supplemental/tls/mbedtls/tls.c
index ca6c716c..8d934d61 100644
--- a/src/supplemental/tls/mbedtls/tls.c
+++ b/src/supplemental/tls/mbedtls/tls.c
@@ -112,6 +112,8 @@ static void
nni_tls_dbg(void *ctx, int level, const char *file, int line, const char *s)
{
char buf[128];
+ NNI_ARG_UNUSED(ctx);
+ NNI_ARG_UNUSED(level);
snprintf(buf, sizeof(buf), "%s:%04d: %s", file, line, s);
nni_plat_println(buf);
}
diff --git a/src/supplemental/websocket/websocket.c b/src/supplemental/websocket/websocket.c
index 05a2c62c..cf3fa8dc 100644
--- a/src/supplemental/websocket/websocket.c
+++ b/src/supplemental/websocket/websocket.c
@@ -660,7 +660,7 @@ ws_send_control(nni_ws *ws, uint8_t op, uint8_t *buf, size_t len)
nni_mtx_lock(&ws->mtx);
if ((ws->closed) ||
- (ws_msg_init_control(&wm, ws, op, buf, sizeof(buf)) != 0)) {
+ (ws_msg_init_control(&wm, ws, op, buf, len) != 0)) {
nni_mtx_unlock(&ws->mtx);
return;
}
@@ -1768,7 +1768,7 @@ ws_conn_cb(void *arg)
}
for (int i = 0; i < 16; i++) {
- raw[i] = nni_random();
+ raw[i] = (uint8_t) nni_random();
}
nni_base64_encode(raw, 16, wskey, 24);
wskey[24] = '\0';