1
1

Merge pull request #422 from jsquyres/topic/coverity-fixes

Some Coverity fixes
Этот коммит содержится в:
Jeff Squyres 2015-02-24 17:00:10 -05:00
родитель bd99b741d2 05f00aface
Коммит a85a392896
18 изменённых файлов: 93 добавлений и 44 удалений

Просмотреть файл

@ -4,6 +4,7 @@
* Copyright (c) 2009-2012 Mellanox Technologies. All rights reserved.
* Copyright (c) 2013-2014 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -196,7 +197,7 @@ static int allreduce_fanout (mca_bcol_basesmuma_module_t *bcol_module, volatile
static int bcol_basesmuma_allreduce_intra_fanin_fanout_progress (bcol_function_args_t *input_args, mca_bcol_base_function_t *c_input_args)
{
mca_bcol_basesmuma_module_t *bcol_module = (mca_bcol_basesmuma_module_t *) c_input_args->bcol_module;
int buff_idx = buff_idx = input_args->src_desc->buffer_index;
int buff_idx = input_args->src_desc->buffer_index;
int *iteration = &bcol_module->ml_mem.nb_coll_desc[buff_idx].iteration;
void *data_addr = (void *) input_args->src_desc->data_addr;
int my_node_index, my_rank, group_size, leading_dim, idx;
@ -268,7 +269,7 @@ int bcol_basesmuma_allreduce_intra_fanin_fanout(bcol_function_args_t *input_args
{
/* local variables */
mca_bcol_basesmuma_module_t *bcol_module = (mca_bcol_basesmuma_module_t *) c_input_args->bcol_module;
int buff_idx = buff_idx = input_args->src_desc->buffer_index;
int buff_idx = input_args->src_desc->buffer_index;
int *iteration = &bcol_module->ml_mem.nb_coll_desc[buff_idx].iteration;
void *data_addr = (void *) input_args->src_desc->data_addr;
volatile mca_bcol_basesmuma_header_t *my_ctl_pointer;

Просмотреть файл

@ -10,6 +10,7 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2012 Oak Ridge National Labs. All rights reserved.
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -120,6 +121,9 @@ mca_coll_basic_barrier_intra_log(struct ompi_communicator_t *comm,
dim = comm->c_cube_dim;
hibit = opal_hibit(rank, dim);
if (hibit < 0) {
return MPI_ERR_OTHER;
}
--dim;
/* Receive from children. */

Просмотреть файл

@ -9,6 +9,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -134,6 +135,9 @@ mca_coll_basic_bcast_log_intra(void *buff, int count,
dim = comm->c_cube_dim;
hibit = opal_hibit(vrank, dim);
if (hibit < 0) {
return MPI_ERR_OTHER;
}
--dim;
/* Receive data from parent in the tree. */

Просмотреть файл

@ -52,7 +52,7 @@ int ompi_coll_libnbc_ireduce_scatter_block(void* sendbuf, void* recvbuf, int rec
if (MPI_SUCCESS != res) { printf("MPI Error in MPI_Comm_rank() (%i)\n", res); return res; }
res = MPI_Comm_size(comm, &p);
if (MPI_SUCCESS != res) { printf("MPI Error in MPI_Comm_size() (%i)\n", res); return res; }
MPI_Type_extent(datatype, &ext);
res = MPI_Type_extent(datatype, &ext);
if (MPI_SUCCESS != res) { printf("MPI Error in MPI_Type_extent() (%i)\n", res); return res; }
schedule = (NBC_Schedule*)malloc(sizeof(NBC_Schedule));
@ -168,7 +168,7 @@ int ompi_coll_libnbc_ireduce_scatter_block_inter(void *sbuf, void *rbuf, int rco
if (MPI_SUCCESS != res) { printf("MPI Error in MPI_Comm_rank() (%i)\n", res); return res; }
res = MPI_Comm_remote_size(comm, &rsize);
if (MPI_SUCCESS != res) { printf("MPI Error in MPI_Comm_remote_size() (%i)\n", res); return res; }
MPI_Type_extent(dtype, &ext);
res = MPI_Type_extent(dtype, &ext);
if (MPI_SUCCESS != res) { printf("MPI Error in MPI_Type_extent() (%i)\n", res); return res; }
schedule = (NBC_Schedule*)malloc(sizeof(NBC_Schedule));

Просмотреть файл

@ -70,7 +70,7 @@ int ompi_coll_libnbc_ireduce_scatter(void* sendbuf, void* recvbuf, int *recvcoun
res = MPI_Comm_rank(comm, &rank);
if (MPI_SUCCESS != res) { printf("MPI Error in MPI_Comm_rank() (%i)\n", res); return res; }
MPI_Type_extent(datatype, &ext);
res = MPI_Type_extent(datatype, &ext);
if (MPI_SUCCESS != res) { printf("MPI Error in MPI_Type_extent() (%i)\n", res); return res; }
schedule = (NBC_Schedule*)malloc(sizeof(NBC_Schedule));
@ -180,7 +180,7 @@ int ompi_coll_libnbc_ireduce_scatter_inter(void* sendbuf, void* recvbuf, int *re
if (MPI_SUCCESS != res) { printf("MPI Error in MPI_Comm_rank() (%i)\n", res); return res; }
res = MPI_Comm_remote_size(comm, &rsize);
if (MPI_SUCCESS != res) { printf("MPI Error in MPI_Comm_remote_size() (%i)\n", res); return res; }
MPI_Type_extent(datatype, &ext);
res = MPI_Type_extent(datatype, &ext);
if (MPI_SUCCESS != res) { printf("MPI Error in MPI_Type_extent() (%i)\n", res); return res; }
schedule = (NBC_Schedule*)malloc(sizeof(NBC_Schedule));

Просмотреть файл

@ -11,7 +11,7 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008-2014 University of Houston. All rights reserved.
* Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2011-2015 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2012-2013 Inria. All rights reserved.
* $COPYRIGHT$
*
@ -338,7 +338,7 @@ int ompi_io_ompio_generate_current_file_view (struct mca_io_ompio_file_t *fh,
sorted = (int *) malloc
(tot_entries * sizeof(int));
if (NULL == all_process){
if (NULL == sorted){
opal_output(1,"Error while allocating per process!\n");
return OMPI_ERR_OUT_OF_RESOURCE;
}

Просмотреть файл

@ -92,6 +92,7 @@ int mca_topo_base_dist_graph_create_adjacent(mca_topo_base_module_t* module,
return OMPI_SUCCESS;
bail_out:
if (NULL != topo) {
if( NULL != topo->in ) free(topo->in);
if( MPI_UNWEIGHTED != sourceweights ) {
if( NULL != topo->inw ) free(topo->inw);
@ -100,7 +101,6 @@ int mca_topo_base_dist_graph_create_adjacent(mca_topo_base_module_t* module,
if( MPI_UNWEIGHTED != destweights ) {
if( NULL != topo->outw ) free(topo->outw);
}
if( NULL != topo ) {
free(topo);
}
ompi_comm_free(newcomm);

Просмотреть файл

@ -10,7 +10,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007-2008 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2007-2015 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2012-2013 Inria. All rights reserved.
@ -62,11 +62,19 @@ int MPI_Cart_rank(MPI_Comm comm, const int coords[], int *rank)
return OMPI_ERRHANDLER_INVOKE (comm, MPI_ERR_COMM,
FUNC_NAME);
}
/* Need this check here to protect the access to "cart",
below. I.e., if OMPI_COMM_IS_CART is true, then cart is
guaranteed to be != NULL. */
if (!OMPI_COMM_IS_CART(comm)) {
return OMPI_ERRHANDLER_INVOKE (comm, MPI_ERR_TOPOLOGY,
FUNC_NAME);
}
cart = comm->c_topo->mtc.cart;
/* Per MPI-2.1, coords is only relevant if the dimension of
the cartesian comm is >0 */
if (((NULL == coords) &&
(NULL != cart) &&
(cart->ndims >= 1)) ||
(NULL == rank)){
return OMPI_ERRHANDLER_INVOKE (comm, MPI_ERR_ARG,
@ -82,12 +90,14 @@ int MPI_Cart_rank(MPI_Comm comm, const int coords[], int *rank)
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
}
}
}
} else {
/* Need to always test for cartesian communicators, even in
the !MPI_PARAM_CHECK case. */
if (!OMPI_COMM_IS_CART(comm)) {
return OMPI_ERRHANDLER_INVOKE (comm, MPI_ERR_TOPOLOGY,
FUNC_NAME);
}
}
OPAL_CR_ENTER_LIBRARY();
/* XXX -- CONST -- do not cast away const -- update mca/topo */

Просмотреть файл

@ -10,7 +10,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2006-2014 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2006-2009 Mellanox Technologies. All rights reserved.
* Copyright (c) 2006-2015 Los Alamos National Security, LLC. All rights
* reserved.
@ -2354,7 +2354,6 @@ static float get_ib_dev_distance(struct ibv_device *dev)
goto out;
}
if (0 != hwloc_get_cpubind(opal_hwloc_topology, my_cpuset, 0)) {
hwloc_bitmap_free(my_cpuset);
goto out;
}
my_obj = hwloc_get_obj_covering_cpuset(opal_hwloc_topology, my_cpuset);

Просмотреть файл

@ -9,6 +9,7 @@
* All rights reserved.
* Copyright (c) 2007 Evergrid, Inc. All rights reserved.
*
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -142,7 +143,9 @@ int opal_crs_base_metadata_read_token(FILE *metadata, char * token, char ***valu
} while(0 == feof(metadata) );
cleanup:
if (NULL != metadata) {
rewind(metadata);
}
return exit_status;
}

Просмотреть файл

@ -2,6 +2,7 @@
* Copyright (c) 2004-2010 The Trustees of Indiana University.
* All rights reserved.
*
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -151,7 +152,9 @@ int opal_crs_none_restart(opal_crs_base_snapshot_t *base_snapshot, bool spawn_ch
}
cleanup:
if (NULL != base_snapshot->metadata) {
fclose(base_snapshot->metadata);
}
base_snapshot->metadata = NULL;
return exit_status;

Просмотреть файл

@ -624,7 +624,7 @@ static void opal_info_show_mca_group_params(const mca_base_var_group_t *group, m
mca_base_component_parse_requested (value->stringval, &include_mode, &requested_components);
for (i = 0, requested = !include_mode ; requested_components[i] ; ++i) {
if (0 == strcmp (requested_components[i], group->group_component)) {
if (0 == strcmp (requested_components[i], group_component)) {
requested = include_mode;
break;
}

Просмотреть файл

@ -12,7 +12,7 @@
* All rights reserved.
* Copyright (c) 2006-2014 Los Alamos National Security, LLC.
* All rights reserved.
* Copyright (c) 2009-2014 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2011 Oak Ridge National Labs. All rights reserved.
* Copyright (c) 2013-2014 Intel, Inc. All rights reserved.
* Copyright (c) 2014 NVIDIA Corporation. All rights reserved.
@ -752,6 +752,7 @@ static int component_set_addr(orte_process_name_t *peer,
* end - we need to remove those extra characters
*/
hptr = host;
#if OPAL_ENABLE_IPV6
if (AF_INET6 == af_family) {
if ('[' == host[0]) {
hptr = &host[1];
@ -760,6 +761,7 @@ static int component_set_addr(orte_process_name_t *peer,
host[strlen(host)-1] = '\0';
}
}
#endif
addrs = opal_argv_split(hptr, ',');

Просмотреть файл

@ -11,7 +11,7 @@
* All rights reserved.
* Copyright (c) 2006-2013 Los Alamos National Security, LLC.
* All rights reserved.
* Copyright (c) 2009-2012 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2011 Oak Ridge National Labs. All rights reserved.
* Copyright (c) 2013-2014 Intel, Inc. All rights reserved.
* $COPYRIGHT$
@ -367,7 +367,6 @@ static void recv_handler(int sd, short flags, void *cbdata)
if (MCA_OOB_USOCK_IDENT == hdr.type) {
if (NULL == (peer = mca_oob_usock_peer_lookup(&hdr.origin))) {
/* should never happen */
mca_oob_usock_peer_close(peer);
goto cleanup;
}
/* set socket up to be non-blocking */

Просмотреть файл

@ -9,7 +9,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007-2014 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2007-2015 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2009 Institut National de Recherche en Informatique
* et Automatique. All rights reserved.
* Copyright (c) 2011-2012 Los Alamos National Security, LLC.
@ -1260,7 +1260,16 @@ int orte_plm_base_orted_append_basic_args(int *argc, char ***argv,
/* Add the 'prefix' param */
tmp_value = NULL;
loc_id = mca_base_var_find("opal", "mca", "base", "param_file_prefix");
mca_base_var_get_value(loc_id, &tmp_value, NULL, NULL);
if (loc_id < 0) {
rc = OPAL_ERR_NOT_FOUND;
ORTE_ERROR_LOG(rc);
return rc;
}
rc = mca_base_var_get_value(loc_id, &tmp_value, NULL, NULL);
if (ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
return rc;
}
if( NULL != tmp_value && NULL != tmp_value[0] ) {
/* Could also use the short version '-am'
* but being verbose has some value
@ -1272,7 +1281,15 @@ int orte_plm_base_orted_append_basic_args(int *argc, char ***argv,
/* Add the 'path' param */
tmp_value = NULL;
loc_id = mca_base_var_find("opal", "mca", "base", "param_file_path");
mca_base_var_get_value(loc_id, &tmp_value, NULL, NULL);
if (loc_id < 0) {
ORTE_ERROR_LOG(rc);
return rc;
}
rc = mca_base_var_get_value(loc_id, &tmp_value, NULL, NULL);
if (ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
return rc;
}
if( NULL != tmp_value && NULL != tmp_value[0] ) {
opal_argv_append(argc, argv, "-"OPAL_MCA_CMD_LINE_ID);
opal_argv_append(argc, argv, "mca_base_param_file_path");
@ -1285,7 +1302,16 @@ int orte_plm_base_orted_append_basic_args(int *argc, char ***argv,
tmp_value = NULL;
loc_id = mca_base_var_find("opal", "mca", "base", "param_file_path_force");
mca_base_var_get_value(loc_id, &tmp_value, NULL, NULL);
if (loc_id < 0) {
rc = OPAL_ERR_NOT_FOUND;
ORTE_ERROR_LOG(rc);
return rc;
}
rc = mca_base_var_get_value(loc_id, &tmp_value, NULL, NULL);
if (OPAL_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
return rc;
}
if( NULL == tmp_value || NULL == tmp_value[0] ) {
/* Get the current working directory */
tmp_force = (char *) malloc(sizeof(char) * OPAL_PATH_MAX);

Просмотреть файл

@ -14,7 +14,7 @@
* Copyright (c) 2008-2009 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2010 Oracle and/or its affiliates. All rights
* reserved.
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2011 IBM Corporation. All rights reserved.
* $COPYRIGHT$
*
@ -319,7 +319,8 @@ char **orte_plm_rsh_search(const char* agent_list, const char *path)
if (NULL == path) {
getcwd(cwd, OPAL_PATH_MAX);
} else {
strncpy(cwd, path, OPAL_PATH_MAX);
strncpy(cwd, path, OPAL_PATH_MAX - 1);
cwd[OPAL_PATH_MAX - 1] = '\0';
}
if (NULL == agent_list) {
lines = opal_argv_split(mca_plm_rsh_component.agent, ':');

Просмотреть файл

@ -9,7 +9,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2006-2014 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2011-2013 Los Alamos National Security, LLC.
* All rights reserved.
* Copyright (c) 2014 Intel, Inc. All rights reserved.
@ -577,10 +577,6 @@ static int check_modifiers(char *ck, orte_mapping_policy_t *tmp)
return ORTE_ERR_SILENT;
}
ptr++;
if (NULL == ptr) {
/* still missing the value */
return ORTE_ERR_SILENT;
}
orte_rmaps_base.cpus_per_rank = strtol(ptr, NULL, 10);
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
"%s rmaps:base setting pe/rank to %d",

Просмотреть файл

@ -10,7 +10,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2006-2014 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2007-2009 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2007-2013 Los Alamos National Security, LLC. All rights
* reserved.
@ -2224,6 +2224,7 @@ static int process(char *orig_line, char *basename, opal_cmd_line_t *cmd_line,
opal_argv_append_nosize(new_argv, orterun_argv[j]);
}
} else if (0 == strcmp(line_argv[i], "@np@")) {
used_num_procs = true;
asprintf(&tmp, "%d", num_procs);
opal_argv_append_nosize(new_argv, tmp);
free(tmp);