summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFrank LENORMAND <lenormf@gmail.com>2015-12-10 11:00:10 +0300
committerFrank LENORMAND <lenormf@gmail.com>2015-12-10 11:00:10 +0300
commitdf31b88187bc1e262abbeddc63c6cde6331bf07a (patch)
treec2c20df6a0382de5f97d77ff9606cef22b48f712 /src
parent2ca1784495f1497b7d93cd0401244ad7d3bcc900 (diff)
Fix "unused result" warnings for several system calls.
Diffstat (limited to 'src')
-rw-r--r--src/file.cc7
-rw-r--r--src/remote.cc3
-rw-r--r--src/shell_manager.cc5
3 files changed, 11 insertions, 4 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)
{
diff --git a/src/remote.cc b/src/remote.cc
index 6169e906..e15d4d0f 100644
--- a/src/remote.cc
+++ b/src/remote.cc
@@ -532,7 +532,8 @@ void RemoteClient::write_next_key()
void send_command(StringView session, StringView command)
{
int sock = connect_to(session);
- ::write(sock, command.data(), (int)command.length());
+ if (::write(sock, command.data(), (int)command.length()) < 0)
+ throw runtime_error(format("unable to write data to socket (fd: {}; errno: {})", sock, ::strerror(errno)));
close(sock);
}
diff --git a/src/shell_manager.cc b/src/shell_manager.cc
index 2d98298e..d8ae6d78 100644
--- a/src/shell_manager.cc
+++ b/src/shell_manager.cc
@@ -29,7 +29,10 @@ namespace
struct Pipe
{
- Pipe() { ::pipe(m_fd); }
+ Pipe() {
+ if (::pipe(m_fd) < 0)
+ throw runtime_error(format("unable to create pipe (fds: {}/{}; errno: {})", m_fd[0], m_fd[1], ::strerror(errno)));
+ }
~Pipe() { close_read_fd(); close_write_fd(); }
int read_fd() const { return m_fd[0]; }