You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2017/11/15 21:05:52 UTC
[28/31] qpid-proton git commit: PROTON-1667: Fix more coverity issues
PROTON-1667: Fix more coverity issues
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/41003e64
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/41003e64
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/41003e64
Branch: refs/heads/go1
Commit: 41003e64a9f99e1e4905cbc893cf6dd2013a87bd
Parents: de3fd61
Author: Andrew Stitcher <as...@apache.org>
Authored: Tue Oct 31 01:12:13 2017 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Tue Oct 31 01:12:13 2017 -0400
----------------------------------------------------------------------
examples/cpp/scheduled_send.cpp | 1 +
proton-c/src/proactor/epoll.c | 35 +++++++++++++++--------------
proton-c/src/tests/connection_driver.c | 1 +
3 files changed, 20 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/41003e64/examples/cpp/scheduled_send.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/scheduled_send.cpp b/examples/cpp/scheduled_send.cpp
index 867b0df..3244540 100644
--- a/examples/cpp/scheduled_send.cpp
+++ b/examples/cpp/scheduled_send.cpp
@@ -48,6 +48,7 @@ class scheduled_sender : public proton::messaging_handler {
url(s),
interval(int(d*proton::duration::SECOND.milliseconds())), // Send interval.
timeout(int(t*proton::duration::SECOND.milliseconds())), // Cancel after timeout.
+ work_queue(0),
ready(true), // Ready to send.
canceled(false) // Canceled.
{}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/41003e64/proton-c/src/proactor/epoll.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/epoll.c b/proton-c/src/proactor/epoll.c
index 6234d4b..69e6d0f 100644
--- a/proton-c/src/proactor/epoll.c
+++ b/proton-c/src/proactor/epoll.c
@@ -1382,23 +1382,24 @@ void pn_proactor_listen(pn_proactor_t *p, pn_listener_t *l, const char *addr, in
for (struct addrinfo *ai = addrinfo; ai; ai = ai->ai_next) {
int fd = socket(ai->ai_family, SOCK_STREAM, ai->ai_protocol);
static int on = 1;
- if ((fd >= 0) &&
- !setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) &&
- /* We listen to v4/v6 on separate sockets, don't let v6 listen for v4 */
- (ai->ai_family != AF_INET6 ||
- !setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on))) &&
- !bind(fd, ai->ai_addr, ai->ai_addrlen) &&
- !listen(fd, backlog))
- {
- psocket_t *ps = &l->psockets[l->psockets_size++];
- psocket_init(ps, p, l, addr);
- ps->sockfd = fd;
- ps->epoll_io.fd = fd;
- ps->epoll_io.wanted = EPOLLIN;
- ps->epoll_io.polling = false;
- start_polling(&ps->epoll_io, ps->proactor->epollfd); // TODO: check for error
- } else {
- close(fd);
+ if (fd >= 0) {
+ if (!setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) &&
+ /* We listen to v4/v6 on separate sockets, don't let v6 listen for v4 */
+ (ai->ai_family != AF_INET6 ||
+ !setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on))) &&
+ !bind(fd, ai->ai_addr, ai->ai_addrlen) &&
+ !listen(fd, backlog))
+ {
+ psocket_t *ps = &l->psockets[l->psockets_size++];
+ psocket_init(ps, p, l, addr);
+ ps->sockfd = fd;
+ ps->epoll_io.fd = fd;
+ ps->epoll_io.wanted = EPOLLIN;
+ ps->epoll_io.polling = false;
+ start_polling(&ps->epoll_io, ps->proactor->epollfd); // TODO: check for error
+ } else {
+ close(fd);
+ }
}
}
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/41003e64/proton-c/src/tests/connection_driver.c
----------------------------------------------------------------------
diff --git a/proton-c/src/tests/connection_driver.c b/proton-c/src/tests/connection_driver.c
index fbcefc3..f152e89 100644
--- a/proton-c/src/tests/connection_driver.c
+++ b/proton-c/src/tests/connection_driver.c
@@ -291,6 +291,7 @@ int send_receive_message(test_t *t, const char* tag,
int errors = t->errors;
char data[100] = {0}; /* Dummy data to send. */
strncpy(data, tag, sizeof(data));
+ data[99] = 0; /* Ensure terminated as we strcmp this later*/
if (!TEST_CHECK(t, pn_link_credit(src->handler.link))) return 1;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org