Skip to content

Commit

Permalink
Merge pull request #18 from yosefe/topic/fix-coverity
Browse files Browse the repository at this point in the history
UCS/UCT: Fix issues found by coverity.
  • Loading branch information
mike-dubman committed Nov 5, 2014
2 parents 98ca1b0 + 16d008a commit 0b71411
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/ucs/debug/memtrack.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,14 @@ void *ucs_memtrack_mmap(void *addr, size_t length, int prot, int flags,
int fd, off_t offset UCS_MEMTRACK_ARG)
{
ucs_memtrack_buffer_t *res;

if ((flags & MAP_FIXED) || !(prot & PROT_WRITE)) {
return NULL;
return MAP_FAILED;
}

res = mmap(addr, length + (ucs_memtrack_context.enabled ? sizeof(*res) : 0),
prot, flags, fd, offset);
if ((res == NULL) || (!ucs_memtrack_context.enabled)) {
if ((res == MAP_FAILED) || (!ucs_memtrack_context.enabled)) {
return res;
}

Expand Down
11 changes: 10 additions & 1 deletion src/uct/tl/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,27 @@ ucs_status_t uct_init(uct_context_h *context_p)
uct_context_t *context;

context = ucs_malloc(ucs_components_total_size(uct_context_t), "uct context");
if (context == NULL) {
status = UCS_ERR_NO_MEMORY;
goto err;
}

context->num_tls = 0;
context->tls = NULL;
ucs_notifier_chain_init(&context->progress_chain);

status = ucs_components_init_all(uct_context_t, context);
if (status != UCS_OK) {
return status;
goto err_free;
}

*context_p = context;
return UCS_OK;

err_free:
ucs_free(context);
err:
return status;
}

void uct_cleanup(uct_context_h context)
Expand Down

0 comments on commit 0b71411

Please sign in to comment.