aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRui Abreu Ferreira <raf-ep@gmx.com>2015-10-20 00:13:37 +0100
committerRui Abreu Ferreira <raf-ep@gmx.com>2015-11-25 23:16:37 +0000
commit5bc6e0dc74828064acef3bdafbf9986435edd0df (patch)
tree488206d29febe2a74c7ed54a8183777c6580d9e3
parent28e59cb2235c9cf37571e339bd09df3e8acacaf6 (diff)
downloadrneovim-5bc6e0dc74828064acef3bdafbf9986435edd0df.tar.gz
rneovim-5bc6e0dc74828064acef3bdafbf9986435edd0df.tar.bz2
rneovim-5bc6e0dc74828064acef3bdafbf9986435edd0df.zip
Update shada.c to use libuv error constants instead of errno constants
From #3473, shada.c used errno constants (e.g. ENOENT) to check the return of os_open(), but in Windows the return from libuv functions is not -errno. Instead use libuv error constants (e.g UV_ENOENT) for error checks.
-rw-r--r--src/nvim/shada.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index 939c435c01..231dad07e5 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -815,7 +815,7 @@ static ShaDaReadResult sd_reader_skip(ShaDaReadDef *const sd_reader,
///
/// All arguments are passed to os_open().
///
-/// @return file descriptor or -errno on failure.
+/// @return file descriptor or libuv error on failure.
static int open_file(const char *const fname, const int flags, const int mode)
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{
@@ -825,15 +825,15 @@ open_file_start:
fd = os_open(fname, flags, mode);
if (fd < 0) {
- if (-fd == ENOENT) {
+ if (fd == UV_ENOENT) {
return fd;
}
- if (-fd == ENOMEM && !did_try_to_free) {
+ if (fd == UV_ENOMEM && !did_try_to_free) {
try_to_free_memory();
did_try_to_free = true;
goto open_file_start;
}
- if (-fd != EEXIST) {
+ if (fd != UV_EEXIST) {
emsg3(_(SERR "System error while opening ShaDa file %s: %s"),
fname, os_strerror(fd));
}
@@ -847,7 +847,7 @@ open_file_start:
/// @param[in] fname File name to open.
/// @param[out] sd_reader Location where reader structure will be saved.
///
-/// @return -errno in case of error, 0 otherwise.
+/// @return libuv error in case of error, 0 otherwise.
static int open_shada_file_for_reading(const char *const fname,
ShaDaReadDef *sd_reader)
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
@@ -965,7 +965,7 @@ static int shada_read_file(const char *const file, const int flags)
}
if (of_ret != 0) {
- if (-of_ret == ENOENT && (flags & kShaDaMissingError)) {
+ if (of_ret == UV_ENOENT && (flags & kShaDaMissingError)) {
emsg3(_(SERR "System error while opening ShaDa file %s for reading: %s"),
fname, os_strerror(of_ret));
}
@@ -2964,9 +2964,9 @@ shada_write_file_open:
fd = (intptr_t) open_file(tempname, O_CREAT|O_WRONLY|O_NOFOLLOW|O_EXCL,
perm);
if (fd < 0) {
- if (-fd == EEXIST
+ if (fd == UV_EEXIST
#ifdef ELOOP
- || -fd == ELOOP
+ || fd == UV_ELOOP
#endif
) {
// File already exists, try another name