Wconversion: Fix warnings in file_search.c.

This commit is contained in:
Florian Walch
2014-11-18 20:43:25 +01:00
parent cfe4cada30
commit e3fca96e18
5 changed files with 28 additions and 28 deletions

View File

@@ -51,7 +51,6 @@ set(CONV_SOURCES
ex_getln.c
farsi.c
fileio.c
file_search.c
fold.c
getchar.c
hardcopy.c

View File

@@ -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,
size_t 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;
rv.items[i].data.string.size = length;
}
return rv;

View File

@@ -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) {

View File

@@ -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, ",");
}
}

View File

@@ -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' */