Commit 49d384b1 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

ltlcross: diagnose failure to write into temporary files

The removes a warning about the return code from write() being
ignored.  Reported by Thomas Badie.

* src/bin/ltlcross.cc (string_to_tmp): Call error() on error.
parent 973c5bc0
......@@ -502,9 +502,12 @@ namespace
string_to_tmp(std::string& str, unsigned n, std::string& tmpname)
{
int fd = create_tmpfile('i', n, tmpname);
write(fd, str.c_str(), str.size());
write(fd, "\n", 1);
close(fd);
ssize_t s = str.size();
if (write(fd, str.c_str(), s) != s
|| write(fd, "\n", 1) != 1)
error(2, errno, "failed to write into %s", tmpname.c_str());
if (close(fd))
error(2, errno, "failed to close %s", tmpname.c_str());
toclean.push_back(tmpname);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment