Skip to content

Commit

Permalink
Check for NULL pointer not return code
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Nov 8, 2016
1 parent ebd1ecb commit 72b291d
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/interpreter.c
Expand Up @@ -1395,7 +1395,7 @@ int unlang_event_fd_readable_add(REQUEST *request, fr_unlang_fd_callback_t callb
ev->inst = module_instance;
ev->ctx = ctx;

if (fr_event_fd_insert(request->el, fd, unlang_event_fd_handler, NULL, NULL, ev) < 0) {
if (!fr_event_fd_insert(request->el, fd, unlang_event_fd_handler, NULL, NULL, ev)) {
talloc_free(ev);
return -1;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/process.c
Expand Up @@ -4886,7 +4886,7 @@ static int event_new_fd(rad_listen_t *this)
/*
* All sockets: add the FD to the event handler.
*/
if (fr_event_fd_insert(el, this->fd, event_socket_handler, NULL, NULL, this) < 0) {
if (!fr_event_fd_insert(el, this->fd, event_socket_handler, NULL, NULL, this)) {
ERROR("Failed adding event handler for socket: %s", fr_strerror());
fr_exit(1);
}
Expand Down Expand Up @@ -5391,7 +5391,7 @@ int radius_event_start(bool have_children)
}
DEBUG4("Created signal pipe. Read end FD %i, write end FD %i", self_pipe[0], self_pipe[1]);

if (fr_event_fd_insert(el, self_pipe[0], event_signal_handler, NULL, NULL, el) < 0) {
if (!fr_event_fd_insert(el, self_pipe[0], event_signal_handler, NULL, NULL, el)) {
ERROR("Failed creating signal pipe handler: %s", fr_strerror());
return -1;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/radsniff.c
Expand Up @@ -2800,7 +2800,7 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}

if (fr_event_fd_insert(events, self_pipe[0], rs_signal_action, NULL, NULL, events) < 0) {
if (!fr_event_fd_insert(events, self_pipe[0], rs_signal_action, NULL, NULL, events)) {
ERROR("Failed inserting signal pipe descriptor: %s", fr_strerror());
goto finish;
}
Expand All @@ -2819,7 +2819,7 @@ int main(int argc, char *argv[])
event->out = out;
event->stats = stats;

if (fr_event_fd_insert(events, in_p->fd, rs_got_packet, NULL, NULL, event) < 0) {
if (!fr_event_fd_insert(events, in_p->fd, rs_got_packet, NULL, NULL, event)) {
ERROR("Failed inserting file descriptor");
goto finish;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/threads.c
Expand Up @@ -461,7 +461,7 @@ static void *thread_handler(void *arg)
local_backlog = fr_heap_create(timestamp_cmp, offsetof(REQUEST, heap_id));
rad_assert(local_backlog != NULL);

if (fr_event_fd_insert(el, thread->pipe_fd[0], thread_fd_handler, NULL, NULL, thread) < 0) {
if (!fr_event_fd_insert(el, thread->pipe_fd[0], thread_fd_handler, NULL, NULL, thread)) {
ERROR("Failed inserting event for self");
goto done;
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/proto_bfd/proto_bfd.c
Expand Up @@ -332,7 +332,7 @@ static int bfd_pthread_create(bfd_state_t *session)
fcntl(session->pipefd[1], F_SETFL, O_NONBLOCK | FD_CLOEXEC);
#endif

if (fr_event_fd_insert(session->el, session->pipefd[0], bfd_pipe_recv, NULL, NULL, session) < 0) {
if (!fr_event_fd_insert(session->el, session->pipefd[0], bfd_pipe_recv, NULL, NULL, session)) {
ERROR("Failed inserting file descriptor into event list: %s", fr_strerror());
goto close_pipes;
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/rlm_radius_client/rlm_radius_client.c
Expand Up @@ -367,7 +367,7 @@ static int mod_fd_add(fr_event_list_t *el, rlm_radius_client_conn_t *conn, rlm_r
return -1;
}

if (fr_event_fd_insert(el, sockfd, mod_event_fd, NULL, NULL, conn) < 0) {
if (!fr_event_fd_insert(el, sockfd, mod_event_fd, NULL, NULL, conn)) {
DEBUG("Failed adding event for socket: %s", fr_strerror());
close(sockfd);
return -1;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/rlm_unbound/rlm_unbound.c
Expand Up @@ -625,7 +625,7 @@ static int mod_instantiate(CONF_SECTION *conf, void *instance)

inst->log_fd = ub_fd(inst->ub);
if (inst->log_fd >= 0) {
if (fr_event_fd_insert(inst->el, inst->log_fd, ub_fd_handler, NULL, NULL, inst) < 0) {
if (!fr_event_fd_insert(inst->el, inst->log_fd, ub_fd_handler, NULL, NULL, inst)) {
cf_log_err_cs(conf, "could not insert async fd");
inst->log_fd = -1;
goto error_nores;
Expand Down

0 comments on commit 72b291d

Please sign in to comment.