diff options
| author | Garrett D'Amore <garrett@damore.org> | 2019-12-11 05:12:36 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2019-12-11 05:12:36 -0800 |
| commit | 5c0f08087429e7a89c97742e4a4b146688442a04 (patch) | |
| tree | b09dd481be3389d7321d3198a86efc9919216f3f /src | |
| parent | 52f5eb316f826c5c5be13c35f24f809d6d5efce4 (diff) | |
| download | nng-5c0f08087429e7a89c97742e4a4b146688442a04.tar.gz nng-5c0f08087429e7a89c97742e4a4b146688442a04.tar.bz2 nng-5c0f08087429e7a89c97742e4a4b146688442a04.zip | |
Address complaints found by lgtm.com.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/aio.c | 4 | ||||
| -rw-r--r-- | src/platform/posix/posix_ipc.h | 5 | ||||
| -rw-r--r-- | src/platform/posix/posix_ipcconn.c | 44 | ||||
| -rw-r--r-- | src/platform/posix/posix_pollq_epoll.c | 8 | ||||
| -rw-r--r-- | src/platform/posix/posix_tcp.h | 5 | ||||
| -rw-r--r-- | src/platform/posix/posix_tcpconn.c | 45 | ||||
| -rw-r--r-- | src/platform/posix/posix_udp.c | 21 |
7 files changed, 34 insertions, 98 deletions
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++) { |
