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.
This commit is contained in:
parent
973c5bc050
commit
49d384b1eb
1 changed files with 6 additions and 3 deletions
|
|
@ -502,9 +502,12 @@ namespace
|
||||||
string_to_tmp(std::string& str, unsigned n, std::string& tmpname)
|
string_to_tmp(std::string& str, unsigned n, std::string& tmpname)
|
||||||
{
|
{
|
||||||
int fd = create_tmpfile('i', n, tmpname);
|
int fd = create_tmpfile('i', n, tmpname);
|
||||||
write(fd, str.c_str(), str.size());
|
ssize_t s = str.size();
|
||||||
write(fd, "\n", 1);
|
if (write(fd, str.c_str(), s) != s
|
||||||
close(fd);
|
|| 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);
|
toclean.push_back(tmpname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue