diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-10-21 08:53:55 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-10-21 11:05:49 -0300 |
commit | 79b7263f793206167260fcbc99bd76f73bfeb2c7 (patch) | |
tree | b13a3d75b080cbb953b5c78c9b7d4777156d937b /src/nvim/os/input.c | |
parent | cf9571b7b144f37b61ceaf3b17e84806913fd969 (diff) | |
download | rneovim-79b7263f793206167260fcbc99bd76f73bfeb2c7.tar.gz rneovim-79b7263f793206167260fcbc99bd76f73bfeb2c7.tar.bz2 rneovim-79b7263f793206167260fcbc99bd76f73bfeb2c7.zip |
compilation: Add -Wconversion to more files and validate CONV_SOURCES
All files under the os, api and msgpack_rpc directories have -Wconversion
automatically applied. CONV_SOURCES is also checked for missing files(when
renaming, for example)
Diffstat (limited to 'src/nvim/os/input.c')
-rw-r--r-- | src/nvim/os/input.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index d9dae2b44e..cc693b9f1b 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -72,7 +72,7 @@ void input_stop(void) } // Low level input function. -int os_inchar(uint8_t *buf, int maxlen, int32_t ms, int tb_change_cnt) +int os_inchar(uint8_t *buf, int maxlen, int ms, int tb_change_cnt) { InbufPollResult result; @@ -86,7 +86,7 @@ int os_inchar(uint8_t *buf, int maxlen, int32_t ms, int tb_change_cnt) return 0; } } else { - if ((result = inbuf_poll(p_ut)) == kInputNone) { + if ((result = inbuf_poll((int)p_ut)) == kInputNone) { if (trigger_cursorhold() && maxlen >= 3 && !typebuf_changed(tb_change_cnt)) { buf[0] = K_SPECIAL; @@ -116,7 +116,9 @@ int os_inchar(uint8_t *buf, int maxlen, int32_t ms, int tb_change_cnt) } convert_input(); - return rbuffer_read(input_buffer, (char *)buf, maxlen); + // Safe to convert rbuffer_read to int, it will never overflow since + // we use relatively small buffers. + return (int)rbuffer_read(input_buffer, (char *)buf, (size_t)maxlen); } // Check if a character is available for reading @@ -170,7 +172,7 @@ static bool input_poll(int ms) } // This is a replacement for the old `WaitForChar` function in os_unix.c -static InbufPollResult inbuf_poll(int32_t ms) +static InbufPollResult inbuf_poll(int ms) { if (typebuf_was_filled || rbuffer_pending(input_buffer)) { return kInputAvail; @@ -260,9 +262,9 @@ static void convert_input(void) char *inbuf = rbuffer_read_ptr(input_buffer); size_t count = rbuffer_pending(input_buffer), consume_count = 0; - for (int i = count - 1; i >= 0; i--) { + for (int i = (int)count - 1; i >= 0; i--) { if (inbuf[i] == 3) { - consume_count = i + 1; + consume_count = (size_t)(i + 1); break; } } |