Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
more than 100 codacy treats, not bad
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 26 May 2017 09:07:22 +0000 (11:07 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 26 May 2017 13:23:15 +0000 (15:23 +0200)
but I'm not sure that any of these changes actually fixed a bug. At
most, they sometimes reduced the brain overload, which is already
something.

48 files changed:
examples/java/app/bittorrent/Peer.java
examples/java/app/centralizedmutex/Coordinator.java
examples/java/app/centralizedmutex/GrantTask.java
examples/java/app/centralizedmutex/Main.java
examples/java/app/centralizedmutex/Node.java
examples/java/app/centralizedmutex/ReleaseTask.java
examples/java/app/centralizedmutex/RequestTask.java
examples/java/cloud/migration/Daemon.java
examples/java/cloud/migration/XVM.java
examples/java/dht/chord/ChordTask.java
examples/java/dht/chord/Node.java
examples/java/dht/kademlia/Answer.java
examples/msg/app-chainsend/broadcaster.c
examples/msg/cloud-masterworker/cloud-masterworker.c
examples/smpi/replay_multiple/generate_multiple_deployment.sh
include/xbt/automaton.hpp
include/xbt/string.hpp
src/bindings/java/org/simgrid/NativeLib.java
src/bindings/java/org/simgrid/msg/Process.java
src/bindings/java/org/simgrid/msg/Storage.java
src/bindings/java/org/simgrid/msg/Task.java
src/instr/instr_paje_trace.cpp
src/kernel/routing/DijkstraZone.cpp
src/mc/Frame.cpp
src/mc/Process.cpp
src/mc/checker/simgrid_mc.cpp
src/mc/compare.cpp
src/mc/mc_base.cpp
src/mc/mc_config.cpp
src/mc/mc_snapshot.h
src/simix/smx_network.cpp
src/smpi/smpi_info.cpp
src/smpi/smpi_shared.cpp
src/smpi/smpi_win.cpp
src/surf/lagrange.cpp
src/surf/maxmin.cpp
src/surf/surf_interface.cpp
src/xbt/cunit.cpp
src/xbt/memory_map.cpp
src/xbt/xbt_main.cpp
src/xbt/xbt_str.cpp
teshsuite/java/semaphoreGC/SemaphoreGC.java
teshsuite/s4u/storage_client_server/storage_client_server.cpp
tools/fix-paje-trace.sh
tools/jenkins/Coverage.sh
tools/jenkins/DynamicAnalysis_description.sh
tools/jenkins/build.sh
tools/tesh/tesh.py

index 3a2e19e..94d0a68 100644 (file)
@@ -216,7 +216,7 @@ public class Peer extends Process {
     return success;
   }
 
-  void handleMessage(Task task) {
+  private void handleMessage(Task task) {
     MessageTask message = (MessageTask)task;
     Connection remotePeer = peers.get(message.peerId);
     switch (message.type) {
@@ -332,7 +332,7 @@ public class Peer extends Process {
     beginReceiveTime = Msg.getClock();
   }
 
-  void waitForPieces() {
+  private void waitForPieces() {
     boolean finished = false;
     while (Msg.getClock() < deadline && !finished) {
       if (commReceived == null) {
@@ -380,7 +380,7 @@ public class Peer extends Process {
    * If the peer has more than pieces, he downloads the pieces that are the less
    * replicated
    */
-  void updateCurrentPiece() {
+  private void updateCurrentPiece() {
     if (currentPieces.size() >= (Common.FILE_PIECES - pieces)) {
       return;
     }
index 1931293..22b3cfd 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -14,18 +13,16 @@ import org.simgrid.msg.Process;
 import org.simgrid.msg.MsgException;
 
 public class Coordinator extends Process {
-  LinkedList<RequestTask> waitingQueue=new LinkedList<>();
-  int csToServe;
-
   public Coordinator(Host host, String name, String[]args) {
     super(host,name,args);
   }
 
   public void main(String[] args) throws MsgException {
-    csToServe = Integer.parseInt(args[0]);
-    Task task;
+    int csToServe = Integer.parseInt(args[0]);
+    LinkedList<RequestTask> waitingQueue=new LinkedList<>();
+     
     while (csToServe >0) {
-      task = Task.receive("coordinator");
+      Task task = Task.receive("coordinator");
       if (task instanceof RequestTask) {
         RequestTask t = (RequestTask) task;
         if (waitingQueue.isEmpty()) {
index ff21e2a..e80bbc4 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 24da241..cb0a4e5 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 43ed0cf..a1495a0 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index ebc2286..37c2c7a 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index adfc3a7..c8f4c5c 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -8,7 +7,7 @@ package app.centralizedmutex;
 import org.simgrid.msg.Task;
 
 public class RequestTask extends Task {
-  String from;
+  protected String from;
   public RequestTask(String name) {
     super();
     from=name;
index d03d09a..d3c2af2 100644 (file)
@@ -11,7 +11,7 @@ import org.simgrid.msg.Process;
 
 public class Daemon extends Process {
   private Task currentTask;
-  public Daemon(VM vm, int load) {
+  public Daemon(VM vm) {
     super((Host)vm,"Daemon");
     currentTask = new Task(this.getHost().getName()+"-daemon-0", this.getHost().getSpeed()*100, 0);
   }
index 756b753..3cc30ea 100644 (file)
@@ -24,7 +24,7 @@ public class XVM extends VM {
     this.currentLoad = 0;
     this.dpIntensity = dpIntensity ;
     this.ramsize= ramsize;
-    this.daemon = new Daemon(this, 100);
+    this.daemon = new Daemon(this);
   }
 
   public void setLoad(int load){  
index e17a19b..04fde06 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2006-2014. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2006-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 835c316..1e6f6b1 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2006-2014. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2006-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -22,7 +21,7 @@ public class Node extends Process {
   protected Comm commReceive;
   ///Last time I changed a finger or my predecessor
   protected double lastChangeDate;
-  int[] fingers;
+  private int[] fingers;
 
   public Node(Host host, String name, String[] args) {
     super(host,name,args);
@@ -109,7 +108,7 @@ public class Node extends Process {
     }
   }
 
-  void handleTask(Task task) {
+  private void handleTask(Task task) {
     if (task instanceof FindSuccessorTask) {
       FindSuccessorTask fTask = (FindSuccessorTask)task;
       Msg.debug("Receiving a 'Find Successor' request from " + fTask.getIssuerHostName() + " for id " + 
@@ -138,7 +137,7 @@ public class Node extends Process {
     }
   }
 
-  void leave() {
+  private void leave() {
     Msg.debug("Well Guys! I Think it's time for me to quit ;)");
     quitNotify(1); //Notify my successor
     quitNotify(-1); //Notify my predecessor.
@@ -148,20 +147,18 @@ public class Node extends Process {
    * @brief Notifies the successor or the predecessor of the current node of the departure
    * @param to 1 to notify the successor, -1 to notify the predecessor
    */
-  static void quitNotify( int to) {
+  static private void quitNotify( int to) {
     //TODO
   }
 
-  /**
-   * @brief Initializes the current node as the first one of the system.
-   */
-  void create() {
+  /** @brief Initializes the current node as the first one of the system  */
+  private void create() {
     Msg.debug("Create a new Chord ring...");
     setPredecessor(-1);
   }
 
   // Makes the current node join the ring, knowing the id of a node already in the ring 
-  boolean join(int knownId) {
+  private boolean join(int knownId) {
     Msg.info("Joining the ring with id " + this.id + " knowing node " + knownId);
     setPredecessor(-1);
     int successorId = remoteFindSuccessor(knownId, this.id);
@@ -173,7 +170,7 @@ public class Node extends Process {
     return successorId != -1;
   }
 
-  void setPredecessor(int predecessorId) {
+  private void setPredecessor(int predecessorId) {
     if (predecessorId != predId) {
       predId = predecessorId;
       if (predecessorId != -1) {
@@ -188,7 +185,7 @@ public class Node extends Process {
    * @param askTo the node to ask to
    * @return the id of its predecessor node, or -1 if the request failed(or if the node does not know its predecessor)
    */
-  int remoteGetPredecessor(int askTo) {
+  private int remoteGetPredecessor(int askTo) {
     int predecessorId = -1;
     boolean stop = false;
     Msg.debug("Sending a 'Get Predecessor' request to " + askTo);
@@ -229,7 +226,7 @@ public class Node extends Process {
    * @param id the id to find
    * @return the id of the successor node, or -1 if the request failed
    */
-  int findSuccessor(int id) {
+  private int findSuccessor(int id) {
     if (isInInterval(id, this.id + 1, fingers[0])) {
       return fingers[0];
     }
@@ -239,7 +236,7 @@ public class Node extends Process {
   }
 
   // Asks another node the successor node of an id.
-  int remoteFindSuccessor(int askTo, int id) {
+  private int remoteFindSuccessor(int askTo, int id) {
     int successor = -1;
     boolean stop = false;
     String askToMailbox = Integer.toString(askTo);
@@ -281,7 +278,7 @@ public class Node extends Process {
   }
 
   // This function is called periodically. It checks the immediate successor of the current node.
-  void stabilize() {
+  private void stabilize() {
     Msg.debug("Stabilizing node");
     int candidateId;
     int successorId = fingers[0];
@@ -303,7 +300,7 @@ public class Node extends Process {
    * @brief Notifies the current node that its predecessor may have changed.
    * @param candidate_id the possible new predecessor
    */
-  void notify(int predecessorCandidateId) {
+  private void notify(int predecessorCandidateId) {
     if (predId == -1 || isInInterval(predecessorCandidateId, predId + 1, this.id - 1 )) {
       setPredecessor(predecessorCandidateId);
     }
@@ -314,7 +311,7 @@ public class Node extends Process {
    * @param notify_id id of the node to notify
    * @param candidate_id the possible new predecessor
    */
-  void remoteNotify(int notifyId, int predecessorCandidateId) {
+  private void remoteNotify(int notifyId, int predecessorCandidateId) {
     Msg.debug("Sending a 'Notify' request to " + notifyId);
     Task sentTask = new NotifyTask(getHost().getName(), this.mailbox, predecessorCandidateId);
     sentTask.dsend(Integer.toString(notifyId));
@@ -322,7 +319,7 @@ public class Node extends Process {
 
   // This function is called periodically.
   // It refreshes the finger table of the current node.
-  void fixFingers() {
+  private void fixFingers() {
     Msg.debug("Fixing fingers");
     int i = this.nextFingerToFix;
     int successorId = this.findSuccessor(this.id + (int)Math.pow(2,i)); //FIXME: SLOW
@@ -336,12 +333,12 @@ public class Node extends Process {
 
   // This function is called periodically.
   // It checks whether the predecessor has failed
-  void checkPredecessor() {
+  private void checkPredecessor() {
     //TODO
   }
 
   // Performs a find successor request to a random id.
-  void randomLookup() {
+  private void randomLookup() {
     int id = 1337;
     //Msg.info("Making a lookup request for id " + id);
     findSuccessor(id);
@@ -352,7 +349,7 @@ public class Node extends Process {
    * @param id the id to find
    * @return the closest preceding finger of that id
    */
-  int closestPrecedingNode(int id) {
+  private int closestPrecedingNode(int id) {
     for (int i = Common.NB_BITS - 1; i >= 0; i--) {
       if (isInInterval(fingers[i], this.id + 1, id - 1)) {
         return fingers[i];
@@ -377,7 +374,7 @@ public class Node extends Process {
    * @param end upper bound
    * @return a non-zero value if id in in [start, end]
    */
-  static boolean isInInterval(int id, int start, int end) {
+  static private boolean isInInterval(int id, int start, int end) {
     int normId = normalize(id);
     int normStart = normalize(start);
     int normEnd = normalize(end);
@@ -397,7 +394,7 @@ public class Node extends Process {
    * @param id an id
    * @return the corresponding normalized id
    */
-  static int normalize(int id) {
+  static private int normalize(int id) {
     return id & (Common.NB_KEYS - 1);
   }
 
@@ -406,7 +403,7 @@ public class Node extends Process {
    * @param finger_index index of the finger to set (0 to nb_bits - 1)
    * @param id the id to set for this finger
    */
-  void setFinger(int fingerIndex, int id) {
+  private void setFinger(int fingerIndex, int id) {
     if (id != fingers[fingerIndex]) {
       fingers[fingerIndex] = id;
       lastChangeDate = Msg.getClock();
index a18bc2a..c339c3b 100644 (file)
@@ -19,15 +19,15 @@ public class Answer {
     nodes = new ArrayList<>();
   }
 
-  int getDestinationId() {
+  protected int getDestinationId() {
     return destinationId;
   }
 
-  ArrayList<Contact> getNodes() {
+  protected ArrayList<Contact> getNodes() {
     return nodes;
   }
 
-  int size() {
+  protected int size() {
     return nodes.size();
   }
 
index f17ed64..61a1aca 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -105,15 +104,12 @@ static void broadcaster_destroy(broadcaster_t bc)
 /** Emitter function  */
 int broadcaster(int argc, char *argv[])
 {
-  broadcaster_t bc = NULL;
-  xbt_dynar_t host_list = NULL;
-  int status;
   unsigned int piece_count = PIECE_COUNT;
 
   XBT_DEBUG("broadcaster");
 
   /* Add every mailbox given by the hostcount in argv[1] to a dynamic array */
-  host_list = build_hostlist_from_hostcount(xbt_str_parse_int(argv[1], "Invalid number of peers: %s"));
+  xbt_dynar_t host_list = build_hostlist_from_hostcount(xbt_str_parse_int(argv[1], "Invalid number of peers: %s"));
 
   /* argv[2] is the number of pieces */
   if (argc > 2) {
@@ -122,10 +118,10 @@ int broadcaster(int argc, char *argv[])
   } else {
     XBT_DEBUG("No piece_count specified, defaulting to %d", piece_count);
   }
-  bc = broadcaster_init(host_list, piece_count);
+  broadcaster_t bc = broadcaster_init(host_list, piece_count);
 
   /* TODO: Error checking */
-  status = broadcaster_send_file(bc);
+  int status = broadcaster_send_file(bc);
 
   broadcaster_destroy(bc);
 
index 0c13cc2..41fa989 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2007-2015. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -152,7 +151,7 @@ static int master_fun(int argc, char *argv[])
   XBT_INFO("# Shutdown the half of worker processes gracefully. The remaining half will be forcibly killed.");
   for (i = 0; i < nb_workers; i++) {
     char mbox[MAXMBOXLEN];
-    snprintf(mbox, MAXMBOXLEN, "MBOX:WRK%02d", i);
+    snprintf(mbox, MAXMBOXLEN, "MBOX:WRK%02u", i);
     msg_task_t finalize = MSG_task_create("finalize", 0, 0, 0);
     MSG_task_send(finalize, mbox);
   }
index e454081..134c852 100755 (executable)
@@ -20,8 +20,6 @@ then
     exit
 fi
 
-EXTOPT=""
-WRAPPER=""
 HOSTFILE=""
 
 while true; do
@@ -29,7 +27,7 @@ while true; do
         "-platform")
            PLATFORM="$2"
             if [ ! -f "${PLATFORM}" ]; then
-               echo "[`basename $0`] ** error: the file '${PLATFORM}' does not exist. Aborting."
+               echo "["$(basename $0)"] ** error: the file \'${PLATFORM}\' does not exist. Aborting."
                exit 1
             fi
            shift 2
@@ -37,7 +35,7 @@ while true; do
         "-hostfile")
            HOSTFILE="$2"
             if [ ! -f "${HOSTFILE}" ]; then
-               echo "[`basename $0`] ** error: the file '${HOSTFILE}' does not exist. Aborting."
+               echo "["$(basename $0)"] ** error: the file \'${HOSTFILE}\' does not exist. Aborting."
                exit 1
             fi
            shift 2
@@ -45,7 +43,7 @@ while true; do
         "-machinefile")
            HOSTFILE="$2"
             if [ ! -f "${HOSTFILE}" ]; then
-               echo "[`basename $0`] ** error: the file '${HOSTFILE}' does not exist. Aborting."
+               echo "["$(basename $0)"] ** error: the file \'${HOSTFILE}\' does not exist. Aborting."
                exit 1
             fi
            shift 2
@@ -88,7 +86,7 @@ fi
 UNROLLEDHOSTFILETMP=0
 
 #parse if our lines are terminated by :num_process
-multiple_processes=`grep -c ":" $HOSTFILE`
+multiple_processes=$(grep -c ":" $HOSTFILE)
 if [ "${multiple_processes}" -gt 0 ] ; then
     UNROLLEDHOSTFILETMP=1
     UNROLLEDHOSTFILE="$(mktemp tmphostXXXXXX)"
@@ -101,9 +99,9 @@ if [ "${multiple_processes}" -gt 0 ] ; then
 fi
 
 # Don't use wc -l to compute it to avoid issues with trailing \n at EOF
-hostfile_procs=`grep -c "[a-zA-Z0-9]" $HOSTFILE`
+hostfile_procs=$(grep -c "[a-zA-Z0-9]" $HOSTFILE)
 if [ ${hostfile_procs} = 0 ] ; then
-   echo "[`basename $0`] ** error: the hostfile '${HOSTFILE}' is empty. Aborting." >&2
+   echo "["$(basename $0)"] ** error: the hostfile \'${HOSTFILE}\' is empty. Aborting." >&2
    exit 1
 fi
 
@@ -119,15 +117,13 @@ APPLICATIONHEAD
 
 ##---- cache hostnames of hostfile---------------
 if [ -n "${HOSTFILE}" ] && [ -f ${HOSTFILE} ]; then
-    hostnames=$(cat ${HOSTFILE} | tr '\n\r' '  ')
-    NUMHOSTS=$(cat ${HOSTFILE} | wc -l)
+    hostnames=$(tr '\n\r' '  ' < ${HOSTFILE})
+    NUMHOSTS=$(wc -l < ${HOSTFILE})
 fi
 
 DESCRIPTIONFILE=$(echo $PROC_ARGS|cut -d' ' -f1)
 
 if [ -n "${DESCRIPTIONFILE}" ] && [ -f "${DESCRIPTIONFILE}" ]; then
-    NUMINSTANCES=$(cat ${DESCRIPTIONFILE} | wc -l)
-    replayinstances=$(cat ${DESCRIPTIONFILE})
     IFS_OLD=$IFS
     IFS=$'\n'
     set -f
@@ -148,10 +144,10 @@ if [ -n "${DESCRIPTIONFILE}" ] && [ -f "${DESCRIPTIONFILE}" ]; then
         fi
         
         sleeptime=$(echo "$line"|cut -d' ' -f4)
-        HAVE_SEQ="`which seq 2>/dev/null`"
+        HAVE_SEQ=$(which seq 2>/dev/null)
 
         if [ -n "${HAVE_SEQ}" ]; then
-            SEQ1=`${HAVE_SEQ} 0 $((${NUMPROCSMINE}-1))`
+            SEQ1=$( ${HAVE_SEQ} 0 $((${NUMPROCSMINE}-1)) )
         else
             cnt=0
             while (( $cnt < ${NUMPROCSMINE} )) ; do
index 1c78e9a..5c3dad8 100644 (file)
@@ -4,8 +4,8 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#ifndef _XBT_AUTOMATON_HPP
-#define _XBT_AUTOMATON_HPP
+#ifndef XBT_AUTOMATON_HPP
+#define XBT_AUTOMATON_HPP
 
 #include <utility>
 
index b163867..9343ce6 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2015. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2015-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -209,7 +208,7 @@ public:
   template<class X>
   bool operator!=(X const& that) const
   {
-    return !((*this) == that);
+    return not (*this == that);
   }
 
   // Compare:
index 11578d4..6739dba 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2016. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -20,7 +20,7 @@ import java.nio.file.Path;
  */
 public final class NativeLib {
        private static boolean isNativeInited = false;
-       static Path tempDir = null; // where the embeeded libraries are unpacked before loading them
+       private static Path tempDir = null; // where the embeeded libraries are unpacked before loading them
 
        /** A static-only "class" don't need no constructor */
        private NativeLib() {
index 4e9247b..355856d 100644 (file)
@@ -51,11 +51,8 @@ public abstract class Process implements Runnable {
 
        /** Time at which the process should be created  */
        protected double startTime = 0;
-       /** Time at which the process should be killed.
-        * 
-        * Set at creation, and used internally by SimGrid
-        */
-       private double killTime = -1;
+       /** Time at which the process should be killed */
+       private double killTime = -1; // Used from the C world
 
        private String name = null;
        
@@ -116,9 +113,9 @@ public abstract class Process implements Runnable {
        public Process(Host host, String name, String[]args) 
        {
                if (host == null)
-                       throw new NullPointerException("Cannot create a process on the null host");
+                       throw new IllegalArgumentException("Cannot create a process on the null host");
                if (name == null)
-                       throw new NullPointerException("Process name cannot be null");
+                       throw new IllegalArgumentException("Process name cannot be null");
                
                this.host = host;
                this.name = name;
index ea76296..4b15bba 100644 (file)
@@ -15,18 +15,11 @@ public class Storage {
         * a native storage. Even if this attribute is public you must never
         * access to it.
         */ 
-       private long bind;
+       private long bind = 0;
 
        /** Storage name */
        protected String name;
 
-       /** User data. */ 
-       private Object data;
-       protected Storage() {
-               this.bind = 0;
-               this.data = null;
-       }
-
        @Override
        public String toString (){
                return this.name; 
index 0dec155..a82ce2f 100644 (file)
@@ -74,13 +74,13 @@ public class Task {
         */ 
        public Task(String name, Host[]hosts, double[]flopsAmount, double[]bytesAmount) {
                if (flopsAmount == null)
-                       throw new NullPointerException("Parallel task flops amounts is null");
+                       throw new IllegalArgumentException("Parallel task flops amounts is null");
                if (bytesAmount == null)
-                       throw new NullPointerException("Parallel task bytes amounts is null");
+                       throw new IllegalArgumentException("Parallel task bytes amounts is null");
                if (hosts == null)
-                       throw new NullPointerException("Host list is null");
+                       throw new IllegalArgumentException("Host list is null");
                if (name == null)
-                       throw new NullPointerException("Parallel task name is null");
+                       throw new IllegalArgumentException("Parallel task name is null");
                
                parallelCreate(name, hosts, flopsAmount, bytesAmount);
                this.name = name;
index dce4b1e..eb46729 100644 (file)
@@ -150,7 +150,6 @@ static void insert_into_buffer (PajeEvent* tbi)
     if (e1->timestamp <= tbi->timestamp)
       break;
   }
-  buffer.insert(i.base(), tbi);
   if (i == buffer.rend())
     XBT_DEBUG("%s: inserted at beginning", __FUNCTION__);
   else if (i == buffer.rbegin())
@@ -158,6 +157,7 @@ static void insert_into_buffer (PajeEvent* tbi)
   else
     XBT_DEBUG("%s: inserted at pos= %zd from its end", __FUNCTION__,
         std::distance(buffer.rbegin(),i));
+  buffer.insert(i.base(), tbi);
 
   buffer_debug(&buffer);
 }
index 6c9efbd..0efd92e 100644 (file)
@@ -44,9 +44,8 @@ namespace kernel {
 namespace routing {
 void DijkstraZone::seal()
 {
-  xbt_node_t node = nullptr;
-  unsigned int cursor2;
   unsigned int cursor;
+  xbt_node_t node = nullptr;
 
   /* Create the topology graph */
   if (not routeGraph_)
@@ -57,9 +56,10 @@ void DijkstraZone::seal()
   /* Add the loopback if needed */
   if (surf_network_model->loopback_ && hierarchy_ == RoutingMode::base) {
     xbt_dynar_foreach (xbt_graph_get_nodes(routeGraph_), cursor, node) {
-      xbt_edge_t edge = nullptr;
 
       bool found = false;
+      xbt_edge_t edge = nullptr;
+      unsigned int cursor2;
       xbt_dynar_foreach (xbt_graph_node_get_outedges(node), cursor2, edge) {
         if (xbt_graph_edge_get_target(edge) == node) {
           found = true;
@@ -238,10 +238,7 @@ void DijkstraZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cb
   /* compose route path with links */
   NetPoint* gw_src = nullptr;
   NetPoint* gw_dst;
-  NetPoint* prev_gw_src;
   NetPoint* first_gw            = nullptr;
-  NetPoint* gw_dst_net_elm      = nullptr;
-  NetPoint* prev_gw_src_net_elm = nullptr;
 
   for (int v = dst_node_id; v != src_node_id; v = pred_arr[v]) {
     xbt_node_t node_pred_v = xbt_dynar_get_as(nodes, pred_arr[v], xbt_node_t);
@@ -251,9 +248,9 @@ void DijkstraZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cb
     if (edge == nullptr)
       THROWF(arg_error, 0, "No route from '%s' to '%s'", src->name().c_str(), dst->name().c_str());
 
-    prev_gw_src = gw_src;
-
     sg_platf_route_cbarg_t e_route = (sg_platf_route_cbarg_t)xbt_graph_edge_get_data(edge);
+
+    NetPoint* prev_gw_src          = gw_src;
     gw_src                         = e_route->gw_src;
     gw_dst                         = e_route->gw_dst;
 
@@ -264,6 +261,8 @@ void DijkstraZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cb
         strcmp(gw_dst->name().c_str(), prev_gw_src->name().c_str())) {
       std::vector<surf::LinkImpl*> e_route_as_to_as;
 
+      NetPoint* gw_dst_net_elm      = nullptr;
+      NetPoint* prev_gw_src_net_elm = nullptr;
       getGlobalRoute(gw_dst_net_elm, prev_gw_src_net_elm, &e_route_as_to_as, nullptr);
       auto pos = route->link_list->begin();
       for (auto link : e_route_as_to_as) {
index 4b25440..09a72de 100644 (file)
@@ -34,4 +34,4 @@ void* Frame::frame_base(unw_cursor_t& unw_cursor) const
 }
 
 }
-}
\ No newline at end of file
+}
index ed6f2d0..665985f 100644 (file)
@@ -4,8 +4,6 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#define _FILE_OFFSET_BITS 64
-
 #include <assert.h>
 #include <stddef.h>
 #include <stdint.h>
index cf5164b..e9af0b5 100644 (file)
@@ -45,7 +45,7 @@ std::unique_ptr<simgrid::mc::Checker> createChecker(simgrid::mc::Session& sessio
   if (_sg_mc_comms_determinism || _sg_mc_send_determinism)
     return std::unique_ptr<simgrid::mc::Checker>(
       simgrid::mc::createCommunicationDeterminismChecker(session));
-  else if (!_sg_mc_property_file || _sg_mc_property_file[0] == '\0')
+  else if (_sg_mc_property_file == nullptr || _sg_mc_property_file[0] == '\0')
     return std::unique_ptr<simgrid::mc::Checker>(
       simgrid::mc::createSafetyChecker(session));
   else
index bdc2339..0cc7c2a 100644 (file)
@@ -1363,9 +1363,7 @@ static int compare_areas_with_type(simgrid::mc::StateComparator& state,
 
       if (addr_pointed1 > process->heap_address
           && addr_pointed1 < mc_snapshot_get_heap_end(snapshot1)) {
-        if (!
-            (addr_pointed2 > process->heap_address
-             && addr_pointed2 < mc_snapshot_get_heap_end(snapshot2)))
+        if (not(addr_pointed2 > process->heap_address && addr_pointed2 < mc_snapshot_get_heap_end(snapshot2)))
           return 1;
         // The pointers are both in the heap:
         return simgrid::mc::compare_heap_area(state,
index 4bc39eb..8933c4e 100644 (file)
@@ -69,7 +69,6 @@ void wait_for_requests()
 // Called from both MCer and MCed:
 bool request_is_enabled(smx_simcall_t req)
 {
-  unsigned int index = 0;
   // TODO, add support for the subtypes?
 
   switch (req->call) {
@@ -132,7 +131,7 @@ bool request_is_enabled(smx_simcall_t req)
     comms = simcall_comm_waitany__get__comms(req);
 #endif
 
-    for (index = 0; index < comms->used; ++index) {
+    for (unsigned int index = 0; index < comms->used; ++index) {
 #if SIMGRID_HAVE_MC
       // Fetch act from MCed memory:
       // HACK, type puning
index b188bf7..c6b2d71 100644 (file)
@@ -63,7 +63,7 @@ int _sg_mc_termination = 0;
 
 void _mc_cfg_cb_reduce(const char *name)
 {
-  if (_sg_cfg_init_status && !_sg_do_model_check)
+  if (_sg_cfg_init_status && not _sg_do_model_check)
     xbt_die
         ("You are specifying a reduction strategy after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
 
@@ -79,7 +79,7 @@ void _mc_cfg_cb_reduce(const char *name)
 
 void _mc_cfg_cb_checkpoint(const char *name)
 {
-  if (_sg_cfg_init_status && !_sg_do_model_check)
+  if (_sg_cfg_init_status && not _sg_do_model_check)
     xbt_die
         ("You are specifying a checkpointing value after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
 
@@ -87,7 +87,7 @@ void _mc_cfg_cb_checkpoint(const char *name)
 }
 
 void _mc_cfg_cb_sparse_checkpoint(const char *name) {
-  if (_sg_cfg_init_status && !_sg_do_model_check)
+  if (_sg_cfg_init_status && not _sg_do_model_check)
     xbt_die("You are specifying a checkpointing value after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
 
   _sg_mc_sparse_checkpoint = xbt_cfg_get_boolean(name);
@@ -95,7 +95,7 @@ void _mc_cfg_cb_sparse_checkpoint(const char *name) {
 
 void _mc_cfg_cb_ksm(const char *name)
 {
-  if (_sg_cfg_init_status && !_sg_do_model_check)
+  if (_sg_cfg_init_status && not _sg_do_model_check)
     xbt_die("You are specifying a KSM value after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
 
   _sg_mc_ksm = xbt_cfg_get_boolean(name);
@@ -103,7 +103,7 @@ void _mc_cfg_cb_ksm(const char *name)
 
 void _mc_cfg_cb_property(const char *name)
 {
-  if (_sg_cfg_init_status && !_sg_do_model_check)
+  if (_sg_cfg_init_status && not _sg_do_model_check)
     xbt_die
         ("You are specifying a property after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
 
@@ -112,7 +112,7 @@ void _mc_cfg_cb_property(const char *name)
 
 void _mc_cfg_cb_hash(const char *name)
 {
-  if (_sg_cfg_init_status && !_sg_do_model_check)
+  if (_sg_cfg_init_status && not _sg_do_model_check)
     xbt_die
         ("You are specifying a value to enable/disable the use of global hash to speedup state comparaison, but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
 
@@ -121,7 +121,7 @@ void _mc_cfg_cb_hash(const char *name)
 
 void _mc_cfg_cb_snapshot_fds(const char *name)
 {
-  if (_sg_cfg_init_status && !_sg_do_model_check)
+  if (_sg_cfg_init_status && not _sg_do_model_check)
     xbt_die
         ("You are specifying a value to enable/disable the use of FD snapshotting, but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
 
@@ -130,7 +130,7 @@ void _mc_cfg_cb_snapshot_fds(const char *name)
 
 void _mc_cfg_cb_max_depth(const char *name)
 {
-  if (_sg_cfg_init_status && !_sg_do_model_check)
+  if (_sg_cfg_init_status && not _sg_do_model_check)
     xbt_die
         ("You are specifying a max depth value after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
 
@@ -139,7 +139,7 @@ void _mc_cfg_cb_max_depth(const char *name)
 
 void _mc_cfg_cb_visited(const char *name)
 {
-  if (_sg_cfg_init_status && !_sg_do_model_check)
+  if (_sg_cfg_init_status && not _sg_do_model_check)
     xbt_die
         ("You are specifying a number of stored visited states after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
 
@@ -148,7 +148,7 @@ void _mc_cfg_cb_visited(const char *name)
 
 void _mc_cfg_cb_dot_output(const char *name)
 {
-  if (_sg_cfg_init_status && !_sg_do_model_check)
+  if (_sg_cfg_init_status && not _sg_do_model_check)
     xbt_die
         ("You are specifying a file name for a dot output of graph state after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
 
@@ -157,7 +157,7 @@ void _mc_cfg_cb_dot_output(const char *name)
 
 void _mc_cfg_cb_comms_determinism(const char *name)
 {
-  if (_sg_cfg_init_status && !_sg_do_model_check)
+  if (_sg_cfg_init_status && not _sg_do_model_check)
     xbt_die
         ("You are specifying a value to enable/disable the detection of determinism in the communications schemes after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
 
@@ -166,7 +166,7 @@ void _mc_cfg_cb_comms_determinism(const char *name)
 
 void _mc_cfg_cb_send_determinism(const char *name)
 {
-  if (_sg_cfg_init_status && !_sg_do_model_check)
+  if (_sg_cfg_init_status && not _sg_do_model_check)
     xbt_die
         ("You are specifying a value to enable/disable the detection of send-determinism in the communications schemes after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
 
@@ -175,7 +175,7 @@ void _mc_cfg_cb_send_determinism(const char *name)
 
 void _mc_cfg_cb_termination(const char *name)
 {
-  if (_sg_cfg_init_status && !_sg_do_model_check)
+  if (_sg_cfg_init_status && not _sg_do_model_check)
     xbt_die
         ("You are specifying a value to enable/disable the detection of non progressive cycles after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
 
index fb0c109..a5c7c17 100644 (file)
 #include <string>
 #include <memory>
 
-#include "src/xbt/mmalloc/mmprivate.h"
-//#include "xbt/asserts.h"
-#include "xbt/base.h"
-
 #include "src/mc/ModelChecker.hpp"
 #include "src/mc/RegionSnapshot.hpp"
 #include "src/mc/mc_forward.hpp"
index f542074..6233044 100644 (file)
@@ -52,7 +52,7 @@ _find_matching_comm(boost::circular_buffer_space_optimized<smx_activity_t>* dequ
     } else if (comm->type == SIMIX_COMM_RECEIVE) {
       other_user_data = comm->dst_data;
     }
-    if (comm->type == type && (!match_fun || match_fun(this_user_data, other_user_data, synchro)) &&
+    if (comm->type == type && (match_fun == nullptr || match_fun(this_user_data, other_user_data, synchro)) &&
         (not comm->match_fun || comm->match_fun(other_user_data, this_user_data, my_synchro))) {
       XBT_DEBUG("Found a matching communication synchro %p", comm);
       if (remove_matching)
index 5dac6d2..584ab1f 100644 (file)
@@ -44,8 +44,6 @@ void Info::set(char *key, char *value){
   xbt_dict_set(dict_, key, xbt_strdup(value), nullptr);
 }
 
-
-
 int Info::get(char *key, int valuelen, char *value, int *flag){
   *flag=false;
   char* tmpvalue=static_cast<char*>(xbt_dict_get_or_null(dict_, key));
index d1b16a3..eaa72b9 100644 (file)
@@ -87,7 +87,7 @@ public:
     return filename_length == that.filename_length && line == that.line &&
            std::memcmp(filename, that.filename, filename_length) == 0;
   }
-  bool operator!=(smpi_source_location const& that) const { return !(*this == that); }
+  bool operator!=(smpi_source_location const& that) const { return not(*this == that); }
 };
 }
 
index 2de3200..6ddaeb5 100644 (file)
@@ -682,22 +682,21 @@ int Win::finish_comms(int rank){
   int size = static_cast<int>(reqqs->size());
   if (size > 0) {
     size = 0;
-    std::vector<MPI_Request>* myreqqs = new std::vector<MPI_Request>();
+    std::vector<MPI_Request> myreqqs;
     std::vector<MPI_Request>::iterator iter = reqqs->begin();
     while (iter != reqqs->end()){
       if(((*iter)!=MPI_REQUEST_NULL) && (((*iter)->src() == rank) || ((*iter)->dst() == rank))){
-          myreqqs->push_back(*iter);
-          iter = reqqs->erase(iter);
-          size++;
+        myreqqs.push_back(*iter);
+        iter = reqqs->erase(iter);
+        size++;
       } else {
         ++iter;
       }
     }
     if(size >0){
-      MPI_Request* treqs = &(*myreqqs)[0];
+      MPI_Request* treqs = &myreqqs[0];
       Request::waitall(size, treqs, MPI_STATUSES_IGNORE);
-      myreqqs->clear();
-      delete myreqqs;
+      myreqqs.clear();
     }
   }
   xbt_mutex_release(mut_);
index e82b60f..20f16b5 100644 (file)
@@ -291,7 +291,7 @@ void lagrange_solve(lmm_system_t sys)
     }
 
     XBT_DEBUG("-------------- Check feasability ----------");
-    if (!__check_feasible(cnst_list, var_list, 0))
+    if (not __check_feasible(cnst_list, var_list, 0))
       overall_modification = 1.0;
     XBT_DEBUG("Iteration %d: overall_modification : %f", iteration, overall_modification);
     /*     if(not dual_updated) { */
index 0f156e3..ffa7f59 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2004-2015. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2004-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 #include "xbt/mallocator.h"
 #include "xbt/sysdep.h"
 #include <cxxabi.h>
+#include <limits>
 #include <math.h>
 #include <stdio.h> /* sprintf */
 #include <stdlib.h>
+
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_maxmin, surf, "Logging specific to SURF (maxmin)");
 
 typedef struct s_dyn_light {
@@ -134,7 +135,6 @@ void lmm_system_free(lmm_system_t sys)
 static inline void lmm_variable_remove(lmm_system_t sys, lmm_variable_t var)
 {
   int i;
-  int nelements;
 
   lmm_element_t elem = nullptr;
 
@@ -153,9 +153,9 @@ static inline void lmm_variable_remove(lmm_system_t sys, lmm_variable_t var)
     xbt_swag_remove(elem, &(elem->constraint->enabled_element_set));
     xbt_swag_remove(elem, &(elem->constraint->disabled_element_set));
     xbt_swag_remove(elem, &(elem->constraint->active_element_set));
-    nelements=xbt_swag_size(&(elem->constraint->enabled_element_set)) +
-              xbt_swag_size(&(elem->constraint->disabled_element_set));
-    if (not nelements)
+    int nelements = xbt_swag_size(&(elem->constraint->enabled_element_set)) +
+                    xbt_swag_size(&(elem->constraint->disabled_element_set));
+    if (nelements == 0)
       make_constraint_inactive(sys, elem->constraint);
     else
       lmm_on_disabled_var(sys,elem->constraint);
@@ -403,7 +403,6 @@ void lmm_shrink(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var)
 void lmm_expand(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, double value)
 {
   lmm_element_t elem = nullptr;
-  double weight;
   int i,current_share;
 
   sys->modified = 1;
@@ -421,7 +420,7 @@ void lmm_expand(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, dou
 
   //Check if we need to disable the variable 
   if(var->weight>0 && var->concurrency_share-current_share>lmm_concurrency_slack(cnst)) {
-    weight=var->weight;
+    double weight = var->weight;
     lmm_disable_var(sys,var);
     for (i = 0; i < var->cnsts_number; i++)
       lmm_on_disabled_var(sys,var->cnsts[i].constraint);
@@ -459,7 +458,7 @@ void lmm_expand(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, dou
 
 void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, double value)
 {
-  int i,j;
+  int i;
   double weight;
   sys->modified = 1;
 
@@ -484,7 +483,7 @@ void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var,
       if(lmm_concurrency_slack(cnst)<lmm_element_concurrency(&var->cnsts[i])){
         weight=var->weight;
         lmm_disable_var(sys,var);
-        for (j = 0; j < var->cnsts_number; j++)
+        for (int j = 0; j < var->cnsts_number; j++)
           lmm_on_disabled_var(sys,var->cnsts[j].constraint);
         var->staged_weight=weight;
         xbt_assert(not var->weight);
@@ -641,7 +640,6 @@ void lmm_print(lmm_system_t sys)
   xbt_swag_t var_list   = nullptr;
   xbt_swag_t elem_list  = nullptr;
   std::string buf       = std::string("MAX-MIN ( ");
-  double sum = 0.0;
 
   /* Printing Objective */
   var_list = &(sys->variable_set);
@@ -657,8 +655,8 @@ void lmm_print(lmm_system_t sys)
   /* Printing Constraints */
   cnst_list = &(sys->active_constraint_set);
   xbt_swag_foreach(_cnst, cnst_list) {
-  cnst = (lmm_constraint_t)_cnst;
-    sum = 0.0;
+    cnst       = (lmm_constraint_t)_cnst;
+    double sum = 0.0;
     //Show  the enabled variables
     elem_list = &(cnst->enabled_element_set);
     buf += "\t";
@@ -965,11 +963,9 @@ int lmm_concurrency_slack(lmm_constraint_t cnstr){
 
 /** \brief Measure the minimum concurrency slack across all constraints where the given var is involved */
 int lmm_cnstrs_min_concurrency_slack(lmm_variable_t var){
-  int i;
-  //FIXME MARTIN: Replace by infinite value std::numeric_limits<int>::(max)(), or something better within Simgrid?
-  int slack,minslack=666;
-  for (i = 0; i < var->cnsts_number; i++) {
-    slack=lmm_concurrency_slack(var->cnsts[i].constraint);
+  int minslack = std::numeric_limits<int>::max();
+  for (int i = 0; i < var->cnsts_number; i++) {
+    int slack = lmm_concurrency_slack(var->cnsts[i].constraint);
 
     //This is only an optimization, to avoid looking at more constraints when slack is already zero
     //Disable it when debugging to let lmm_concurrency_slack catch nasty things
@@ -1251,28 +1247,24 @@ double lmm_constraint_get_usage(lmm_constraint_t cnst) {
 }
 
 void lmm_check_concurrency(lmm_system_t sys){
-  void* _cnst;
-  void* _elem;
-  void* _var;
-  lmm_element_t elem;
-  lmm_constraint_t cnst;
-  lmm_variable_t var;
-  int concurrency;
-  int i,belong_to_enabled,belong_to_disabled,belong_to_active;
-
   //These checks are very expensive, so do them only if we want to debug SURF LMM
   if (XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug)) {
-    xbt_swag_foreach(_cnst, &(sys->constraint_set)) {
-      cnst = (lmm_constraint_t) _cnst;
-      concurrency=0;
-      xbt_swag_foreach(_elem, &(cnst->enabled_element_set)) {
-        elem = (lmm_element_t)_elem;
+    void* cnstIt;
+    xbt_swag_foreach(cnstIt, &(sys->constraint_set))
+    {
+      lmm_constraint_t cnst = (lmm_constraint_t)cnstIt;
+      int concurrency       = 0;
+      void* elemIt;
+      xbt_swag_foreach(elemIt, &(cnst->enabled_element_set))
+      {
+        lmm_element_t elem = (lmm_element_t)elemIt;
         xbt_assert(elem->variable->weight > 0);
         concurrency+=lmm_element_concurrency(elem);
       }
 
-      xbt_swag_foreach(_elem, &(cnst->disabled_element_set)) {
-        elem = (lmm_element_t)_elem;
+      xbt_swag_foreach(elemIt, &(cnst->disabled_element_set))
+      {
+        lmm_element_t elem = (lmm_element_t)elemIt;
         //We should have staged variables only if concurrency is reached in some constraint
         xbt_assert(cnst->concurrency_limit<0 || elem->variable->staged_weight==0 ||
                    lmm_cnstrs_min_concurrency_slack(elem->variable) < elem->variable->concurrency_share,
@@ -1284,18 +1276,20 @@ void lmm_check_concurrency(lmm_system_t sys){
     }
 
     //Check that for each variable, all corresponding elements are in the same state (i.e. same element sets)
-    xbt_swag_foreach(_var, &(sys->variable_set)) {
-      var= (lmm_variable_t) _var;
+    void* varIt;
+    xbt_swag_foreach(varIt, &(sys->variable_set))
+    {
+      lmm_variable_t var = (lmm_variable_t)varIt;
 
       if (not var->cnsts_number)
         continue;
 
-      elem = &var->cnsts[0];
-      belong_to_enabled=xbt_swag_belongs(elem,&(elem->constraint->enabled_element_set));
-      belong_to_disabled=xbt_swag_belongs(elem,&(elem->constraint->disabled_element_set));
-      belong_to_active=xbt_swag_belongs(elem,&(elem->constraint->active_element_set));
+      lmm_element_t elem     = &var->cnsts[0];
+      int belong_to_enabled  = xbt_swag_belongs(elem, &(elem->constraint->enabled_element_set));
+      int belong_to_disabled = xbt_swag_belongs(elem, &(elem->constraint->disabled_element_set));
+      int belong_to_active   = xbt_swag_belongs(elem, &(elem->constraint->active_element_set));
 
-      for (i = 1; i < var->cnsts_number; i++) {
+      for (int i = 1; i < var->cnsts_number; i++) {
         elem = &var->cnsts[i];
         xbt_assert(belong_to_enabled==xbt_swag_belongs(elem,&(elem->constraint->enabled_element_set)),
                    "Variable inconsistency (1): enabled_element_set");
index d168c33..7ebcf63 100644 (file)
@@ -146,7 +146,6 @@ std::ifstream* surf_ifsopen(const char* name)
 }
 FILE *surf_fopen(const char *name, const char *mode)
 {
-  char *buff;
   FILE *file = nullptr;
 
   xbt_assert(name);
@@ -156,7 +155,7 @@ FILE *surf_fopen(const char *name, const char *mode)
 
   /* search relative files in the path */
   for (auto path_elm : surf_path) {
-    buff = bprintf("%s" FILE_DELIM "%s", path_elm.c_str(), name);
+    char* buff = bprintf("%s" FILE_DELIM "%s", path_elm.c_str(), name);
     file = fopen(buff, mode);
     free(buff);
 
index 195d368..ba3d860 100644 (file)
@@ -166,7 +166,7 @@ xbt_test_suite_t xbt_test_suite_new(const char *name, const char *fmt, ...)
   xbt_test_suite_t suite = xbt_new0(struct s_xbt_test_suite, 1);
   va_list ap;
 
-  if (!_xbt_test_suites)
+  if (_xbt_test_suites == nullptr)
     _xbt_test_suites = xbt_dynar_new(sizeof(xbt_test_suite_t), xbt_test_suite_free);
 
   va_start(ap, fmt);
index 3551312..4725333 100644 (file)
@@ -128,6 +128,7 @@ XBT_PRIVATE std::vector<VmMap> get_memory_map(pid_t pid)
       memreg.prot |= PROT_EXEC;
 
     /* Private (copy-on-write) or shared? */
+    memregs.flags = 0;
     if (info.shared)
       memreg.flags |= MAP_SHARED;
     else
index 5781efe..d53d973 100644 (file)
@@ -107,7 +107,7 @@ static void xbt_preinit()
 
 static void xbt_postexit()
 {
-  if (!_sg_do_clean_atexit)
+  if (not _sg_do_clean_atexit)
     return;
   xbt_initialized--;
   xbt_dict_postexit();
index 1146eef..6637f21 100644 (file)
@@ -219,12 +219,11 @@ xbt_dynar_t xbt_str_split_str(const char *s, const char *sep)
 
   while (not done) {
     char *to_push;
-    int v = 0;
     // get the start of the first occurrence of the substring
     q = strstr(p, sep);
     //if substring was not found add the entire string
     if (nullptr == q) {
-      v = strlen(p);
+      int v   = strlen(p);
       to_push = (char*) xbt_malloc(v + 1);
       memcpy(to_push, p, v);
       to_push[v] = '\0';
index badbfe4..cf18ab2 100644 (file)
@@ -13,8 +13,6 @@ import org.simgrid.msg.*;
 import org.simgrid.msg.Process;
 
 class SemCreator extends Process {
-  Semaphore sem; 
-
   SemCreator(Host h, String n){
     super(h, n);
   }
@@ -23,7 +21,7 @@ class SemCreator extends Process {
     int j; 
     Msg.info("Creating 50 new Semaphores, yielding and triggering a GC after each");
     for(j = 1; j <= 50; j++) {
-      sem = new Semaphore(0);
+      new Semaphore(0);
       waitFor(10);
       System.gc();
     }
index 0dbda82..735879f 100644 (file)
@@ -11,12 +11,13 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(storage, "Messages specific for this simulation");
 
 static void display_storage_properties(simgrid::s4u::Storage* storage)
 {
-  xbt_dict_cursor_t cursor = NULL;
-  char* key;
-  char* data;
   xbt_dict_t props = storage->properties();
   if (xbt_dict_length(props) > 0) {
     XBT_INFO("\tProperties of mounted storage: %s", storage->name());
+
+    xbt_dict_cursor_t cursor = NULL;
+    char* key;
+    char* data;
     xbt_dict_foreach (props, cursor, key, data)
       XBT_INFO("\t\t'%s' -> '%s'", key, data);
   } else {
index 211a727..259fae9 100755 (executable)
@@ -1,7 +1,6 @@
 #!/bin/bash
 
-# Copyright (c) 2010, 2014. The SimGrid Team.
-# All rights reserved.
+# Copyright (c) 2010-2017. The SimGrid Team. All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
@@ -14,10 +13,10 @@ fi
 
 TRACE=$1
 echo "input: $TRACE"
-OUTPUT=`echo $TRACE | cut -d\. -f1`.fix.trace
+OUTPUT=$( echo $TRACE | cut -d\. -f1 ).fix.trace
 
-cat $TRACE | grep ^% > header
-DEFEVENTS=`cat header | grep Define | awk '{ print $3 }'`
+grep ^% < $TRACE > header
+DEFEVENTS=$(grep Define < header | awk '{ print $3 }')
 
 GREP=""
 GREP2=""
@@ -28,9 +27,9 @@ do
 done
 GREP="/^%\ /d; /^%     /d; /^%E/d; $GREP"
 
-cat $TRACE | eval grep $GREP2 > types
+grep $GREP2 < $TRACE > types
 /bin/sed -e "$GREP" $TRACE > events
-cat events |  sort -n -k 2 -s > events.sorted
+sort -n -k 2 -s < events > events.sorted
 cat header types events.sorted > $OUTPUT
 rm types events events.sorted header
 
index e6a1694..b2ed44a 100755 (executable)
@@ -66,11 +66,11 @@ ctest -D ExperimentalCoverage || true
 unset JAVA_TOOL_OPTIONS
 if [ -f Testing/TAG ] ; then
 
-  files=`find . -name "jacoco.exec"`
+  files=$( find . -name "jacoco.exec" )
   i=0
   for file in $files
   do
-    sourcepath=`dirname $file`
+    sourcepath=$( dirname $file )
     #convert jacoco reports in xml ones
     ant -f $WORKSPACE/tools/jenkins/jacoco.xml -Dexamplesrcdir=$WORKSPACE -Dbuilddir=$BUILDFOLDER/${sourcepath} -Djarfile=$BUILDFOLDER/simgrid.jar -Djacocodir=${JACOCO_PATH}/lib
     #convert jacoco xml reports in cobertura xml reports
@@ -80,6 +80,6 @@ if [ -f Testing/TAG ] ; then
 
    #convert all gcov reports to xml cobertura reports
    gcovr -r .. --xml-pretty -e teshsuite.* -u -o $WORKSPACE/xml_coverage.xml
-   xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl Testing/`head -n 1 < Testing/TAG`/Test.xml > CTestResults_memcheck.xml
+   xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl Testing/$( head -n 1 < Testing/TAG )/Test.xml > CTestResults_memcheck.xml
    mv CTestResults_memcheck.xml $WORKSPACE
 fi
index 799781c..1203441 100755 (executable)
@@ -31,7 +31,7 @@ Testing with valgrind and gcov. Click on the graphs for details.
  <tr class=\"matrix-row\">  
   <td class=\"matrix-cell\">
     <a href=\"https://ci.inria.fr/simgrid/job/SimGrid-DynamicAnalysis-Valgrind/label=simgrid-debian8-64-dynamic-analysis/valgrindResult/\">
-        <img src=\"https://ci.inria.fr/simgrid/job/SimGrid-DynamicAnalysis/lastCompletedBuild/label=simgrid-debian8-64-dynamic-analysis/artifact/valgrind_graph.png\" title="$VALGRIND_RES">
+        <img src=\"https://ci.inria.fr/simgrid/job/SimGrid-DynamicAnalysis/lastCompletedBuild/label=simgrid-debian8-64-dynamic-analysis/artifact/valgrind_graph.png\" title=\"$VALGRIND_RES\">
        </a>
   </td>
   <td class=\"matrix-cell\">
index 525a9c3..d92a433 100755 (executable)
@@ -94,7 +94,7 @@ PATH="$WORKSPACE/build/lib:$PATH"
 if test "$(uname -o)" != "Msys"; then
   echo "XX"
   echo "XX Build the archive out of the tree"
-  echo "XX   pwd: `pwd`"
+  echo "XX   pwd: "$(pwd)
   echo "XX"
 
   cmake -G"$GENERATOR" -Denable_documentation=OFF $WORKSPACE
@@ -103,9 +103,9 @@ if test "$(uname -o)" != "Msys"; then
   echo "XX"
   echo "XX Open the resulting archive"
   echo "XX"
-  gunzip `cat VERSION`.tar.gz
-  tar xf `cat VERSION`.tar
-  cd `cat VERSION`
+  gunzip $(cat VERSION).tar.gz
+  tar xf $(cat VERSION).tar
+  cd $(cat VERSION)
   mkdir build
   cd build
   SRCFOLDER=".."
@@ -116,7 +116,7 @@ fi
 
 echo "XX"
 echo "XX Configure and build SimGrid"
-echo "XX   pwd: `pwd`"
+echo "XX   pwd: "$(pwd)
 echo "XX"
 cmake -G"$GENERATOR"\
   -Denable_debug=ON -Denable_documentation=OFF -Denable_coverage=OFF \
@@ -134,19 +134,17 @@ make -j$NUMBER_OF_PROCESSORS VERBOSE=1
 
 if test "$(uname -o)" != "Msys"; then
   cd $WORKSPACE/build
-  cd `cat VERSION`/build
+  cd $(cat VERSION)/build
 fi
 
-TRES=0
-
 echo "XX"
 echo "XX Run the tests"
-echo "XX   pwd: `pwd`"
+echo "XX   pwd: "$(pwd)
 echo "XX"
 
 ctest -T test --output-on-failure --no-compress-output || true
 if [ -f Testing/TAG ] ; then
-   xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl Testing/`head -n 1 < Testing/TAG`/Test.xml > CTestResults.xml
+   xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl Testing/$( head -n 1 < Testing/TAG )/Test.xml > CTestResults.xml
    mv CTestResults.xml $WORKSPACE
 fi
 
index be40773..52729f4 100755 (executable)
@@ -305,13 +305,13 @@ class Cmd(object):
 
         try:
             proc = subprocess.Popen(args, bufsize=1, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
-        except OSError as e:
-            if e.errno == 8:
-                e.strerror += "\nOSError: [Errno 8] Executed scripts should start with shebang line (like #!/bin/sh)"
-            raise e
         except FileNotFoundError:
             print("["+FileReader().filename+":"+str(self.linenumber)+"] Cannot start '"+args[0]+"': File not found")
             exit(3)
+        except OSError as osE:
+            if osE.errno == 8:
+                osE.strerror += "\nOSError: [Errno 8] Executed scripts should start with shebang line (like #!/bin/sh)"
+            raise osE
 
         cmdName = FileReader().filename+":"+str(self.linenumber)
         try: