Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence Coverity warnings and update atomics #1311

Merged
merged 3 commits into from
Jun 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/atomics/sys/atomic_stdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* Copyright (c) 2018 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2018 Intel, Inc. All rights reserved.
* Copyright (c) 2018-2019 Intel, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -72,7 +72,14 @@ static inline void pmix_atomic_wmb (void)

static inline void pmix_atomic_rmb (void)
{
#if PMIX_ASSEMBLY_ARCH == PMIX_X86_64
/* work around a bug in older gcc versions (observed in gcc 6.x)
* where acquire seems to get treated as a no-op instead of being
* equivalent to __asm__ __volatile__("": : :"memory") on x86_64 */
pmix_atomic_mb ();
#else
atomic_thread_fence (memory_order_acquire);
#endif
}

#define pmix_atomic_compare_exchange_strong_32(addr, compare, value) atomic_compare_exchange_strong_explicit (addr, compare, value, memory_order_relaxed, memory_order_relaxed)
Expand Down
44 changes: 37 additions & 7 deletions src/mca/pnet/test/pnet_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,9 @@ static pmix_status_t test_init(void)
nnodes = strtoul(&system[r][6], NULL, 10);
for (n=0; n < nnodes; n++) {
node = PMIX_NEW(pnet_node_t);
asprintf(&node->name, "test%03d", n);
if (0 > asprintf(&node->name, "test%03d", n)) {
return PMIX_ERR_NOMEM;
}
pmix_list_append(&mynodes, &node->super);
}
} else if (0 == strncasecmp(system[r], "plane", 5)) {
Expand Down Expand Up @@ -317,7 +319,9 @@ static pmix_status_t test_init(void)
nplane = 0;
PMIX_LIST_FOREACH(p, &myplanes, pnet_plane_t) {
/* assign a name to the plane */
asprintf(&p->name, "plane%03d", nplane);
if (0 > asprintf(&p->name, "plane%03d", nplane)) {
return PMIX_ERR_NOMEM;
}
/* setup the ports on the switches */
nports = nnodes / p->nswitches;
/* if it didn't divide evenly, then we have to add
Expand All @@ -327,14 +331,22 @@ static pmix_status_t test_init(void)
}
for (n=0; n < p->nswitches; n++) {
s = PMIX_NEW(pnet_switch_t);
asprintf(&s->name, "%s:switch%03d", p->name, n);
if (0 > asprintf(&s->name, "%s:switch%03d", p->name, n)) {
return PMIX_ERR_NOMEM;
}
s->index = n;
pmix_list_append(&p->switches, &s->super);
asprintf(&s->leftport.name, "%s:port000", s->name);
asprintf(&s->rightport.name, "%s:port%03d", s->name, nports+1);
if (0 > asprintf(&s->leftport.name, "%s:port000", s->name)) {
return PMIX_ERR_NOMEM;
}
if (0 > asprintf(&s->rightport.name, "%s:port%03d", s->name, nports+1)) {
return PMIX_ERR_NOMEM;
}
for (m=0; m < nports; m++) {
nic = PMIX_NEW(pnet_nic_t);
asprintf(&nic->name, "%s:port%03d", s->name, m+1);
if (0 > asprintf(&nic->name, "%s:port%03d", s->name, m+1)) {
return PMIX_ERR_NOMEM;
}
nic->s = s;
nic->plane = p;
pmix_list_append(&s->ports, &nic->super);
Expand Down Expand Up @@ -394,7 +406,9 @@ static pmix_status_t test_init(void)
ns = pmix_list_get_size(&s->ports);
PMIX_LIST_FOREACH(node, &mynodes, pnet_node_t) {
nic2 = PMIX_NEW(pnet_nic_t);
asprintf(&nic2->name, "%s:nic%03d", node->name, n);
if (0 > asprintf(&nic2->name, "%s:nic%03d", node->name, n)) {
return PMIX_ERR_NOMEM;
}
++n;
--ns;
nic2->node = node;
Expand Down Expand Up @@ -425,8 +439,16 @@ static pmix_status_t test_init(void)
for (n64=0; n64 < p->nverts; n64++) {
p->costmatrix[n64][n64] = 0;
nic = (pnet_nic_t*)pmix_pointer_array_get_item(&mynics, n64);
if (NULL == nic) {
PMIX_ERROR_LOG(PMIX_ERR_NOT_FOUND);
continue;
}
for (m64=n64+1; m64 < p->nverts; m64++) {
nic2 = (pnet_nic_t*)pmix_pointer_array_get_item(&mynics, m64);
if (NULL == nic2) {
PMIX_ERROR_LOG(PMIX_ERR_NOT_FOUND);
continue;
}
/* if they are on the same switch, then cost is 2 */
if (nic->s == nic2->s) {
p->costmatrix[n64][m64] = 2;
Expand Down Expand Up @@ -1028,6 +1050,10 @@ static pmix_status_t get_vertex(pmix_fabric_t *fabric,

/* find NIC that corresponds to this index */
nic = (pnet_nic_t*)pmix_pointer_array_get_item(&mynics, i);
if (NULL == nic) {
pmix_atomic_unlock(&p->atomlock);
return PMIX_ERR_NOT_FOUND;
}
node = (pnet_node_t*)nic->node;
*nodename = strdup(node->name);
/* the value we pass back will be a data array containing
Expand Down Expand Up @@ -1117,6 +1143,10 @@ static pmix_status_t get_index(pmix_fabric_t *fabric,
* that is the NIC id */
*i = identifier->data.uint32;
nic = (pnet_nic_t*)pmix_pointer_array_get_item(&mynics, *i);
if (NULL == nic) {
ret = PMIX_ERR_NOT_FOUND;
goto cleanup;
}
node = (pnet_node_t*)nic->node;
*nodename = strdup(node->name);
ret = PMIX_SUCCESS;
Expand Down
8 changes: 4 additions & 4 deletions src/server/pmix_server_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -3827,10 +3827,6 @@ static void _grpcbfunc(int sd, short argc, void *cbdata)

PMIX_ACQUIRE_OBJECT(scd);

pmix_output_verbose(2, pmix_server_globals.connect_output,
"server:grpcbfunc processing WITH %d MEMBERS",
(NULL == trk) ? 0 : (int)pmix_list_get_size(&trk->local_cbs));

if (NULL == trk) {
/* give them a release if they want it - this should
* never happen, but protect against the possibility */
Expand All @@ -3841,6 +3837,10 @@ static void _grpcbfunc(int sd, short argc, void *cbdata)
return;
}

pmix_output_verbose(2, pmix_server_globals.connect_output,
"server:grpcbfunc processing WITH %d MEMBERS",
(int)pmix_list_get_size(&trk->local_cbs));

/* if the timer is active, clear it */
if (trk->event_active) {
pmix_event_del(&trk->ev);
Expand Down