From 4c13ae49e3c558dd6c83e0e1a479c189f57aec45 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 10 Jul 2019 08:48:45 +0200 Subject: [PATCH] Misc sonar threats. --- src/surf/network_cm02.hpp | 3 --- src/surf/xml/surfxml_sax_cb.cpp | 2 +- .../mc/random-bug/random-bug-replay.tesh | 6 ++--- teshsuite/mc/random-bug/random-bug.cpp | 27 +++++++++++-------- teshsuite/mc/random-bug/random-bug.tesh | 8 +++--- 5 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/surf/network_cm02.hpp b/src/surf/network_cm02.hpp index 8cd453e390..1b9469bcde 100644 --- a/src/surf/network_cm02.hpp +++ b/src/surf/network_cm02.hpp @@ -57,9 +57,6 @@ class NetworkWifiLink : public NetworkCm02Link { /** @brief Hold every rates association between host and links (host name, rates id) */ std::map host_rates_; - /** @brief Hold every rates available for this Access Point */ - // double* rates; FIXME: unused - /** @brief A link can have several bandwith attach to it (mostly use by wifi model) */ std::vector bandwidths_; diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index 5544791786..a363d6c14a 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -243,7 +243,7 @@ std::vector surf_parse_get_bandwidths(const char* string, const char* en "Append 'Bps' to get bytes per second (or 'bps' for bits but 1Bps = 8bps)", "Bps")); } - return (bandwidths); + return bandwidths; } double surf_parse_get_speed(const char* string, const char* entity_kind, const std::string& name) diff --git a/teshsuite/mc/random-bug/random-bug-replay.tesh b/teshsuite/mc/random-bug/random-bug-replay.tesh index 11145c900d..ed83684e88 100644 --- a/teshsuite/mc/random-bug/random-bug-replay.tesh +++ b/teshsuite/mc/random-bug/random-bug-replay.tesh @@ -1,12 +1,12 @@ #!/usr/bin/env tesh $ ${bindir:=.}/random-bug printf ${platfdir}/small_platform.xml --log=xbt_cfg.thresh:warning "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" "--cfg=model-check/replay:1/3;1/4" -> Behavior: printf +> [ 0.000000] (0:maestro@) Behavior: printf > [ 0.000000] (0:maestro@) path=1/3;1/4 -> Error reached +> [ 0.000000] (1:app@Fafard) Error reached # Behavior: assert does not have the same output within and without MC, so don't test it here. That's already covered with the other ones ! expect signal SIGIOT $ $VALGRIND_NO_LEAK_CHECK ${bindir:=.}/random-bug abort ${platfdir}/small_platform.xml --log=xbt_cfg.thresh:warning "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" "--cfg=model-check/replay:1/3;1/4" -> Behavior: abort +> [ 0.000000] (0:maestro@) Behavior: abort > [ 0.000000] (0:maestro@) path=1/3;1/4 diff --git a/teshsuite/mc/random-bug/random-bug.cpp b/teshsuite/mc/random-bug/random-bug.cpp index 4f3a9f88b3..23e96cb34f 100644 --- a/teshsuite/mc/random-bug/random-bug.cpp +++ b/teshsuite/mc/random-bug/random-bug.cpp @@ -3,10 +3,12 @@ /* 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 #include #include +#include -#include /* snprintf */ +XBT_LOG_NEW_DEFAULT_CATEGORY(random_bug, "For this example"); enum { ABORT, ASSERT, PRINTF } behavior; @@ -16,13 +18,16 @@ static void app() int x = MC_random(0, 5); int y = MC_random(0, 5); - if (behavior == ABORT) { - abort(); - } else if (behavior == ASSERT) { - MC_assert(x != 3 || y != 4); - } else if (behavior == PRINTF) { - if (x == 3 && y == 4) - fprintf(stderr, "Error reached\n"); + switch (behavior) { + case ABORT: + abort(); + case ASSERT: + MC_assert(x != 3 || y != 4); + break; + case PRINTF: + if (x == 3 && y == 4) + XBT_ERROR("Error reached"); + break; } } @@ -32,13 +37,13 @@ int main(int argc, char* argv[]) simgrid::s4u::Engine e(&argc, argv); xbt_assert(argc == 3, "Usage: random-bug raise|assert "); if (strcmp(argv[1], "abort") == 0) { - printf("Behavior: abort\n"); + XBT_INFO("Behavior: abort"); behavior = ABORT; } else if (strcmp(argv[1], "assert") == 0) { - printf("Behavior: assert\n"); + XBT_INFO("Behavior: assert"); behavior = ASSERT; } else if (strcmp(argv[1], "printf") == 0) { - printf("Behavior: printf\n"); + XBT_INFO("Behavior: printf"); behavior = PRINTF; } diff --git a/teshsuite/mc/random-bug/random-bug.tesh b/teshsuite/mc/random-bug/random-bug.tesh index 4e03424a14..c41c45b317 100644 --- a/teshsuite/mc/random-bug/random-bug.tesh +++ b/teshsuite/mc/random-bug/random-bug.tesh @@ -2,7 +2,7 @@ ! expect return 1 $ ${bindir:=.}/../../../bin/simgrid-mc ${bindir:=.}/random-bug assert ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --log=xbt_cfg.thresh:warning > [ 0.000000] (0:maestro@) Check a safety property. Reduction is: dpor. -> Behavior: assert +> [ 0.000000] (0:maestro@) Behavior: assert > [ 0.000000] (0:maestro@) ************************** > [ 0.000000] (0:maestro@) *** PROPERTY NOT VALID *** > [ 0.000000] (0:maestro@) ************************** @@ -18,7 +18,7 @@ $ ${bindir:=.}/../../../bin/simgrid-mc ${bindir:=.}/random-bug assert ${platfdir # because SIMGRID_MC_EXIT_PROGRAM_CRASH = 6 $ ${bindir:=.}/../../../bin/simgrid-mc ${bindir:=.}/random-bug abort ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --log=xbt_cfg.thresh:warning --log=no_loc > [ 0.000000] (0:maestro@) Check a safety property. Reduction is: dpor. -> Behavior: abort +> [ 0.000000] (0:maestro@) Behavior: abort > [ 0.000000] (0:maestro@) ************************** > [ 0.000000] (0:maestro@) ** CRASH IN THE PROGRAM ** > [ 0.000000] (0:maestro@) ************************** @@ -34,8 +34,8 @@ $ ${bindir:=.}/../../../bin/simgrid-mc ${bindir:=.}/random-bug abort ${platfdir} $ ${bindir:=.}/../../../bin/simgrid-mc ${bindir:=.}/random-bug printf ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --log=xbt_cfg.thresh:warning > [ 0.000000] (0:maestro@) Check a safety property. Reduction is: dpor. -> Behavior: printf -> Error reached +> [ 0.000000] (0:maestro@) Behavior: printf +> [ 0.000000] (1:app@Fafard) Error reached > [ 0.000000] (0:maestro@) No property violation found. > [ 0.000000] (0:maestro@) Expanded states = 43 > [ 0.000000] (0:maestro@) Visited states = 108 -- 2.20.1