From: Arnaud Giersch Date: Sat, 9 Sep 2017 14:05:08 +0000 (+0200) Subject: Fix unitialized value spotted by scan-build. X-Git-Tag: v3_17~159 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/93a6d5f863fff05c78c6380f3cceaaa82fbca5f4?ds=sidebyside Fix unitialized value spotted by scan-build. 34 while (simgrid::s4u::Engine::getClock() < deadline) { # (1) Loop condition is true. Entering loop body 35 void* received; # (2) 'received' declared without an initial value 36 if (comm == nullptr) # (3) Taking false branch 37 comm = mailbox->get_async(&received); 38 if (comm->test()) { # (4) Assuming the condition is true # (5) Taking true branch 39 // Retrieve the data sent by the peer. 40 TrackerQuery* tq = static_cast(received); # (6) Assigned value is garbage or undefined --- diff --git a/examples/s4u/app-bittorrent/s4u_tracker.cpp b/examples/s4u/app-bittorrent/s4u_tracker.cpp index 7ddd5e095a..1b8e3e4290 100644 --- a/examples/s4u/app-bittorrent/s4u_tracker.cpp +++ b/examples/s4u/app-bittorrent/s4u_tracker.cpp @@ -31,8 +31,8 @@ Tracker::Tracker(std::vector args) void Tracker::operator()() { simgrid::s4u::CommPtr comm = nullptr; + void* received; while (simgrid::s4u::Engine::getClock() < deadline) { - void* received; if (comm == nullptr) comm = mailbox->get_async(&received); if (comm->test()) {