Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix unitialized value spotted by scan-build.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 9 Sep 2017 14:05:08 +0000 (16:05 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 9 Sep 2017 19:55:25 +0000 (21:55 +0200)
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<TrackerQuery*>(received);
        # (6) Assigned value is garbage or undefined

examples/s4u/app-bittorrent/s4u_tracker.cpp

index 7ddd5e0..1b8e3e4 100644 (file)
@@ -31,8 +31,8 @@ Tracker::Tracker(std::vector<std::string> 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()) {