From 4315e3fd476bdd6443bdf01606694f9322567add Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Mon, 4 Feb 2019 10:29:01 +0100 Subject: [PATCH] [codacy/cppcheck] Fix: Variable is reassigned a value before the old one has been used. --- src/smpi/colls/smpi_default_selector.cpp | 3 +-- src/smpi/colls/smpi_mvapich2_selector.cpp | 6 ++---- src/smpi/colls/smpi_mvapich2_selector_stampede.hpp | 6 ++---- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/smpi/colls/smpi_default_selector.cpp b/src/smpi/colls/smpi_default_selector.cpp index aa44938f40..7b6899e25e 100644 --- a/src/smpi/colls/smpi_default_selector.cpp +++ b/src/smpi/colls/smpi_default_selector.cpp @@ -74,9 +74,8 @@ int Coll_reduce_scatter_default::reduce_scatter(void *sendbuf, void *recvbuf, in count += recvcounts[i]; } void *tmpbuf = static_cast(smpi_get_tmp_sendbuffer(count*datatype->get_extent())); - int ret = MPI_SUCCESS; - ret = Coll_reduce_default::reduce(sendbuf, tmpbuf, count, datatype, op, 0, comm); + int ret = Coll_reduce_default::reduce(sendbuf, tmpbuf, count, datatype, op, 0, comm); if(ret==MPI_SUCCESS) ret = Colls::scatterv(tmpbuf, recvcounts, displs, datatype, recvbuf, recvcounts[rank], datatype, 0, comm); xbt_free(displs); diff --git a/src/smpi/colls/smpi_mvapich2_selector.cpp b/src/smpi/colls/smpi_mvapich2_selector.cpp index 9ecb998b2b..f3c697bf71 100644 --- a/src/smpi/colls/smpi_mvapich2_selector.cpp +++ b/src/smpi/colls/smpi_mvapich2_selector.cpp @@ -201,11 +201,9 @@ int Coll_gather_mvapich2::gather(void *sendbuf, int range_threshold = 0; int range_intra_threshold = 0; long nbytes = 0; - int comm_size = 0; int recvtype_size, sendtype_size; - int rank = -1; - comm_size = comm->size(); - rank = comm->rank(); + int comm_size = comm->size(); + int rank = comm->rank(); if (rank == root) { recvtype_size=recvtype->size(); diff --git a/src/smpi/colls/smpi_mvapich2_selector_stampede.hpp b/src/smpi/colls/smpi_mvapich2_selector_stampede.hpp index 417bb1b58b..e6dfc43462 100644 --- a/src/smpi/colls/smpi_mvapich2_selector_stampede.hpp +++ b/src/smpi/colls/smpi_mvapich2_selector_stampede.hpp @@ -369,10 +369,9 @@ static void init_mv2_allgather_tables_stampede() if (simgrid::smpi::Colls::smpi_coll_cleanup_callback == NULL) simgrid::smpi::Colls::smpi_coll_cleanup_callback = &smpi_coll_cleanup_mvapich2; - mv2_allgather_tuning_table** table_ptrs = NULL; mv2_allgather_num_ppn_conf = 3; mv2_allgather_thresholds_table = new mv2_allgather_tuning_table*[mv2_allgather_num_ppn_conf]; - table_ptrs = new mv2_allgather_tuning_table*[mv2_allgather_num_ppn_conf]; + mv2_allgather_tuning_table** table_ptrs = new mv2_allgather_tuning_table*[mv2_allgather_num_ppn_conf]; mv2_size_allgather_tuning_table = new int[mv2_allgather_num_ppn_conf]; mv2_allgather_table_ppn_conf = new int[mv2_allgather_num_ppn_conf]; mv2_allgather_table_ppn_conf[0] = 1; @@ -1516,10 +1515,9 @@ static void init_mv2_scatter_tables_stampede() simgrid::smpi::Colls::smpi_coll_cleanup_callback = &smpi_coll_cleanup_mvapich2; int agg_table_sum = 0; - mv2_scatter_tuning_table** table_ptrs = NULL; mv2_scatter_num_ppn_conf = 3; mv2_scatter_thresholds_table = new mv2_scatter_tuning_table*[mv2_scatter_num_ppn_conf]; - table_ptrs = new mv2_scatter_tuning_table*[mv2_scatter_num_ppn_conf]; + mv2_scatter_tuning_table** table_ptrs = new mv2_scatter_tuning_table*[mv2_scatter_num_ppn_conf]; mv2_size_scatter_tuning_table = new int[mv2_scatter_num_ppn_conf]; mv2_scatter_table_ppn_conf = new int[mv2_scatter_num_ppn_conf]; mv2_scatter_table_ppn_conf[0] = 1; -- 2.20.1