diff options
author | George Zhao <zhaozg@gmail.com> | 2018-01-17 19:54:21 +0800 |
---|---|---|
committer | George Zhao <zhaozg@gmail.com> | 2018-01-19 13:01:29 +0800 |
commit | 2408a05151542da9432bd406c36f92c8bdeef1ec (patch) | |
tree | 154c5a1ebcf82c2e4d2c0b7e759a74e833d1b29e /src | |
parent | 421f2605c003c51ce25d131d444489f63a2ad928 (diff) | |
download | rneovim-2408a05151542da9432bd406c36f92c8bdeef1ec.tar.gz rneovim-2408a05151542da9432bd406c36f92c8bdeef1ec.tar.bz2 rneovim-2408a05151542da9432bd406c36f92c8bdeef1ec.zip |
Fix warning, read/write have unsigned int count on windows.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/macros.h | 7 | ||||
-rw-r--r-- | src/nvim/os/fs.c | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/nvim/macros.h b/src/nvim/macros.h index 351fa55929..05065499f4 100644 --- a/src/nvim/macros.h +++ b/src/nvim/macros.h @@ -195,4 +195,11 @@ # define UV_BUF_LEN(x) (x) #endif +// Type of bufcnt for read/write on Windows is unsigned int, not size_t. +#if defined(WIN32) +# define IO_SIZE(x) (unsigned)(x) +#else +# define IO_SIZE(x) (x) +#endif + #endif // NVIM_MACROS_H diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 5f29a45263..f3b3871aac 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -461,7 +461,7 @@ ptrdiff_t os_read(const int fd, bool *ret_eof, char *const ret_buf, while (read_bytes != size) { assert(size >= read_bytes); const ptrdiff_t cur_read_bytes = read(fd, ret_buf + read_bytes, - size - read_bytes); + IO_SIZE(size - read_bytes)); if (cur_read_bytes > 0) { read_bytes += (size_t)cur_read_bytes; } @@ -564,7 +564,7 @@ ptrdiff_t os_write(const int fd, const char *const buf, const size_t size) while (written_bytes != size) { assert(size >= written_bytes); const ptrdiff_t cur_written_bytes = write(fd, buf + written_bytes, - size - written_bytes); + IO_SIZE(size - written_bytes)); if (cur_written_bytes > 0) { written_bytes += (size_t)cur_written_bytes; } |