From 93a6d5f863fff05c78c6380f3cceaaa82fbca5f4 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Sat, 9 Sep 2017 16:05:08 +0200 Subject: [PATCH] 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 --- examples/s4u/app-bittorrent/s4u_tracker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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()) { -- 2.20.1