From 79b7263f793206167260fcbc99bd76f73bfeb2c7 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Tue, 21 Oct 2014 08:53:55 -0300 Subject: 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) --- src/nvim/os/shell.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src/nvim/os/shell.c') diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 453cc6d605..a127597e52 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -1,4 +1,5 @@ #include +#include #include #include @@ -58,11 +59,11 @@ typedef struct { /// `shell_free_argv` when no longer needed. char **shell_build_argv(const char_u *cmd, const char_u *extra_shell_opt) { - int argc = tokenize(p_sh, NULL) + tokenize(p_shcf, NULL); + size_t argc = tokenize(p_sh, NULL) + tokenize(p_shcf, NULL); char **rv = xmalloc((unsigned)((argc + 4) * sizeof(char *))); // Split 'shell' - int i = tokenize(p_sh, rv); + size_t i = tokenize(p_sh, rv); if (extra_shell_opt != NULL) { // Push a copy of `extra_shell_opt` @@ -356,9 +357,9 @@ static void system_data_cb(RStream *rstream, void *data, bool eof) /// @param argv The vector that will be filled with copies of the parsed /// words. It can be NULL if the caller only needs to count words. /// @return The number of words parsed. -static int tokenize(const char_u *str, char **argv) +static size_t tokenize(const char_u *str, char **argv) { - int argc = 0, len; + size_t argc = 0, len; char_u *p = (char_u *) str; while (*p != NUL) { @@ -383,11 +384,11 @@ static int tokenize(const char_u *str, char **argv) /// /// @param str A pointer to the first character of the word /// @return The offset from `str` at which the word ends. -static int word_length(const char_u *str) +static size_t word_length(const char_u *str) { const char_u *p = str; bool inquote = false; - int length = 0; + size_t length = 0; // Move `p` to the end of shell word by advancing the pointer while it's // inside a quote or it's a non-whitespace character @@ -418,15 +419,15 @@ static void write_selection(uv_write_t *req) // TODO(tarruda): use a static buffer for up to a limit(BUFFER_LENGTH) and // only after filled we should start allocating memory(skip unnecessary // allocations for small writes) - int buflen = BUFFER_LENGTH; + size_t buflen = BUFFER_LENGTH; pdata->wbuffer = (char *)xmalloc(buflen); uv_buf_t uvbuf; linenr_T lnum = curbuf->b_op_start.lnum; - int off = 0; - int written = 0; + size_t off = 0; + size_t written = 0; char_u *lp = ml_get(lnum); - int l; - int len; + size_t l; + size_t len; for (;;) { l = strlen((char *)lp + written); @@ -443,7 +444,7 @@ static void write_selection(uv_write_t *req) pdata->wbuffer[off++] = NUL; } else { char_u *s = vim_strchr(lp + written, NL); - len = s == NULL ? l : s - (lp + written); + len = s == NULL ? l : (size_t)(s - (lp + written)); while (off + len >= buflen) { // Resize the buffer buflen *= 2; @@ -584,6 +585,7 @@ static void exit_cb(uv_process_t *proc, int64_t status, int term_signal) { ProcessData *data = (ProcessData *)proc->data; data->exited++; - data->exit_status = status; + assert(status <= INT_MAX); + data->exit_status = (int)status; uv_close((uv_handle_t *)proc, NULL); } -- cgit From b6c9883169202c2b8ae4ca82a6e70ff3e8cd396f Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Tue, 21 Oct 2014 12:27:25 -0300 Subject: event: Remove direct calls to `uv_run` from job.c/shell.c --- src/nvim/os/shell.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/nvim/os/shell.c') diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index a127597e52..d5464f7975 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -8,6 +8,7 @@ #include "nvim/ascii.h" #include "nvim/lib/kvec.h" #include "nvim/log.h" +#include "nvim/os/event.h" #include "nvim/os/job.h" #include "nvim/os/rstream.h" #include "nvim/os/shell.h" @@ -213,7 +214,7 @@ int os_call_shell(char_u *cmd, ShellOpts opts, char_u *extra_shell_arg) // Keep running the loop until all three handles are completely closed while (pdata.exited < expected_exits) { - uv_run(uv_default_loop(), UV_RUN_ONCE); + event_poll(0); if (got_int) { // Forward SIGINT to the shell -- cgit