diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2014-11-27 21:02:30 -0500 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-11-27 21:02:30 -0500 |
commit | 68cee4c28d6c309e18ae35eeba9d5dffaf1078ca (patch) | |
tree | 3f129ff50c55b72fb182b45df4c44212a837171c /src | |
parent | 5e4809f5a4ba4d3cc6a6cdea5f7ac632c73086ab (diff) | |
parent | ce5d6506ba0d8241dbee94aceb56ea53a6bd1ed9 (diff) | |
download | rneovim-68cee4c28d6c309e18ae35eeba9d5dffaf1078ca.tar.gz rneovim-68cee4c28d6c309e18ae35eeba9d5dffaf1078ca.tar.bz2 rneovim-68cee4c28d6c309e18ae35eeba9d5dffaf1078ca.zip |
Merge pull request #1492 from fwalch/fix-wconversion
Fix some more -Wconversion warnings.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/nvim/api/vim.c | 11 | ||||
-rw-r--r-- | src/nvim/cursor_shape.c | 2 | ||||
-rw-r--r-- | src/nvim/digraph.c | 2 | ||||
-rw-r--r-- | src/nvim/ex_cmds2.c | 3 | ||||
-rw-r--r-- | src/nvim/ex_eval.c | 6 | ||||
-rw-r--r-- | src/nvim/file_search.c | 37 | ||||
-rw-r--r-- | src/nvim/indent_c.c | 47 | ||||
-rw-r--r-- | src/nvim/misc2.c | 4 | ||||
-rw-r--r-- | src/nvim/search.c | 2 |
10 files changed, 60 insertions, 58 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index a2d052c4ec..3b05c7329c 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -48,17 +48,14 @@ set(CONV_SOURCES ex_cmds2.c ex_cmds.c ex_docmd.c - ex_eval.c ex_getln.c farsi.c fileio.c - file_search.c fold.c getchar.c hardcopy.c if_cscope.c indent.c - indent_c.c keymap.c main.c mark.c @@ -76,7 +73,6 @@ set(CONV_SOURCES popupmnu.c quickfix.c regexp.c - regexp_nfa.c screen.c search.c sha256.c diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index fc1307090d..fe5fa6274b 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -207,12 +207,11 @@ ArrayOf(String) vim_list_runtime_paths(void) rv.items[i].type = kObjectTypeString; rv.items[i].data.string.data = xmalloc(MAXPATHL); // Copy the path from 'runtimepath' to rv.items[i] - int length = copy_option_part(&rtp, - (char_u *)rv.items[i].data.string.data, - MAXPATHL, - ","); - assert(length >= 0); - rv.items[i].data.string.size = (size_t)length; + size_t length = copy_option_part(&rtp, + (char_u *)rv.items[i].data.string.data, + MAXPATHL, + ","); + rv.items[i].data.string.size = length; } return rv; diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c index 06c8186bf9..87064b4ef3 100644 --- a/src/nvim/cursor_shape.c +++ b/src/nvim/cursor_shape.c @@ -135,7 +135,7 @@ char_u *parse_shape_opt(int what) p += len; if (!VIM_ISDIGIT(*p)) return (char_u *)N_("E548: digit expected"); - long digits = getdigits(&p); + int64_t digits = getdigits(&p); assert(digits <= INT_MAX); int n = (int)digits; if (len == 3) { /* "ver" or "hor" */ diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index 440d07aab0..6587a43452 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -1611,7 +1611,7 @@ void putdigraph(char_u *str) EMSG(_(e_number_exp)); return; } - long digits = getdigits(&str); + int64_t digits = getdigits(&str); assert(digits <= INT_MAX); int n = (int)digits; diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 96410897df..24a1ccf85d 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2116,7 +2116,8 @@ int do_in_runtimepath(char_u *name, int all, DoInRuntimepathCB callback, np = name; while (*np != NUL && (all || !did_one)) { /* Append the pattern from "name" to buf[]. */ - copy_option_part(&np, tail, (int)(MAXPATHL - (tail - buf)), + assert(MAXPATHL >= (tail - buf)); + copy_option_part(&np, tail, (size_t)(MAXPATHL - (tail - buf)), "\t "); if (p_verbose > 2) { diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index fba0b93253..ef3facb18b 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -11,6 +11,7 @@ */ #include <assert.h> #include <stdbool.h> +#include <stdint.h> #include <inttypes.h> #include "nvim/vim.h" @@ -1307,7 +1308,7 @@ void ex_catch(exarg_T *eap) int skip = FALSE; int caught = FALSE; char_u *end; - int save_char = 0; + char_u save_char = 0; char_u *save_cpo; regmatch_T regmatch; int prev_got_int; @@ -1530,7 +1531,8 @@ void ex_finally(exarg_T *eap) pending |= did_throw ? CSTP_THROW : 0; pending |= did_emsg ? CSTP_ERROR : 0; pending |= got_int ? CSTP_INTERRUPT : 0; - cstack->cs_pending[cstack->cs_idx] = pending; + assert(pending >= CHAR_MIN && pending <= CHAR_MAX); + cstack->cs_pending[cstack->cs_idx] = (char)pending; /* It's mandatory that the current exception is stored in the * cstack so that it can be rethrown at the ":endtry" or be diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index 1cb9e1e8f7..a51f088586 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -44,10 +44,13 @@ * functions. */ +#include <assert.h> #include <errno.h> #include <string.h> #include <stdbool.h> +#include <stdint.h> #include <inttypes.h> +#include <limits.h> #include "nvim/vim.h" #include "nvim/ascii.h" @@ -355,12 +358,11 @@ vim_findfile_init ( */ if (stopdirs != NULL) { char_u *walker = stopdirs; - int dircount; while (*walker == ';') walker++; - dircount = 1; + size_t dircount = 1; search_ctx->ffsc_stopdirs_v = xmalloc(sizeof(char_u *)); do { @@ -397,7 +399,7 @@ vim_findfile_init ( */ wc_part = vim_strchr(path, '*'); if (wc_part != NULL) { - int llevel; + int64_t llevel; int len; char *errpt; @@ -425,7 +427,7 @@ vim_findfile_init ( llevel = strtol((char *)wc_part, &errpt, 10); if ((char_u *)errpt != wc_part && llevel > 0 && llevel < 255) - ff_expand_buffer[len++] = llevel; + ff_expand_buffer[len++] = (char_u)llevel; else if ((char_u *)errpt != wc_part && llevel == 0) /* restrict is 0 -> remove already added '**' */ len -= 2; @@ -580,8 +582,7 @@ char_u *vim_findfile(void *search_ctx_arg) char_u *rest_of_wildcards; char_u *path_end = NULL; ff_stack_T *stackp; - int len; - int i; + size_t len; char_u *p; char_u *suf; ff_search_ctx_T *search_ctx; @@ -701,7 +702,7 @@ char_u *vim_findfile(void *search_ctx_arg) rest_of_wildcards = stackp->ffs_wc_path; if (*rest_of_wildcards != NUL) { - len = (int)STRLEN(file_path); + len = STRLEN(file_path); if (STRNCMP(rest_of_wildcards, "**", 2) == 0) { /* pointer to the restrict byte * The restrict byte is not a character! @@ -772,7 +773,7 @@ char_u *vim_findfile(void *search_ctx_arg) * We don't have further wildcards to expand, so we have to * check for the final file now. */ - for (i = stackp->ffs_filearray_cur; + for (int i = stackp->ffs_filearray_cur; i < stackp->ffs_filearray_size; ++i) { if (!path_with_url(stackp->ffs_filearray[i]) && !os_isdir(stackp->ffs_filearray[i])) @@ -788,7 +789,7 @@ char_u *vim_findfile(void *search_ctx_arg) * Try without extra suffix and then with suffixes * from 'suffixesadd'. */ - len = (int)STRLEN(file_path); + len = STRLEN(file_path); if (search_ctx->ffsc_tagfile) suf = (char_u *)""; else @@ -829,7 +830,8 @@ char_u *vim_findfile(void *search_ctx_arg) #endif /* push dir to examine rest of subdirs later */ - stackp->ffs_filearray_cur = i + 1; + assert(i < UCHAR_MAX - 1); + stackp->ffs_filearray_cur = (char_u)(i + 1); ff_push(search_ctx, stackp); if (!path_with_url(file_path)) @@ -856,6 +858,7 @@ char_u *vim_findfile(void *search_ctx_arg) /* Not found or found already, try next suffix. */ if (*suf == NUL) break; + assert(MAXPATHL >= len); copy_option_part(&suf, file_path + len, MAXPATHL - len, ","); } @@ -865,7 +868,7 @@ char_u *vim_findfile(void *search_ctx_arg) * still wildcards left, push the directories for further * search */ - for (i = stackp->ffs_filearray_cur; + for (int i = stackp->ffs_filearray_cur; i < stackp->ffs_filearray_size; ++i) { if (!os_isdir(stackp->ffs_filearray[i])) continue; /* not a directory */ @@ -886,7 +889,7 @@ char_u *vim_findfile(void *search_ctx_arg) * leaves of the directory tree. */ if (STRNCMP(stackp->ffs_wc_path, "**", 2) == 0) { - for (i = stackp->ffs_filearray_cur; + for (int i = stackp->ffs_filearray_cur; i < stackp->ffs_filearray_size; ++i) { if (fnamecmp(stackp->ffs_filearray[i], stackp->ffs_fix_path) == 0) @@ -1397,9 +1400,6 @@ find_file_in_path_option ( * filename on the first call. */ if (first == TRUE) { - int l; - int run; - if (path_with_url(ff_file_to_find)) { file_name = vim_strsave(ff_file_to_find); goto theend; @@ -1407,8 +1407,8 @@ find_file_in_path_option ( /* When FNAME_REL flag given first use the directory of the file. * Otherwise or when this fails use the current directory. */ - for (run = 1; run <= 2; ++run) { - l = (int)STRLEN(ff_file_to_find); + for (int run = 1; run <= 2; ++run) { + size_t l = STRLEN(ff_file_to_find); if (run == 1 && rel_to_curdir && (options & FNAME_REL) @@ -1416,7 +1416,7 @@ find_file_in_path_option ( && STRLEN(rel_fname) + l < MAXPATHL) { STRCPY(NameBuff, rel_fname); STRCPY(path_tail(NameBuff), ff_file_to_find); - l = (int)STRLEN(NameBuff); + l = STRLEN(NameBuff); } else { STRCPY(NameBuff, ff_file_to_find); run = 2; @@ -1436,6 +1436,7 @@ find_file_in_path_option ( } if (*buf == NUL) break; + assert(MAXPATHL >= l); copy_option_part(&buf, NameBuff + l, MAXPATHL - l, ","); } } diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index 509f94dbf2..82f9194fa7 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -1,4 +1,6 @@ +#include <assert.h> #include <inttypes.h> +#include <stdint.h> #include "nvim/vim.h" #include "nvim/ascii.h" @@ -37,7 +39,7 @@ find_start_comment ( /* XXX */ pos_T *pos; char_u *line; char_u *p; - int cur_maxcomment = ind_maxcomment; + int64_t cur_maxcomment = ind_maxcomment; for (;; ) { pos = findmatchlimit(NULL, '*', FM_BACKWARD, cur_maxcomment); @@ -115,27 +117,25 @@ static char_u *skip_string(char_u *p) /* - * Return TRUE if the string "line" starts with a word from 'cinwords'. + * Return true if the string "line" starts with a word from 'cinwords'. */ -int cin_is_cinword(char_u *line) +bool cin_is_cinword(char_u *line) { - char_u *cinw; - char_u *cinw_buf; - int cinw_len; - int retval = FALSE; - int len; + bool retval = false; - cinw_len = (int)STRLEN(curbuf->b_p_cinw) + 1; - cinw_buf = xmalloc(cinw_len); + size_t cinw_len = STRLEN(curbuf->b_p_cinw) + 1; + char_u *cinw_buf = xmalloc(cinw_len); line = skipwhite(line); - for (cinw = curbuf->b_p_cinw; *cinw; ) { - len = copy_option_part(&cinw, cinw_buf, cinw_len, ","); + + for (char_u *cinw = curbuf->b_p_cinw; *cinw; ) { + size_t len = copy_option_part(&cinw, cinw_buf, cinw_len, ","); if (STRNCMP(line, cinw_buf, len) == 0 && (!vim_iswordc(line[len]) || !vim_iswordc(line[len - 1]))) { - retval = TRUE; + retval = true; break; } } + free(cinw_buf); return retval; @@ -662,7 +662,7 @@ static int cin_islinecomment(char_u *p) * Return the character terminating the line (ending char's have precedence if * both apply in order to determine initializations). */ -static int +static char_u cin_isterminated ( char_u *s, int incl_open, /* include '{' at the end as terminator */ @@ -1281,8 +1281,6 @@ void parse_cino(buf_T *buf) { char_u *p; char_u *l; - char_u *digits; - int n; int divider; int fraction = 0; int sw = (int)get_sw_value(buf); @@ -1415,11 +1413,13 @@ void parse_cino(buf_T *buf) l = p++; if (*p == '-') ++p; - digits = p; /* remember where the digits start */ - n = getdigits(&p); + char_u *digits_start = p; /* remember where the digits start */ + int64_t digits = getdigits(&p); + assert(digits <= INT_MAX); + int n = (int)digits; divider = 0; if (*p == '.') { /* ".5s" means a fraction */ - fraction = atol((char *)++p); + fraction = atoi((char *)++p); while (VIM_ISDIGIT(*p)) { ++p; if (divider) @@ -1429,7 +1429,7 @@ void parse_cino(buf_T *buf) } } if (*p == 's') { /* "2s" means two times 'shiftwidth' */ - if (p == digits) + if (p == digits_start) n = sw; /* just "s" is one 'shiftwidth' */ else { n *= sw; @@ -1625,8 +1625,11 @@ int get_c_indent(void) what = *p++; else if (*p == COM_LEFT || *p == COM_RIGHT) align = *p++; - else if (VIM_ISDIGIT(*p) || *p == '-') - off = getdigits(&p); + else if (VIM_ISDIGIT(*p) || *p == '-') { + int64_t digits = getdigits(&p); + assert(digits <= INT_MAX); + off = (int)digits; + } else ++p; } diff --git a/src/nvim/misc2.c b/src/nvim/misc2.c index acf243b349..bc65056b21 100644 --- a/src/nvim/misc2.c +++ b/src/nvim/misc2.c @@ -167,9 +167,9 @@ int csh_like_shell(void) * "*option" is advanced to the next part. * The length is returned. */ -int copy_option_part(char_u **option, char_u *buf, int maxlen, char *sep_chars) +size_t copy_option_part(char_u **option, char_u *buf, size_t maxlen, char *sep_chars) { - int len = 0; + size_t len = 0; char_u *p = *option; /* skip '.' at start of option part, for 'suffixes' */ diff --git a/src/nvim/search.c b/src/nvim/search.c index 78d9dcbccb..e9184d84cd 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -1430,7 +1430,7 @@ static int check_prevcol(char_u *linep, int col, int ch, int *prevcol) * NULL */ -pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int maxtravel) +pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) { static pos_T pos; /* current search position */ int findc = 0; /* matching brace */ |