Skip to content

Commit

Permalink
No ignoring return value
Browse files Browse the repository at this point in the history
  • Loading branch information
mgautierfr committed Aug 31, 2023
1 parent 69675a1 commit f8c2369
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion test/tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ std::unique_ptr<TempFile>
makeTempFile(const char* name, const std::string& content)
{
std::unique_ptr<TempFile> p(new TempFile(name));
write(p->fd(), &content[0], content.size());
if (write(p->fd(), &content[0], content.size()) != (ssize_t)content.size()) {
throw std::runtime_error("Error writing temp file " + p->path());
}
p->close();
return p;
}
Expand Down
4 changes: 3 additions & 1 deletion test/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ zim::Buffer write_to_buffer(const T& object, const std::string& tail="")
TempFile tmpFile("test_temp_file");
const auto tmp_fd = tmpFile.fd();
object.write(tmp_fd);
write(tmp_fd, tail.data(), tail.size());
if (write(tmp_fd, tail.data(), tail.size()) != (ssize_t)tail.size()) {
throw std::runtime_error("Cannot write to " + tmpFile.path());
}
size_type size = LSEEK(tmp_fd, 0, SEEK_END);

auto buf = zim::Buffer::makeBuffer(zim::zsize_t(size));
Expand Down

0 comments on commit f8c2369

Please sign in to comment.