From fa8e3f3f20f2f2dc5d160fb70b747568a7b4f1cf Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 25 Jul 2015 13:34:57 +0300 Subject: [PATCH] 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). --- src/nvim/shada.c | 4 ++-- 1 file 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;