Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
another bunch of sonar treats
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 17 May 2017 14:31:44 +0000 (16:31 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 17 May 2017 14:31:44 +0000 (16:31 +0200)
src/surf/network_ib.hpp
src/surf/storage_interface.cpp
src/xbt/dict_cursor.c
src/xbt/xbt_os_file.c
teshsuite/smpi/macro-sample/macro-sample.c

index ac9b8a8..f132f83 100644 (file)
@@ -24,7 +24,7 @@ namespace simgrid {
       NetworkAction *action;
       double init_rate;
       ActiveComm() : destination(nullptr),action(nullptr),init_rate(-1){};
       NetworkAction *action;
       double init_rate;
       ActiveComm() : destination(nullptr),action(nullptr),init_rate(-1){};
-      ~ActiveComm(){};
+      virtual ~ActiveComm() = default;
     };
 
     class IBNode{
     };
 
     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){};
       //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 {
     };
 
     class XBT_PRIVATE NetworkIBModel : public NetworkSmpiModel {
index 19b8361..554c9a2 100644 (file)
@@ -6,7 +6,6 @@
 
 #include "storage_interface.hpp"
 #include "surf_private.h"
 
 #include "storage_interface.hpp"
 #include "surf_private.h"
-#include "xbt/file.h" /* xbt_getline */
 #include <boost/algorithm/string.hpp>
 #include <boost/algorithm/string/join.hpp>
 #include <boost/algorithm/string/split.hpp>
 #include <boost/algorithm/string.hpp>
 #include <boost/algorithm/string/join.hpp>
 #include <boost/algorithm/string/split.hpp>
index ab5872c..d9f3b14 100644 (file)
@@ -108,7 +108,8 @@ inline void xbt_dict_cursor_step(xbt_dict_cursor_t cursor)
       XBT_CDEBUG(xbt_dict_cursor, "next element: %p", current);
     }
 
       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);
       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);
index 46dd79a..789c141 100644 (file)
  */
 ssize_t xbt_getline(char **buf, size_t *n, FILE *stream)
 {
  */
 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;
 
   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);
   }
 
     *buf = xbt_malloc(*n);
   }
 
-  i = 0;
+  ssize_t i = 0;
   do {
   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);
 
   } 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;
   (*buf)[i] = '\0';
 
   return i;
index 4ae5dba..e1a4bf7 100644 (file)
@@ -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) {
     /* 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
         if (verbose)
           fprintf(stderr, "(%12.6f)", MPI_Wtime());
         else