aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt3
-rw-r--r--src/core/aio.c4
-rw-r--r--src/platform/posix/posix_ipc.h5
-rw-r--r--src/platform/posix/posix_ipcconn.c44
-rw-r--r--src/platform/posix/posix_pollq_epoll.c8
-rw-r--r--src/platform/posix/posix_tcp.h5
-rw-r--r--src/platform/posix/posix_tcpconn.c45
-rw-r--r--src/platform/posix/posix_udp.c21
-rw-r--r--tools/nngcat/nngcat.c19
9 files changed, 47 insertions, 107 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f5f3220b..5c8132b8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,7 +3,7 @@
# Copyright (c) 2013 GoPivotal, Inc. All rights reserved.
# Copyright (c) 2015-2016 Jack R. Dunaway. All rights reserved.
# Copyright 2016 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
-# Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
+# Copyright 2019 Staysail Systems, Inc. <info@staysail.tech>
# Copyright 2018 Capitar IT Group BV <info@capitar.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -340,7 +340,6 @@ else ()
nng_check_sym (AF_UNIX sys/socket.h NNG_HAVE_UNIX_SOCKETS)
nng_check_sym (backtrace_symbols_fd execinfo.h NNG_HAVE_BACKTRACE)
- nng_check_sym (alloca alloca.h NNG_HAVE_ALLOCA)
nng_check_struct_member(msghdr msg_control sys/socket.h NNG_HAVE_MSG_CONTROL)
nng_check_sym (eventfd sys/eventfd.h NNG_HAVE_EVENTFD)
nng_check_sym (kqueue sys/event.h NNG_HAVE_KQUEUE)
diff --git a/src/core/aio.c b/src/core/aio.c
index ee3d10a5..28f61e50 100644
--- a/src/core/aio.c
+++ b/src/core/aio.c
@@ -546,11 +546,11 @@ nni_aio_expire_add(nni_aio *aio)
}
static void
-nni_aio_expire_loop(void *arg)
+nni_aio_expire_loop(void *notused)
{
nni_list *aios = &nni_aio_expire_aios;
- NNI_ARG_UNUSED(arg);
+ NNI_ARG_UNUSED(notused);
for (;;) {
nni_aio_cancelfn fn;
diff --git a/src/platform/posix/posix_ipc.h b/src/platform/posix/posix_ipc.h
index f570b172..7fdff4aa 100644
--- a/src/platform/posix/posix_ipc.h
+++ b/src/platform/posix/posix_ipc.h
@@ -9,6 +9,9 @@
// found online at https://opensource.org/licenses/MIT.
//
+#ifndef PLATFORM_POSIX_IPC_H
+#define PLATFORM_POSIX_IPC_H
+
#include "core/nng_impl.h"
#include "core/stream.h"
@@ -40,3 +43,5 @@ extern int nni_posix_ipc_init(nni_ipc_conn **, nni_posix_pfd *);
extern void nni_posix_ipc_start(nni_ipc_conn *);
#endif // NNG_PLATFORM_POSIX
+
+#endif // PLATFORM_POSIX_IPC_H \ No newline at end of file
diff --git a/src/platform/posix/posix_ipcconn.c b/src/platform/posix/posix_ipcconn.c
index c9faded5..d3b997a9 100644
--- a/src/platform/posix/posix_ipcconn.c
+++ b/src/platform/posix/posix_ipcconn.c
@@ -29,10 +29,6 @@
#include <sys/ucred.h>
#endif
-#ifdef NNG_HAVE_ALLOCA
-#include <alloca.h>
-#endif
-
#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0
#endif
@@ -58,29 +54,16 @@ ipc_dowrite(ipc_conn *c)
unsigned naiov;
nni_iov * aiov;
struct msghdr hdr;
-#ifdef NNG_HAVE_ALLOCA
- struct iovec *iovec;
-#else
- struct iovec iovec[16];
-#endif
+ struct iovec iovec[16];
memset(&hdr, 0, sizeof(hdr));
nni_aio_get_iov(aio, &naiov, &aiov);
-#ifdef NNG_HAVE_ALLOCA
- if (naiov > 64) {
- nni_aio_list_remove(aio);
- nni_aio_finish_error(aio, NNG_EINVAL);
- continue;
- }
- iovec = alloca(naiov * sizeof(*iovec));
-#else
if (naiov > NNI_NUM_ELEMENTS(iovec)) {
nni_aio_list_remove(aio);
nni_aio_finish_error(aio, NNG_EINVAL);
continue;
}
-#endif
for (niov = 0, i = 0; i < naiov; i++) {
if (aiov[i].iov_len > 0) {
@@ -134,32 +117,19 @@ ipc_doread(ipc_conn *c)
}
while ((aio = nni_list_first(&c->readq)) != NULL) {
- unsigned i;
- int n;
- int niov;
- unsigned naiov;
- nni_iov *aiov;
-#ifdef NNG_HAVE_ALLOCA
- struct iovec *iovec;
-#else
+ unsigned i;
+ int n;
+ int niov;
+ unsigned naiov;
+ nni_iov * aiov;
struct iovec iovec[16];
-#endif
nni_aio_get_iov(aio, &naiov, &aiov);
-#ifdef NNG_HAVE_ALLOCA
- if (naiov > 64) {
- nni_aio_list_remove(aio);
- nni_aio_finish_error(aio, NNG_EINVAL);
- continue;
- }
- iovec = alloca(naiov * sizeof(*iovec));
-#else
if (naiov > NNI_NUM_ELEMENTS(iovec)) {
nni_aio_list_remove(aio);
nni_aio_finish_error(aio, NNG_EINVAL);
continue;
}
-#endif
for (niov = 0, i = 0; i < naiov; i++) {
if (aiov[i].iov_len != 0) {
iovec[niov].iov_len = aiov[i].iov_len;
@@ -205,7 +175,7 @@ static void
ipc_error(void *arg, int err)
{
ipc_conn *c = arg;
- nni_aio *aio;
+ nni_aio * aio;
nni_mtx_lock(&c->mtx);
while (((aio = nni_list_first(&c->readq)) != NULL) ||
diff --git a/src/platform/posix/posix_pollq_epoll.c b/src/platform/posix/posix_pollq_epoll.c
index 92c03120..8af4f253 100644
--- a/src/platform/posix/posix_pollq_epoll.c
+++ b/src/platform/posix/posix_pollq_epoll.c
@@ -1,5 +1,5 @@
//
-// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2019 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
// Copyright 2018 Liam Staskawicz <liam@stask.net>
//
@@ -267,7 +267,7 @@ nni_posix_poll_thr(void *arg)
} else {
nni_posix_pfd * pfd = ev->data.ptr;
nni_posix_pfd_cb cb;
- void * arg;
+ void * cbarg;
int events;
events = ev->events &
@@ -276,12 +276,12 @@ nni_posix_poll_thr(void *arg)
nni_mtx_lock(&pfd->mtx);
pfd->events &= ~events;
cb = pfd->cb;
- arg = pfd->arg;
+ cbarg = pfd->arg;
nni_mtx_unlock(&pfd->mtx);
// Execute the callback with lock released
if (cb != NULL) {
- cb(pfd, events, arg);
+ cb(pfd, events, cbarg);
}
}
}
diff --git a/src/platform/posix/posix_tcp.h b/src/platform/posix/posix_tcp.h
index 1638df61..9c7d0684 100644
--- a/src/platform/posix/posix_tcp.h
+++ b/src/platform/posix/posix_tcp.h
@@ -9,6 +9,9 @@
// found online at https://opensource.org/licenses/MIT.
//
+#ifndef PLATFORM_POSIX_TCP_H
+#define PLATFORM_POSIX_TCP_H
+
#include "core/nng_impl.h"
#include "platform/posix/posix_aio.h"
@@ -26,3 +29,5 @@ struct nni_tcp_conn {
};
extern int nni_posix_tcp_init(nni_tcp_conn **, nni_posix_pfd *);
extern void nni_posix_tcp_start(nni_tcp_conn *, int, int);
+
+#endif // PLATFORM_POSIX_TCP_H \ No newline at end of file
diff --git a/src/platform/posix/posix_tcpconn.c b/src/platform/posix/posix_tcpconn.c
index 6ca7013b..fc867ce0 100644
--- a/src/platform/posix/posix_tcpconn.c
+++ b/src/platform/posix/posix_tcpconn.c
@@ -25,9 +25,6 @@
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
-#ifdef NNG_HAVE_ALLOCA
-#include <alloca.h>
-#endif
#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0
@@ -52,29 +49,16 @@ tcp_dowrite(nni_tcp_conn *c)
unsigned naiov;
nni_iov * aiov;
struct msghdr hdr;
-#ifdef NNG_HAVE_ALLOCA
- struct iovec *iovec;
-#else
- struct iovec iovec[16];
-#endif
+ struct iovec iovec[16];
memset(&hdr, 0, sizeof(hdr));
nni_aio_get_iov(aio, &naiov, &aiov);
-#ifdef NNG_HAVE_ALLOCA
- if (naiov > 64) {
- nni_aio_list_remove(aio);
- nni_aio_finish_error(aio, NNG_EINVAL);
- continue;
- }
- iovec = alloca(naiov * sizeof(*iovec));
-#else
if (naiov > NNI_NUM_ELEMENTS(iovec)) {
nni_aio_list_remove(aio);
nni_aio_finish_error(aio, NNG_EINVAL);
continue;
}
-#endif
for (niov = 0, i = 0; i < naiov; i++) {
if (aiov[i].iov_len > 0) {
@@ -128,32 +112,19 @@ tcp_doread(nni_tcp_conn *c)
}
while ((aio = nni_list_first(&c->readq)) != NULL) {
- unsigned i;
- int n;
- int niov;
- unsigned naiov;
- nni_iov *aiov;
-#ifdef NNG_HAVE_ALLOCA
- struct iovec *iovec;
-#else
+ unsigned i;
+ int n;
+ int niov;
+ unsigned naiov;
+ nni_iov * aiov;
struct iovec iovec[16];
-#endif
nni_aio_get_iov(aio, &naiov, &aiov);
-#ifdef NNG_HAVE_ALLOCA
- if (naiov > 64) {
- nni_aio_list_remove(aio);
- nni_aio_finish_error(aio, NNG_EINVAL);
- continue;
- }
- iovec = alloca(naiov * sizeof(*iovec));
-#else
if (naiov > NNI_NUM_ELEMENTS(iovec)) {
nni_aio_list_remove(aio);
nni_aio_finish_error(aio, NNG_EINVAL);
continue;
}
-#endif
for (niov = 0, i = 0; i < naiov; i++) {
if (aiov[i].iov_len != 0) {
iovec[niov].iov_len = aiov[i].iov_len;
@@ -199,7 +170,7 @@ static void
tcp_error(void *arg, int err)
{
nni_tcp_conn *c = arg;
- nni_aio *aio;
+ nni_aio * aio;
nni_mtx_lock(&c->mtx);
while (((aio = nni_list_first(&c->readq)) != NULL) ||
@@ -258,7 +229,7 @@ tcp_cb(nni_posix_pfd *pfd, int events, void *arg)
nni_tcp_conn *c = arg;
if (events & (POLLHUP | POLLERR | POLLNVAL)) {
- tcp_error(c, NNG_ECONNSHUT);
+ tcp_error(c, NNG_ECONNSHUT);
return;
}
nni_mtx_lock(&c->mtx);
diff --git a/src/platform/posix/posix_udp.c b/src/platform/posix/posix_udp.c
index 6b1ef399..015fb4ad 100644
--- a/src/platform/posix/posix_udp.c
+++ b/src/platform/posix/posix_udp.c
@@ -1,5 +1,5 @@
//
-// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2019 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -23,9 +23,6 @@
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
-#ifdef NNG_HAVE_ALLOCA
-#include <alloca.h>
-#endif
// UDP support.
@@ -123,26 +120,14 @@ nni_posix_udp_dosend(nni_plat_udp *udp)
if (len < 1) {
rv = NNG_EADDRINVAL;
} else {
- unsigned niov;
- nni_iov *aiov;
-#ifdef NNG_HAVE_ALLOCA
- struct iovec *iov;
-#else
+ unsigned niov;
+ nni_iov * aiov;
struct iovec iov[16];
-#endif
nni_aio_get_iov(aio, &niov, &aiov);
-#ifdef NNG_HAVE_ALLOCA
- if (niov > 64) {
- rv = NNG_EINVAL;
- } else {
- iov = alloca(niov * sizeof(*iov));
- }
-#else
if (niov > NNI_NUM_ELEMENTS(iov)) {
rv = NNG_EINVAL;
}
-#endif
if (rv == 0) {
struct msghdr hdr = { .msg_name = NULL };
for (unsigned i = 0; i < niov; i++) {
diff --git a/tools/nngcat/nngcat.c b/tools/nngcat/nngcat.c
index 1866e8f7..ab891830 100644
--- a/tools/nngcat/nngcat.c
+++ b/tools/nngcat/nngcat.c
@@ -1,5 +1,5 @@
//
-// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2019 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -309,7 +309,7 @@ static void
loadfile(const char *path, void **datap, size_t *lenp)
{
FILE * f;
- char * data;
+ char * fdata;
size_t len;
if ((f = fopen(path, "r")) == NULL) {
@@ -320,16 +320,16 @@ loadfile(const char *path, void **datap, size_t *lenp)
}
len = ftell(f);
(void) fseek(f, 0, SEEK_SET);
- if ((data = malloc(len + 1)) == NULL) {
+ if ((fdata = malloc(len + 1)) == NULL) {
fatal("Out of memory.");
}
- data[len] = '\0';
+ fdata[len] = '\0';
- if (fread(data, 1, len, f) != len) {
+ if (fread(fdata, 1, len, f) != len) {
fatal("Read file %s failed: %s", path, strerror(errno));
}
fclose(f);
- *datap = data;
+ *datap = fdata;
*lenp = len;
}
@@ -860,6 +860,8 @@ main(int ac, char **av)
case NNG_ENOARG:
fatal("Option %s requires argument.", av[idx]);
break;
+ default:
+ break;
}
if (addrs == NULL) {
@@ -889,7 +891,7 @@ main(int ac, char **av)
}
if (proto == OPT_SUB0) {
if (topics == NULL) {
- topicend = addtopic(topicend, ""); // subscribe to all
+ (void) addtopic(topicend, ""); // subscribe to all
}
} else {
if (topics != NULL) {
@@ -940,6 +942,9 @@ main(int ac, char **av)
"--file or --data.");
}
break;
+ default:
+ // Will be caught in next switch statement.
+ break;
}
switch (proto) {