From a976ff26ca5afba53350d9ed449c122b52972824 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Mon, 7 May 2018 22:06:42 +0200 Subject: [PATCH] Remove useless check for null before free. --- src/msg/msg_global.cpp | 3 --- src/smpi/mpi/smpi_comm.cpp | 6 ++---- src/surf/cpu_ti.cpp | 7 ++----- src/surf/surf_interface.cpp | 7 ++----- src/xbt/automaton/automatonparse_promela.c | 3 +-- 5 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/msg/msg_global.cpp b/src/msg/msg_global.cpp index c90d181b16..cab13d920d 100644 --- a/src/msg/msg_global.cpp +++ b/src/msg/msg_global.cpp @@ -86,9 +86,6 @@ void MSG_config(const char *key, const char *value){ } static void MSG_exit() { - if (msg_global==nullptr) - return; - delete msg_global; msg_global = nullptr; } diff --git a/src/smpi/mpi/smpi_comm.cpp b/src/smpi/mpi/smpi_comm.cpp index 5a7ddbbaa8..2a80d4cd06 100644 --- a/src/smpi/mpi/smpi_comm.cpp +++ b/src/smpi/mpi/smpi_comm.cpp @@ -265,10 +265,8 @@ void Comm::cleanup_smp(){ Comm::unref(intra_comm_); if (leaders_comm_ != MPI_COMM_NULL) Comm::unref(leaders_comm_); - if (non_uniform_map_ != nullptr) - xbt_free(non_uniform_map_); - if (leaders_map_ != nullptr) - delete[] leaders_map_; + xbt_free(non_uniform_map_); + delete[] leaders_map_; } void Comm::unref(Comm* comm){ diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index ad16d13b7f..c2827d33d7 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -47,8 +47,7 @@ CpuTiTrace::~CpuTiTrace() CpuTiTmgr::~CpuTiTmgr() { - if (trace_) - delete trace_; + delete trace_; } /** @@ -372,9 +371,7 @@ CpuTi::~CpuTi() } void CpuTi::set_speed_trace(tmgr_trace_t trace) { - if (speed_integrated_trace_) - delete speed_integrated_trace_; - + delete speed_integrated_trace_; speed_integrated_trace_ = new CpuTiTmgr(trace, speed_.scale); /* add a fake trace event if periodicity == 0 */ diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index 5fb89fb004..c85eba3fef 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -317,11 +317,8 @@ void surf_exit() delete model; delete all_existing_models; - - if (future_evt_set) { - delete future_evt_set; - future_evt_set = nullptr; - } + delete future_evt_set; + future_evt_set = nullptr; tmgr_finalize(); sg_platf_exit(); diff --git a/src/xbt/automaton/automatonparse_promela.c b/src/xbt/automaton/automatonparse_promela.c index 939bfe9d56..6f59cb4d0f 100644 --- a/src/xbt/automaton/automatonparse_promela.c +++ b/src/xbt/automaton/automatonparse_promela.c @@ -44,8 +44,7 @@ static void new_state(char* id, int src){ parsed_automaton->current_state = state; if(src) { - if (state_id_src) - xbt_free(state_id_src); + xbt_free(state_id_src); state_id_src = xbt_strdup(id); } } -- 2.20.1