refactor: fix warnings

This commit is contained in:
Justin M. Keyes
2017-02-04 05:57:15 +01:00
parent 67fbbdb1b5
commit ea449b16b9
4 changed files with 8 additions and 11 deletions

View File

@@ -4086,10 +4086,8 @@ void fname_expand(buf_T *buf, char_u **ffname, char_u **sfname)
#ifdef WIN32 #ifdef WIN32
if (!buf->b_p_bin) { if (!buf->b_p_bin) {
char_u *rfname;
// If the file name is a shortcut file, use the file it links to. // If the file name is a shortcut file, use the file it links to.
rfname = os_resolve_shortcut(*ffname); char_u *rfname = (char_u *)os_resolve_shortcut(*ffname);
if (rfname != NULL) { if (rfname != NULL) {
xfree(*ffname); xfree(*ffname);
*ffname = rfname; *ffname = rfname;

View File

@@ -14137,11 +14137,9 @@ static void f_resolve(typval_T *argvars, typval_T *rettv, FunPtr fptr)
p = get_tv_string(&argvars[0]); p = get_tv_string(&argvars[0]);
#ifdef WIN32 #ifdef WIN32
{ {
char_u *v = NULL; char *v = os_resolve_shortcut(p);
v = os_resolve_shortcut(p);
if (v != NULL) { if (v != NULL) {
rettv->vval.v_string = v; rettv->vval.v_string = (char_u *)v;
} else { } else {
rettv->vval.v_string = vim_strsave(p); rettv->vval.v_string = vim_strsave(p);
} }

View File

@@ -1517,7 +1517,7 @@ int utf16_to_utf8(const WCHAR *strw, char **str)
0, 0,
strw, strw,
-1, -1,
(LPSTR *)pos, pos,
utf8_len, utf8_len,
NULL, NULL,
NULL); NULL);

View File

@@ -424,11 +424,11 @@ ptrdiff_t os_read(const int fd, bool *ret_eof, char *const ret_buf,
size_t read_bytes = 0; size_t read_bytes = 0;
bool did_try_to_free = false; bool did_try_to_free = false;
while (read_bytes != size) { while (read_bytes != size) {
assert(size >= read_bytes);
const ptrdiff_t cur_read_bytes = read(fd, ret_buf + read_bytes, const ptrdiff_t cur_read_bytes = read(fd, ret_buf + read_bytes,
size - read_bytes); size - read_bytes);
if (cur_read_bytes > 0) { if (cur_read_bytes > 0) {
read_bytes += (size_t)cur_read_bytes; read_bytes += (size_t)cur_read_bytes;
assert(read_bytes <= size);
} }
if (cur_read_bytes < 0) { if (cur_read_bytes < 0) {
const int error = os_translate_sys_error(errno); const int error = os_translate_sys_error(errno);
@@ -527,6 +527,7 @@ ptrdiff_t os_write(const int fd, const char *const buf, const size_t size)
} }
size_t written_bytes = 0; size_t written_bytes = 0;
while (written_bytes != size) { while (written_bytes != size) {
assert(size >= written_bytes);
const ptrdiff_t cur_written_bytes = write(fd, buf + written_bytes, const ptrdiff_t cur_written_bytes = write(fd, buf + written_bytes,
size - written_bytes); size - written_bytes);
if (cur_written_bytes > 0) { if (cur_written_bytes > 0) {
@@ -949,12 +950,12 @@ bool os_fileid_equal_fileinfo(const FileID *file_id,
/// When "fname" is the name of a shortcut (*.lnk) resolve the file it points /// When "fname" is the name of a shortcut (*.lnk) resolve the file it points
/// to and return that name in allocated memory. /// to and return that name in allocated memory.
/// Otherwise NULL is returned. /// Otherwise NULL is returned.
char_u * os_resolve_shortcut(char_u *fname) char *os_resolve_shortcut(char_u *fname)
{ {
HRESULT hr; HRESULT hr;
IPersistFile *ppf = NULL; IPersistFile *ppf = NULL;
OLECHAR wsz[MAX_PATH]; OLECHAR wsz[MAX_PATH];
char_u *rfname = NULL; char *rfname = NULL;
int len; int len;
IShellLinkW *pslw = NULL; IShellLinkW *pslw = NULL;
WIN32_FIND_DATAW ffdw; WIN32_FIND_DATAW ffdw;