diff --git a/opal/class/opal_graph.c b/opal/class/opal_graph.c index 73edaff27f8..cea79b9b035 100644 --- a/opal/class/opal_graph.c +++ b/opal/class/opal_graph.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology @@ -10,6 +11,8 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2007 Voltaire All rights reserved. + * Copyright (c) 2016 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -149,13 +152,7 @@ static void opal_graph_construct(opal_graph_t *graph) static void opal_graph_destruct(opal_graph_t *graph) { - opal_adjacency_list_t *aj_list; - - while (false == opal_list_is_empty(graph->adjacency_list)) { - aj_list = (opal_adjacency_list_t *)opal_list_remove_first(graph->adjacency_list); - OBJ_RELEASE(aj_list); - } - OBJ_RELEASE(graph->adjacency_list); + OPAL_LIST_RELEASE(graph->adjacency_list); graph->number_of_vertices = 0; graph->number_of_edges = 0; } @@ -174,15 +171,8 @@ static void opal_adjacency_list_construct(opal_adjacency_list_t *aj_list) static void opal_adjacency_list_destruct(opal_adjacency_list_t *aj_list) { - opal_graph_edge_t *edge; - aj_list->vertex = NULL; - while (false == opal_list_is_empty(aj_list->edges)) { - edge = (opal_graph_edge_t *)opal_list_remove_first(aj_list->edges); - OBJ_RELEASE(edge); - } - OBJ_RELEASE(aj_list->edges); - + OPAL_LIST_RELEASE(aj_list->edges); } /** @@ -349,14 +339,9 @@ void opal_graph_remove_vertex(opal_graph_t *graph, opal_graph_vertex_t *vertex) opal_adjacency_list_t *adj_list; opal_graph_edge_t *edge; - /** - * remove all the edges of this vertex and destruct them. - */ + /* do not need to remove all the edges of this vertex and destruct them as + * they will be released in the destructor for adj_list */ adj_list = vertex->in_adj_list; - while (false == opal_list_is_empty(adj_list->edges)) { - edge = (opal_graph_edge_t *)opal_list_remove_first(adj_list->edges); - OBJ_RELEASE(edge); - } /** * remove the adjscency list of this vertex from the graph and * destruct it. diff --git a/opal/mca/btl/openib/btl_openib_endpoint.c b/opal/mca/btl/openib/btl_openib_endpoint.c index ec2649d517e..277ff21dabc 100644 --- a/opal/mca/btl/openib/btl_openib_endpoint.c +++ b/opal/mca/btl/openib/btl_openib_endpoint.c @@ -632,8 +632,7 @@ void mca_btl_openib_endpoint_connected(mca_btl_openib_endpoint_t *endpoint) /* Process pending packet on the endpoint */ /* While there are frags in the list, process them */ - while (!opal_list_is_empty(&(endpoint->pending_lazy_frags))) { - frag_item = opal_list_remove_first(&(endpoint->pending_lazy_frags)); + while (NULL != (frag_item = opal_list_remove_first(&(endpoint->pending_lazy_frags)))) { frag = to_send_frag(frag_item); /* We need to post this one */ diff --git a/opal/mca/btl/openib/btl_openib_proc.c b/opal/mca/btl/openib/btl_openib_proc.c index f994f4aef08..6023c09656d 100644 --- a/opal/mca/btl/openib/btl_openib_proc.c +++ b/opal/mca/btl/openib/btl_openib_proc.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology @@ -15,6 +16,8 @@ * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2015 Mellanox Technologies. All rights reserved. + * Copyright (c) 2016 Los Alamos National Security, LLC. All rights + * reserved. * * $COPYRIGHT$ * @@ -184,6 +187,9 @@ mca_btl_openib_proc_t* mca_btl_openib_proc_get_locked(opal_proc_t* proc) /* First time, gotta create a new IB proc * out of the opal_proc ... */ ib_proc = OBJ_NEW(mca_btl_openib_proc_t); + if (NULL == ib_proc) { + return NULL; + } /* Initialize number of peer */ ib_proc->proc_endpoint_count = 0; @@ -321,10 +327,9 @@ mca_btl_openib_proc_t* mca_btl_openib_proc_get_locked(opal_proc_t* proc) err_exit: - fprintf(stderr,"%d: error exit from mca_btl_openib_proc_create\n", OPAL_PROC_MY_NAME.vpid); - if( NULL != ib_proc ){ - OBJ_RELEASE(ib_proc); - } + BTL_ERROR(("%d: error exit from mca_btl_openib_proc_create", OPAL_PROC_MY_NAME.vpid)); + + OBJ_RELEASE(ib_proc); return NULL; } diff --git a/opal/mca/mpool/hugepage/mpool_hugepage_module.c b/opal/mca/mpool/hugepage/mpool_hugepage_module.c index 3f38ed975dd..87dbf8a4185 100644 --- a/opal/mca/mpool/hugepage/mpool_hugepage_module.c +++ b/opal/mca/mpool/hugepage/mpool_hugepage_module.c @@ -159,12 +159,15 @@ void *mca_mpool_hugepage_seg_alloc (void *ctx, size_t *sizep) } base = mmap (NULL, size, PROT_READ | PROT_WRITE, flags | huge_page->mmap_flags, fd, 0); - close (fd); if (path) { unlink (path); free (path); } + if (fd >= 0) { + close (fd); + } + if (MAP_FAILED == base) { opal_output_verbose (MCA_BASE_VERBOSE_WARN, opal_mpool_base_framework.framework_verbose, "could not allocate huge page(s). falling back on standard pages");