]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/FileJournal.cc: fix do-while loop
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Tue, 9 Jun 2015 10:32:42 +0000 (12:32 +0200)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Fri, 17 Jul 2015 08:50:07 +0000 (10:50 +0200)
In case do_submit from libaio fails and returns -EAGAIN the
called continue breaks completely out of the loop since the
loop statement is always false. In this case there is no second
attempt as the code tries. Set the loop condition to true to
fix it.

Fix for:
CID 1297886 (#1 of 1): Structurally dead code (UNREACHABLE)
 continue_in_do_while_false: A continue statement within a do-while
  loop only continues execution of the loop body if the loop
  continuation condition is still true. Since the condition will
  never be true in a "do ... while (false);" loop the continue
  statement has the same effect as a break statement. Did you
  intend execution to continue at the top of the loop?
 do_while_false_condition: This loop will never continue since
  the condition false is never true.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/os/FileJournal.cc

index cf26e5d4f8e71bc3becab38de4fd52fd04ae2b0d..e0ffe069d84356e0206d6cc5fd0dc0c546ab46f8 100644 (file)
@@ -1451,8 +1451,10 @@ int FileJournal::write_aio_bl(off64_t& pos, bufferlist& bl, uint64_t seq)
          continue;
        }
        assert(0 == "io_submit got unexpected error");
+      } else {
+       break;
       }
-    } while (false);
+    } while (true);
     pos += aio.len;
   }
   write_finish_cond.Signal();