diff options
| author | Frank LENORMAND <lenormf@gmail.com> | 2015-12-10 11:00:10 +0300 |
|---|---|---|
| committer | Frank LENORMAND <lenormf@gmail.com> | 2015-12-10 11:00:10 +0300 |
| commit | df31b88187bc1e262abbeddc63c6cde6331bf07a (patch) | |
| tree | c2c20df6a0382de5f97d77ff9606cef22b48f712 /src/file.cc | |
| parent | 2ca1784495f1497b7d93cd0401244ad7d3bcc900 (diff) | |
Fix "unused result" warnings for several system calls.
Diffstat (limited to 'src/file.cc')
| -rw-r--r-- | src/file.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/file.cc b/src/file.cc index bc9c1cf9..508a7bcc 100644 --- a/src/file.cc +++ b/src/file.cc @@ -100,7 +100,9 @@ String compact_path(StringView filename) String real_filename = real_path(filename); char cwd[1024]; - getcwd(cwd, 1024); + if (!::getcwd(cwd, 1024)) + throw runtime_error(format("unable to get the current working directory (errno: {})", ::strerror(errno))); + String real_cwd = real_path(cwd) + "/"; if (prefix_match(real_filename, real_cwd)) return real_filename.substr(real_cwd.length()).str(); @@ -223,7 +225,8 @@ void write_buffer_to_fd(Buffer& buffer, int fd) eoldata = "\n"; if (buffer.options()["BOM"].get<ByteOrderMark>() == ByteOrderMark::Utf8) - ::write(fd, "\xEF\xBB\xBF", 3); + if (::write(fd, "\xEF\xBB\xBF", 3) < 0) + throw runtime_error(format("unable to write data to the buffer (fd: {}; errno: {})", fd, ::strerror(errno))); for (LineCount i = 0; i < buffer.line_count(); ++i) { |
