Skip to content

Commit

Permalink
os/FileJournal.cc: fix do-while loop
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dalgaaf committed Jul 17, 2015
1 parent df83eb3 commit 30adf5b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/os/FileJournal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 30adf5b

Please sign in to comment.