diff options
author | ZyX <kp-pav@yandex.ru> | 2015-07-25 13:34:57 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2015-10-08 22:00:14 +0300 |
commit | fa8e3f3f20f2f2dc5d160fb70b747568a7b4f1cf (patch) | |
tree | 37885721a15670e3aec133c898868208bd86d586 | |
parent | 40bbaa757e5a0c9c3989871be4ad81fd2a71b39b (diff) | |
download | rneovim-fa8e3f3f20f2f2dc5d160fb70b747568a7b4f1cf.tar.gz rneovim-fa8e3f3f20f2f2dc5d160fb70b747568a7b4f1cf.tar.bz2 rneovim-fa8e3f3f20f2f2dc5d160fb70b747568a7b4f1cf.zip |
shada: Only check errno if read/write returned -1
According to the manual (POSIX) this is the only case when errno is set by these
functions. This is needed because some functions (e.g. buflist_new) leave errno
set to non-zero value under some conditions (e.g. when opening non-existing
files).
-rw-r--r-- | src/nvim/shada.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/nvim/shada.c b/src/nvim/shada.c index da107ef38b..d7b3e27550 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -525,7 +525,7 @@ static ptrdiff_t read_file(ShaDaReadDef *const sd_reader, void *const dest, sd_reader->fpos += (uintmax_t) cur_read_bytes; assert(read_bytes <= size); } - if (errno) { + if (cur_read_bytes < 0) { if (errno == EINTR || errno == EAGAIN) { errno = 0; continue; @@ -576,7 +576,7 @@ static ptrdiff_t write_file(ShaDaWriteDef *const sd_writer, if (cur_written_bytes > 0) { written_bytes += (size_t) cur_written_bytes; } - if (errno) { + if (cur_written_bytes < 0) { if (errno == EINTR || errno == EAGAIN) { errno = 0; continue; |