mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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).
This commit is contained in:
parent
40bbaa757e
commit
fa8e3f3f20
@ -525,7 +525,7 @@ static ptrdiff_t read_file(ShaDaReadDef *const sd_reader, void *const dest,
|
|||||||
sd_reader->fpos += (uintmax_t) cur_read_bytes;
|
sd_reader->fpos += (uintmax_t) cur_read_bytes;
|
||||||
assert(read_bytes <= size);
|
assert(read_bytes <= size);
|
||||||
}
|
}
|
||||||
if (errno) {
|
if (cur_read_bytes < 0) {
|
||||||
if (errno == EINTR || errno == EAGAIN) {
|
if (errno == EINTR || errno == EAGAIN) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
continue;
|
continue;
|
||||||
@ -576,7 +576,7 @@ static ptrdiff_t write_file(ShaDaWriteDef *const sd_writer,
|
|||||||
if (cur_written_bytes > 0) {
|
if (cur_written_bytes > 0) {
|
||||||
written_bytes += (size_t) cur_written_bytes;
|
written_bytes += (size_t) cur_written_bytes;
|
||||||
}
|
}
|
||||||
if (errno) {
|
if (cur_written_bytes < 0) {
|
||||||
if (errno == EINTR || errno == EAGAIN) {
|
if (errno == EINTR || errno == EAGAIN) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user