aboutsummaryrefslogtreecommitdiff
path: root/src/platform/posix/posix_udp.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-04-24 16:39:35 -0700
committerGarrett D'Amore <garrett@damore.org>2018-04-24 16:39:35 -0700
commitd35973833e6bf05fec29100a4d5e66bb07b06659 (patch)
treeb380e99a092a0229c8f087d231306b398f6f43f2 /src/platform/posix/posix_udp.c
parent007f74b1053c9406340ffa728f9c254ba37e2a6c (diff)
downloadnng-d35973833e6bf05fec29100a4d5e66bb07b06659.tar.gz
nng-d35973833e6bf05fec29100a4d5e66bb07b06659.tar.bz2
nng-d35973833e6bf05fec29100a4d5e66bb07b06659.zip
fix a number of cppcheck complaints (not all)
Diffstat (limited to 'src/platform/posix/posix_udp.c')
-rw-r--r--src/platform/posix/posix_udp.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/platform/posix/posix_udp.c b/src/platform/posix/posix_udp.c
index b414fa95..37f79431 100644
--- a/src/platform/posix/posix_udp.c
+++ b/src/platform/posix/posix_udp.c
@@ -143,25 +143,28 @@ nni_posix_udp_dosend(nni_plat_udp *udp)
}
#endif
- for (unsigned i = 0; i < niov; i++) {
- iov[i].iov_base = aiov[i].iov_buf;
- iov[i].iov_len = aiov[i].iov_len;
- }
- hdr.msg_iov = iov;
- hdr.msg_iovlen = niov;
- hdr.msg_name = &ss;
- hdr.msg_namelen = len;
- hdr.msg_flags = NNI_MSG_NOSIGNAL;
- hdr.msg_control = NULL;
- hdr.msg_controllen = 0;
-
- if ((cnt = sendmsg(udp->udp_fd, &hdr, 0)) < 0) {
- if ((errno == EAGAIN) ||
- (errno == EWOULDBLOCK)) {
- // Cannot send now, leave at head.
- return;
+ if (rv == 0) {
+ for (unsigned i = 0; i < niov; i++) {
+ iov[i].iov_base = aiov[i].iov_buf;
+ iov[i].iov_len = aiov[i].iov_len;
+ }
+ hdr.msg_iov = iov;
+ hdr.msg_iovlen = niov;
+ hdr.msg_name = &ss;
+ hdr.msg_namelen = len;
+ hdr.msg_flags = NNI_MSG_NOSIGNAL;
+ hdr.msg_control = NULL;
+ hdr.msg_controllen = 0;
+
+ if ((cnt = sendmsg(udp->udp_fd, &hdr, 0)) <
+ 0) {
+ if ((errno == EAGAIN) ||
+ (errno == EWOULDBLOCK)) {
+ // Cannot send now, leave.
+ return;
+ }
+ rv = nni_plat_errno(errno);
}
- rv = nni_plat_errno(errno);
}
}
@@ -176,7 +179,6 @@ nni_posix_udp_cb(void *arg)
{
nni_plat_udp *udp = arg;
int revents;
- int events = 0;
nni_mtx_lock(&udp->udp_mtx);
revents = udp->udp_pitem.revents;
@@ -189,6 +191,7 @@ nni_posix_udp_cb(void *arg)
if (revents & (POLLHUP | POLLERR | POLLNVAL)) {
nni_posix_udp_doclose(udp);
} else {
+ int events = 0;
if (!nni_list_empty(&udp->udp_sendq)) {
events |= POLLOUT;
}