Merge pull request #2943 from ceph/wip-dumper-coverity

tools: Close the fd before returning in Dumper

Reviewed-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2014-11-17 06:57:58 -08:00
commit 7055c88ac2

View File

@ -113,6 +113,7 @@ int Dumper::dump(const char *dump_file)
r = safe_write(fd, buf, sizeof(buf));
if (r) {
derr << "Error " << r << " (" << cpp_strerror(r) << ") writing journal file header" << dendl;
::close(fd);
return r;
}
@ -189,12 +190,14 @@ int Dumper::undump(const char *dump_file)
if (trimmed_pos > start) {
derr << std::hex << "Invalid header (trimmed 0x" << trimmed_pos
<< " > expire 0x" << start << std::dec << dendl;
::close(fd);
return -EINVAL;
}
if (start > write_pos) {
derr << std::hex << "Invalid header (expire 0x" << start
<< " > write 0x" << write_pos << std::dec << dendl;
::close(fd);
return -EINVAL;
}
@ -231,6 +234,7 @@ int Dumper::undump(const char *dump_file)
r = header_cond.wait();
if (r != 0) {
derr << "Failed to write header: " << cpp_strerror(r) << dendl;
::close(fd);
return r;
}
@ -274,6 +278,7 @@ int Dumper::undump(const char *dump_file)
r = write_cond.wait();
if (r != 0) {
derr << "Failed to write header: " << cpp_strerror(r) << dendl;
::close(fd);
return r;
}