From deb8d283908c7fd7002d65a4d8920b59a21fdf52 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 12 Dec 2016 15:19:50 +0100 Subject: [PATCH] don't test pointers after dereferencing them (thanks, sonar) --- src/smpi/smpi_mpi_dt.cpp | 10 +++++++--- src/surf/HostImpl.cpp | 7 +++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/smpi/smpi_mpi_dt.cpp b/src/smpi/smpi_mpi_dt.cpp index 634ecf493f..e948b65137 100644 --- a/src/smpi/smpi_mpi_dt.cpp +++ b/src/smpi/smpi_mpi_dt.cpp @@ -436,7 +436,11 @@ void smpi_datatype_use(MPI_Datatype type){ #endif } -void smpi_datatype_unuse(MPI_Datatype type){ +void smpi_datatype_unuse(MPI_Datatype type) +{ + if (type == MPI_DATATYPE_NULL) + return; + if (type->in_use > 0) type->in_use--; @@ -444,9 +448,9 @@ void smpi_datatype_unuse(MPI_Datatype type){ static_cast((type)->substruct)->subtype_free(&type); } - if(type != MPI_DATATYPE_NULL && type->in_use == 0){ + if (type->in_use == 0) smpi_datatype_free(&type); - } + #if HAVE_MC if(MC_is_active()) MC_ignore(&(type->in_use), sizeof(type->in_use)); diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index bc39f8ff97..c727c673b5 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -296,11 +296,10 @@ xbt_dynar_t HostImpl::getAttachedStorageList() { /* Check if the new full path is on the same mount point */ if (!strncmp((const char*)fd->mount, fullpath, strlen(fd->mount))) { - sg_size_t *psize, *new_psize; - psize = (sg_size_t*)xbt_dict_get_or_null(findStorageOnMountList(fd->mount)->content_, fd->name); - new_psize = xbt_new(sg_size_t, 1); - *new_psize = *psize; + sg_size_t* psize = (sg_size_t*)xbt_dict_get_or_null(findStorageOnMountList(fd->mount)->content_, fd->name); if (psize) { // src file exists + sg_size_t* new_psize = xbt_new(sg_size_t, 1); + *new_psize = *psize; xbt_dict_remove(findStorageOnMountList(fd->mount)->content_, fd->name); char* path = (char*)xbt_malloc((strlen(fullpath) - strlen(fd->mount) + 1)); strncpy(path, fullpath + strlen(fd->mount), strlen(fullpath) - strlen(fd->mount) + 1); -- 2.20.1