From 3e7a6085312ea8e0cc7b71adaef4074db9b15892 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Fri, 26 May 2017 11:07:22 +0200 Subject: [PATCH] more than 100 codacy treats, not bad 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. --- examples/java/app/bittorrent/Peer.java | 6 +- .../app/centralizedmutex/Coordinator.java | 13 ++-- .../java/app/centralizedmutex/GrantTask.java | 3 +- examples/java/app/centralizedmutex/Main.java | 3 +- examples/java/app/centralizedmutex/Node.java | 3 +- .../app/centralizedmutex/ReleaseTask.java | 3 +- .../app/centralizedmutex/RequestTask.java | 5 +- examples/java/cloud/migration/Daemon.java | 2 +- examples/java/cloud/migration/XVM.java | 2 +- examples/java/dht/chord/ChordTask.java | 3 +- examples/java/dht/chord/Node.java | 47 ++++++------ examples/java/dht/kademlia/Answer.java | 6 +- examples/msg/app-chainsend/broadcaster.c | 12 +-- .../cloud-masterworker/cloud-masterworker.c | 5 +- .../generate_multiple_deployment.sh | 24 +++--- include/xbt/automaton.hpp | 4 +- include/xbt/string.hpp | 5 +- src/bindings/java/org/simgrid/NativeLib.java | 4 +- .../java/org/simgrid/msg/Process.java | 11 +-- .../java/org/simgrid/msg/Storage.java | 9 +-- src/bindings/java/org/simgrid/msg/Task.java | 8 +- src/instr/instr_paje_trace.cpp | 2 +- src/kernel/routing/DijkstraZone.cpp | 15 ++-- src/mc/Frame.cpp | 2 +- src/mc/Process.cpp | 2 - src/mc/checker/simgrid_mc.cpp | 2 +- src/mc/compare.cpp | 4 +- src/mc/mc_base.cpp | 3 +- src/mc/mc_config.cpp | 26 +++---- src/mc/mc_snapshot.h | 4 - src/simix/smx_network.cpp | 2 +- src/smpi/smpi_info.cpp | 2 - src/smpi/smpi_shared.cpp | 2 +- src/smpi/smpi_win.cpp | 13 ++-- src/surf/lagrange.cpp | 2 +- src/surf/maxmin.cpp | 76 +++++++++---------- src/surf/surf_interface.cpp | 3 +- src/xbt/cunit.cpp | 2 +- src/xbt/memory_map.cpp | 1 + src/xbt/xbt_main.cpp | 2 +- src/xbt/xbt_str.cpp | 3 +- teshsuite/java/semaphoreGC/SemaphoreGC.java | 4 +- .../storage_client_server.cpp | 7 +- tools/fix-paje-trace.sh | 13 ++-- tools/jenkins/Coverage.sh | 6 +- tools/jenkins/DynamicAnalysis_description.sh | 2 +- tools/jenkins/build.sh | 18 ++--- tools/tesh/tesh.py | 8 +- 48 files changed, 174 insertions(+), 230 deletions(-) diff --git a/examples/java/app/bittorrent/Peer.java b/examples/java/app/bittorrent/Peer.java index 3a2e19eb85..94d0a68cf8 100644 --- a/examples/java/app/bittorrent/Peer.java +++ b/examples/java/app/bittorrent/Peer.java @@ -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; } diff --git a/examples/java/app/centralizedmutex/Coordinator.java b/examples/java/app/centralizedmutex/Coordinator.java index 193129305b..22b3cfd0d4 100644 --- a/examples/java/app/centralizedmutex/Coordinator.java +++ b/examples/java/app/centralizedmutex/Coordinator.java @@ -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 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 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()) { diff --git a/examples/java/app/centralizedmutex/GrantTask.java b/examples/java/app/centralizedmutex/GrantTask.java index ff21e2a90a..e80bbc4f7a 100644 --- a/examples/java/app/centralizedmutex/GrantTask.java +++ b/examples/java/app/centralizedmutex/GrantTask.java @@ -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. */ diff --git a/examples/java/app/centralizedmutex/Main.java b/examples/java/app/centralizedmutex/Main.java index 24da241f69..cb0a4e5550 100644 --- a/examples/java/app/centralizedmutex/Main.java +++ b/examples/java/app/centralizedmutex/Main.java @@ -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. */ diff --git a/examples/java/app/centralizedmutex/Node.java b/examples/java/app/centralizedmutex/Node.java index 43ed0cf0bd..a1495a00a3 100644 --- a/examples/java/app/centralizedmutex/Node.java +++ b/examples/java/app/centralizedmutex/Node.java @@ -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. */ diff --git a/examples/java/app/centralizedmutex/ReleaseTask.java b/examples/java/app/centralizedmutex/ReleaseTask.java index ebc2286b8d..37c2c7a20b 100644 --- a/examples/java/app/centralizedmutex/ReleaseTask.java +++ b/examples/java/app/centralizedmutex/ReleaseTask.java @@ -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. */ diff --git a/examples/java/app/centralizedmutex/RequestTask.java b/examples/java/app/centralizedmutex/RequestTask.java index adfc3a78ae..c8f4c5c4c8 100644 --- a/examples/java/app/centralizedmutex/RequestTask.java +++ b/examples/java/app/centralizedmutex/RequestTask.java @@ -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; diff --git a/examples/java/cloud/migration/Daemon.java b/examples/java/cloud/migration/Daemon.java index d03d09aed6..d3c2af2001 100644 --- a/examples/java/cloud/migration/Daemon.java +++ b/examples/java/cloud/migration/Daemon.java @@ -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); } diff --git a/examples/java/cloud/migration/XVM.java b/examples/java/cloud/migration/XVM.java index 756b7535a2..3cc30eaeda 100644 --- a/examples/java/cloud/migration/XVM.java +++ b/examples/java/cloud/migration/XVM.java @@ -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){ diff --git a/examples/java/dht/chord/ChordTask.java b/examples/java/dht/chord/ChordTask.java index e17a19b253..04fde06df7 100644 --- a/examples/java/dht/chord/ChordTask.java +++ b/examples/java/dht/chord/ChordTask.java @@ -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. */ diff --git a/examples/java/dht/chord/Node.java b/examples/java/dht/chord/Node.java index 835c316977..1e6f6b16ae 100644 --- a/examples/java/dht/chord/Node.java +++ b/examples/java/dht/chord/Node.java @@ -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(); diff --git a/examples/java/dht/kademlia/Answer.java b/examples/java/dht/kademlia/Answer.java index a18bc2af9d..c339c3b21c 100644 --- a/examples/java/dht/kademlia/Answer.java +++ b/examples/java/dht/kademlia/Answer.java @@ -19,15 +19,15 @@ public class Answer { nodes = new ArrayList<>(); } - int getDestinationId() { + protected int getDestinationId() { return destinationId; } - ArrayList getNodes() { + protected ArrayList getNodes() { return nodes; } - int size() { + protected int size() { return nodes.size(); } diff --git a/examples/msg/app-chainsend/broadcaster.c b/examples/msg/app-chainsend/broadcaster.c index f17ed64827..61a1acaa8a 100644 --- a/examples/msg/app-chainsend/broadcaster.c +++ b/examples/msg/app-chainsend/broadcaster.c @@ -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); diff --git a/examples/msg/cloud-masterworker/cloud-masterworker.c b/examples/msg/cloud-masterworker/cloud-masterworker.c index 0c13cc2380..41fa98969a 100644 --- a/examples/msg/cloud-masterworker/cloud-masterworker.c +++ b/examples/msg/cloud-masterworker/cloud-masterworker.c @@ -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); } diff --git a/examples/smpi/replay_multiple/generate_multiple_deployment.sh b/examples/smpi/replay_multiple/generate_multiple_deployment.sh index e454081f3f..134c852eb8 100755 --- a/examples/smpi/replay_multiple/generate_multiple_deployment.sh +++ b/examples/smpi/replay_multiple/generate_multiple_deployment.sh @@ -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 diff --git a/include/xbt/automaton.hpp b/include/xbt/automaton.hpp index 1c78e9a211..5c3dad854a 100644 --- a/include/xbt/automaton.hpp +++ b/include/xbt/automaton.hpp @@ -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 diff --git a/include/xbt/string.hpp b/include/xbt/string.hpp index b1638673d9..9343ce600d 100644 --- a/include/xbt/string.hpp +++ b/include/xbt/string.hpp @@ -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 bool operator!=(X const& that) const { - return !((*this) == that); + return not (*this == that); } // Compare: diff --git a/src/bindings/java/org/simgrid/NativeLib.java b/src/bindings/java/org/simgrid/NativeLib.java index 11578d490b..6739dba4b3 100644 --- a/src/bindings/java/org/simgrid/NativeLib.java +++ b/src/bindings/java/org/simgrid/NativeLib.java @@ -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() { diff --git a/src/bindings/java/org/simgrid/msg/Process.java b/src/bindings/java/org/simgrid/msg/Process.java index 4e9247b0c4..355856d916 100644 --- a/src/bindings/java/org/simgrid/msg/Process.java +++ b/src/bindings/java/org/simgrid/msg/Process.java @@ -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; diff --git a/src/bindings/java/org/simgrid/msg/Storage.java b/src/bindings/java/org/simgrid/msg/Storage.java index ea762968b3..4b15bba5e5 100644 --- a/src/bindings/java/org/simgrid/msg/Storage.java +++ b/src/bindings/java/org/simgrid/msg/Storage.java @@ -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; diff --git a/src/bindings/java/org/simgrid/msg/Task.java b/src/bindings/java/org/simgrid/msg/Task.java index 0dec155c5b..a82ce2f7c2 100644 --- a/src/bindings/java/org/simgrid/msg/Task.java +++ b/src/bindings/java/org/simgrid/msg/Task.java @@ -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; diff --git a/src/instr/instr_paje_trace.cpp b/src/instr/instr_paje_trace.cpp index dce4b1eb0e..eb4672936d 100644 --- a/src/instr/instr_paje_trace.cpp +++ b/src/instr/instr_paje_trace.cpp @@ -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); } diff --git a/src/kernel/routing/DijkstraZone.cpp b/src/kernel/routing/DijkstraZone.cpp index 6c9efbdf4a..0efd92e0e4 100644 --- a/src/kernel/routing/DijkstraZone.cpp +++ b/src/kernel/routing/DijkstraZone.cpp @@ -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 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) { diff --git a/src/mc/Frame.cpp b/src/mc/Frame.cpp index 4b25440723..09a72de799 100644 --- a/src/mc/Frame.cpp +++ b/src/mc/Frame.cpp @@ -34,4 +34,4 @@ void* Frame::frame_base(unw_cursor_t& unw_cursor) const } } -} \ No newline at end of file +} diff --git a/src/mc/Process.cpp b/src/mc/Process.cpp index ed6f2d0d13..665985fa15 100644 --- a/src/mc/Process.cpp +++ b/src/mc/Process.cpp @@ -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 #include #include diff --git a/src/mc/checker/simgrid_mc.cpp b/src/mc/checker/simgrid_mc.cpp index cf5164b391..e9af0b5894 100644 --- a/src/mc/checker/simgrid_mc.cpp +++ b/src/mc/checker/simgrid_mc.cpp @@ -45,7 +45,7 @@ std::unique_ptr createChecker(simgrid::mc::Session& sessio if (_sg_mc_comms_determinism || _sg_mc_send_determinism) return std::unique_ptr( 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::createSafetyChecker(session)); else diff --git a/src/mc/compare.cpp b/src/mc/compare.cpp index bdc2339ae3..0cc7c2a784 100644 --- a/src/mc/compare.cpp +++ b/src/mc/compare.cpp @@ -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, diff --git a/src/mc/mc_base.cpp b/src/mc/mc_base.cpp index 4bc39eb2a2..8933c4e435 100644 --- a/src/mc/mc_base.cpp +++ b/src/mc/mc_base.cpp @@ -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 diff --git a/src/mc/mc_config.cpp b/src/mc/mc_config.cpp index b188bf7caa..c6b2d716c2 100644 --- a/src/mc/mc_config.cpp +++ b/src/mc/mc_config.cpp @@ -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."); diff --git a/src/mc/mc_snapshot.h b/src/mc/mc_snapshot.h index fb0c109e50..a5c7c17560 100644 --- a/src/mc/mc_snapshot.h +++ b/src/mc/mc_snapshot.h @@ -11,10 +11,6 @@ #include #include -#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" diff --git a/src/simix/smx_network.cpp b/src/simix/smx_network.cpp index f542074033..6233044326 100644 --- a/src/simix/smx_network.cpp +++ b/src/simix/smx_network.cpp @@ -52,7 +52,7 @@ _find_matching_comm(boost::circular_buffer_space_optimized* 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) diff --git a/src/smpi/smpi_info.cpp b/src/smpi/smpi_info.cpp index 5dac6d25c3..584ab1f08d 100644 --- a/src/smpi/smpi_info.cpp +++ b/src/smpi/smpi_info.cpp @@ -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(xbt_dict_get_or_null(dict_, key)); diff --git a/src/smpi/smpi_shared.cpp b/src/smpi/smpi_shared.cpp index d1b16a331d..eaa72b9a50 100644 --- a/src/smpi/smpi_shared.cpp +++ b/src/smpi/smpi_shared.cpp @@ -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); } }; } diff --git a/src/smpi/smpi_win.cpp b/src/smpi/smpi_win.cpp index 2de320092d..6ddaeb52bf 100644 --- a/src/smpi/smpi_win.cpp +++ b/src/smpi/smpi_win.cpp @@ -682,22 +682,21 @@ int Win::finish_comms(int rank){ int size = static_cast(reqqs->size()); if (size > 0) { size = 0; - std::vector* myreqqs = new std::vector(); + std::vector myreqqs; std::vector::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_); diff --git a/src/surf/lagrange.cpp b/src/surf/lagrange.cpp index e82b60f5d7..20f16b5951 100644 --- a/src/surf/lagrange.cpp +++ b/src/surf/lagrange.cpp @@ -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) { */ diff --git a/src/surf/maxmin.cpp b/src/surf/maxmin.cpp index 0f156e3709..ffa7f5936c 100644 --- a/src/surf/maxmin.cpp +++ b/src/surf/maxmin.cpp @@ -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. */ @@ -11,9 +10,11 @@ #include "xbt/mallocator.h" #include "xbt/sysdep.h" #include +#include #include #include /* sprintf */ #include + 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)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::(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::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"); diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index d168c3311d..7ebcf63047 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -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); diff --git a/src/xbt/cunit.cpp b/src/xbt/cunit.cpp index 195d36855f..ba3d860e30 100644 --- a/src/xbt/cunit.cpp +++ b/src/xbt/cunit.cpp @@ -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); diff --git a/src/xbt/memory_map.cpp b/src/xbt/memory_map.cpp index 3551312e6c..47253334f0 100644 --- a/src/xbt/memory_map.cpp +++ b/src/xbt/memory_map.cpp @@ -128,6 +128,7 @@ XBT_PRIVATE std::vector 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 diff --git a/src/xbt/xbt_main.cpp b/src/xbt/xbt_main.cpp index 5781efec4c..d53d973cf2 100644 --- a/src/xbt/xbt_main.cpp +++ b/src/xbt/xbt_main.cpp @@ -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(); diff --git a/src/xbt/xbt_str.cpp b/src/xbt/xbt_str.cpp index 1146eef75f..6637f211da 100644 --- a/src/xbt/xbt_str.cpp +++ b/src/xbt/xbt_str.cpp @@ -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'; diff --git a/teshsuite/java/semaphoreGC/SemaphoreGC.java b/teshsuite/java/semaphoreGC/SemaphoreGC.java index badbfe40ae..cf18ab252f 100644 --- a/teshsuite/java/semaphoreGC/SemaphoreGC.java +++ b/teshsuite/java/semaphoreGC/SemaphoreGC.java @@ -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(); } diff --git a/teshsuite/s4u/storage_client_server/storage_client_server.cpp b/teshsuite/s4u/storage_client_server/storage_client_server.cpp index 0dbda82536..735879fe9f 100644 --- a/teshsuite/s4u/storage_client_server/storage_client_server.cpp +++ b/teshsuite/s4u/storage_client_server/storage_client_server.cpp @@ -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 { diff --git a/tools/fix-paje-trace.sh b/tools/fix-paje-trace.sh index 211a727498..259fae977f 100755 --- a/tools/fix-paje-trace.sh +++ b/tools/fix-paje-trace.sh @@ -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 diff --git a/tools/jenkins/Coverage.sh b/tools/jenkins/Coverage.sh index e6a16947aa..b2ed44aa99 100755 --- a/tools/jenkins/Coverage.sh +++ b/tools/jenkins/Coverage.sh @@ -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 diff --git a/tools/jenkins/DynamicAnalysis_description.sh b/tools/jenkins/DynamicAnalysis_description.sh index 799781c4bf..1203441951 100755 --- a/tools/jenkins/DynamicAnalysis_description.sh +++ b/tools/jenkins/DynamicAnalysis_description.sh @@ -31,7 +31,7 @@ Testing with valgrind and gcov. Click on the graphs for details. - + diff --git a/tools/jenkins/build.sh b/tools/jenkins/build.sh index 525a9c33e5..d92a433ae4 100755 --- a/tools/jenkins/build.sh +++ b/tools/jenkins/build.sh @@ -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 diff --git a/tools/tesh/tesh.py b/tools/tesh/tesh.py index be40773fc6..52729f4234 100755 --- a/tools/tesh/tesh.py +++ b/tools/tesh/tesh.py @@ -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: -- 2.20.1