From: Frederic Suter Date: Wed, 17 May 2017 14:31:44 +0000 (+0200) Subject: another bunch of sonar treats X-Git-Tag: v3.16~281^2~14 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/88916d6f88d88c7d1652c6a950acd014a7166beb another bunch of sonar treats --- diff --git a/src/surf/network_ib.hpp b/src/surf/network_ib.hpp index ac9b8a8da5..f132f83f84 100644 --- a/src/surf/network_ib.hpp +++ b/src/surf/network_ib.hpp @@ -24,7 +24,7 @@ namespace simgrid { NetworkAction *action; double init_rate; ActiveComm() : destination(nullptr),action(nullptr),init_rate(-1){}; - ~ActiveComm(){}; + virtual ~ActiveComm() = default; }; class IBNode{ @@ -37,7 +37,7 @@ namespace simgrid { //number of comms the node is receiving int nbActiveCommsDown; explicit IBNode(int id) : id(id),nbActiveCommsDown(0){}; - ~IBNode(){}; + virtual ~IBNode() = default; }; class XBT_PRIVATE NetworkIBModel : public NetworkSmpiModel { diff --git a/src/surf/storage_interface.cpp b/src/surf/storage_interface.cpp index 19b836182f..554c9a22ff 100644 --- a/src/surf/storage_interface.cpp +++ b/src/surf/storage_interface.cpp @@ -6,7 +6,6 @@ #include "storage_interface.hpp" #include "surf_private.h" -#include "xbt/file.h" /* xbt_getline */ #include #include #include diff --git a/src/xbt/dict_cursor.c b/src/xbt/dict_cursor.c index ab5872c158..d9f3b14664 100644 --- a/src/xbt/dict_cursor.c +++ b/src/xbt/dict_cursor.c @@ -108,7 +108,8 @@ inline void xbt_dict_cursor_step(xbt_dict_cursor_t cursor) XBT_CDEBUG(xbt_dict_cursor, "next element: %p", current); } - while (current == NULL && ++line <= cursor->dict->table_size) { + while (current == NULL && (line + 1) <= cursor->dict->table_size) { + line++; XBT_CDEBUG(xbt_dict_cursor, "current is NULL, take the next line"); current = cursor->dict->table[line]; XBT_CDEBUG(xbt_dict_cursor, "element in the next line: %p", current); diff --git a/src/xbt/xbt_os_file.c b/src/xbt/xbt_os_file.c index 46dd79a42e..789c14118e 100644 --- a/src/xbt/xbt_os_file.c +++ b/src/xbt/xbt_os_file.c @@ -36,10 +36,7 @@ */ ssize_t xbt_getline(char **buf, size_t *n, FILE *stream) { - ssize_t i; - int ch; - - ch = getc(stream); + int ch = getc(stream); if (ferror(stream) || feof(stream)) return -1; @@ -48,15 +45,20 @@ ssize_t xbt_getline(char **buf, size_t *n, FILE *stream) *buf = xbt_malloc(*n); } - i = 0; + ssize_t i = 0; do { - if (i == *n) - *buf = xbt_realloc(*buf, *n += 512); - (*buf)[i++] = ch; + if (i == *n) { + *n += 512; + *buf = xbt_realloc(*buf, *n); + } + (*buf)[i] = ch; + i++; } while (ch != '\n' && (ch = getc(stream)) != EOF); - if (i == *n) - *buf = xbt_realloc(*buf, *n += 1); + if (i == *n) { + *n += 1; + *buf = xbt_realloc(*buf, *n); + } (*buf)[i] = '\0'; return i; diff --git a/teshsuite/smpi/macro-sample/macro-sample.c b/teshsuite/smpi/macro-sample/macro-sample.c index 4ae5dbad95..e1a4bf7edd 100644 --- a/teshsuite/smpi/macro-sample/macro-sample.c +++ b/teshsuite/smpi/macro-sample/macro-sample.c @@ -48,7 +48,8 @@ int main(int argc, char *argv[]) /* I want the standard error to go below 0.1 second. * Two tests at least will be run (count is not > 0) */ SMPI_SAMPLE_LOCAL(0, 0.1) { - if (verbose || n++ < 2) { + if (verbose || n < 2) { + n++; if (verbose) fprintf(stderr, "(%12.6f)", MPI_Wtime()); else