Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
---
lib/ipc_posix_mq.c | 3 +++
lib/ipc_shm.c | 19 +++++++++++++++++--
lib/ipc_us.c | 4 +---
lib/ipcs.c | 1 -
lib/loop_poll.c | 6 ++----
lib/unix.c | 1 -
tests/check_array.c | 1 +
tests/check_loop.c | 16 ++++++++++++++++
8 files changed, 40 insertions(+), 11 deletions(-)
diff --git a/lib/ipc_posix_mq.c b/lib/ipc_posix_mq.c
index 068fad3..dfee34e 100644
--- a/lib/ipc_posix_mq.c
+++ b/lib/ipc_posix_mq.c
@@ -167,6 +167,9 @@ qb_ipc_pmq_sendv(struct qb_ipc_one_way *one_way,
for (i = 0; i < iov_len; i++) {
total_size += iov[i].iov_len;
}
+ if (total_size == 0) {
+ return -EINVAL;
+ }
data = malloc(total_size);
if (data == NULL) {
return -ENOMEM;
diff --git a/lib/ipc_shm.c b/lib/ipc_shm.c
index d390939..5b8ba0e 100644
--- a/lib/ipc_shm.c
+++ b/lib/ipc_shm.c
@@ -264,6 +264,10 @@ qb_ipcs_shm_connect(struct qb_ipcs_service *s,
goto cleanup;
}
res = qb_rb_chown(c->request.u.shm.rb, c->euid, c->egid);
+ if (res != 0) {
+ qb_perror(LOG_ERR, "qb_rb_chown:REQUEST");
+ goto cleanup;
+ }
c->response.u.shm.rb = qb_rb_open(r->response,
c->response.max_msg_size,
@@ -271,10 +275,14 @@ qb_ipcs_shm_connect(struct qb_ipcs_service *s,
QB_RB_FLAG_SHARED_PROCESS, 0);
if (c->response.u.shm.rb == NULL) {
res = -errno;
- perror("qb_rb_open:RESPONSE");
+ qb_perror(LOG_ERR, "qb_rb_open:RESPONSE");
goto cleanup_request;
}
res = qb_rb_chown(c->response.u.shm.rb, c->euid, c->egid);
+ if (res != 0) {
+ qb_perror(LOG_ERR, "qb_rb_chown:RESPONSE");
+ goto cleanup_request;
+ }
c->event.u.shm.rb = qb_rb_open(r->event,
c->event.max_msg_size,
@@ -283,14 +291,21 @@ qb_ipcs_shm_connect(struct qb_ipcs_service *s,
if (c->event.u.shm.rb == NULL) {
res = -errno;
- perror("qb_rb_open:EVENT");
+ qb_perror(LOG_ERR, "qb_rb_open:EVENT");
goto cleanup_request_response;
}
res = qb_rb_chown(c->event.u.shm.rb, c->euid, c->egid);
+ if (res != 0) {
+ qb_perror(LOG_ERR, "qb_rb_chown:EVENT");
+ goto cleanup_all;
+ }
r->hdr.error = 0;
return 0;
+cleanup_all:
+ qb_rb_close(c->event.u.shm.rb);
+
cleanup_request_response:
qb_rb_close(c->request.u.shm.rb);
diff --git a/lib/ipc_us.c b/lib/ipc_us.c
index 4251f25..4b7b032 100644
--- a/lib/ipc_us.c
+++ b/lib/ipc_us.c
@@ -682,7 +682,6 @@ qb_ipcs_uc_recv_and_auth(int32_t sock, void *msg, size_t len,
res = -EIO;
goto cleanup_and_return;
}
- res = -EBADMSG;
/*
* currently support getpeerucred, getpeereid, and SO_PASSCRED credential
@@ -780,7 +779,6 @@ retry_accept:
return -1;
}
if (new_fd == -1) {
- res = -errno;
qb_util_perror(LOG_ERR, "Could not accept client connection");
/* This is an error, but -1 would indicate disconnect
* from the poll loop
@@ -801,7 +799,7 @@ retry_accept:
&ugp);
if (setup_msg.hdr.id == QB_IPC_MSG_AUTHENTICATE) {
- res = handle_new_connection(s, res, new_fd, &setup_msg,
+ (void)handle_new_connection(s, res, new_fd, &setup_msg,
sizeof(setup_msg), &ugp);
} else if (setup_msg.hdr.id == QB_IPC_MSG_NEW_EVENT_SOCK) {
if (res == 0) {
diff --git a/lib/ipcs.c b/lib/ipcs.c
index ff4be07..6bf77b4 100644
--- a/lib/ipcs.c
+++ b/lib/ipcs.c
@@ -680,7 +680,6 @@ qb_ipcs_dispatch_connection_request(int32_t fd, int32_t revents, void
*data)
return 0;
}
- res = avail; /* in case error */
do {
res = _process_request_(c, IPC_REQUEST_TIMEOUT);
if (res > 0 || res == -ENOBUFS || res == -EINVAL) {
diff --git a/lib/loop_poll.c b/lib/loop_poll.c
index cc1f580..7a03156 100644
--- a/lib/loop_poll.c
+++ b/lib/loop_poll.c
@@ -816,8 +816,7 @@ qb_loop_timer_del(struct qb_loop * l, qb_loop_timer_handle th)
#ifdef HAVE_EPOLL
if (epoll_ctl(s->epollfd, EPOLL_CTL_DEL, pe->ufd.fd, NULL) ==
-1) {
- res = -errno;
- qb_util_perror(LOG_WARNING, "epoll_ctl(del:%d)",
+ qb_util_perror(LOG_DEBUG, "epoll_ctl(del:%d)",
pe->ufd.fd);
}
#else
@@ -996,8 +995,7 @@ _qb_signal_add_to_jobs_(struct qb_loop *l, struct qb_poll_entry *pe)
res = read(pipe_fds[0], &the_signal, sizeof(int32_t));
if (res != sizeof(int32_t)) {
- res = -errno;
- qb_util_perror(LOG_ERR, "failed to read pipe");
+ qb_util_perror(LOG_WARNING, "failed to read pipe");
return 0;
}
pe->ufd.revents = 0;
diff --git a/lib/unix.c b/lib/unix.c
index 0e4e8be..a13955d 100644
--- a/lib/unix.c
+++ b/lib/unix.c
@@ -87,7 +87,6 @@ qb_sys_mmap_file_open(char *path, const char *file, size_t bytes,
}
fd = open_mmap_file(path, file_flags);
if (fd < 0 && !is_absolute) {
- res = -errno;
qb_util_perror(LOG_ERR, "couldn't open file %s", path);
snprintf(path, PATH_MAX, LOCALSTATEDIR "/run/%s", file);
diff --git a/tests/check_array.c b/tests/check_array.c
index 47f1c23..38ea3d4 100644
--- a/tests/check_array.c
+++ b/tests/check_array.c
@@ -122,6 +122,7 @@ START_TEST(test_array_static_memory)
ck_assert_int_eq(res, 0);
res = qb_array_index(a, 345, (void**)&st);
+ ck_assert_int_eq(res, 0);
st->a = 411;
/* confirm the pointer is the same after a grow */
diff --git a/tests/check_loop.c b/tests/check_loop.c
index b358efd..50e80da 100644
--- a/tests/check_loop.c
+++ b/tests/check_loop.c
@@ -66,23 +66,39 @@ static void job_1_add_nuts(void *data)
qb_loop_t *l = (qb_loop_t *)data;
job_1_run_count++;
res = qb_loop_job_add(l, QB_LOOP_HIGH, data, job_1);
+ ck_assert_int_eq(res, 0);
res = qb_loop_job_add(l, QB_LOOP_HIGH, data, job_1);
+ ck_assert_int_eq(res, 0);
res = qb_loop_job_add(l, QB_LOOP_HIGH, data, job_1);
+ ck_assert_int_eq(res, 0);
res = qb_loop_job_add(l, QB_LOOP_HIGH, data, job_1);
+ ck_assert_int_eq(res, 0);
res = qb_loop_job_add(l, QB_LOOP_HIGH, data, job_1);
+ ck_assert_int_eq(res, 0);
res = qb_loop_job_add(l, QB_LOOP_HIGH, data, job_1);
+ ck_assert_int_eq(res, 0);
res = qb_loop_job_add(l, QB_LOOP_HIGH, data, job_1);
+ ck_assert_int_eq(res, 0);
res = qb_loop_job_add(l, QB_LOOP_HIGH, data, job_1);
+ ck_assert_int_eq(res, 0);
res = qb_loop_job_add(l, QB_LOOP_MED, data, job_1);
+ ck_assert_int_eq(res, 0);
res = qb_loop_job_add(l, QB_LOOP_MED, data, job_1);
+ ck_assert_int_eq(res, 0);
res = qb_loop_job_add(l, QB_LOOP_MED, data, job_1);
+ ck_assert_int_eq(res, 0);
res = qb_loop_job_add(l, QB_LOOP_MED, data, job_1);
+ ck_assert_int_eq(res, 0);
res = qb_loop_job_add(l, QB_LOOP_LOW, data, job_1);
+ ck_assert_int_eq(res, 0);
res = qb_loop_job_add(l, QB_LOOP_LOW, data, job_1);
+ ck_assert_int_eq(res, 0);
if (job_1_run_count < 500) {
res = qb_loop_job_add(l, QB_LOOP_LOW, data, job_1_add_nuts);
+ ck_assert_int_eq(res, 0);
} else {
res = qb_loop_job_add(l, QB_LOOP_LOW, data, job_stop);
+ ck_assert_int_eq(res, 0);
}
ck_assert_int_eq(res, 0);
}
--
1.7.7.6