Skip to content

Commit 6aa2cd4

Browse files
committed
patch 7.4.1334
Problem: Many compiler warnings with MingW. Solution: Add type casts. (Yasuhiro Matsumoto)
1 parent f8df7ad commit 6aa2cd4

18 files changed

Lines changed: 194 additions & 153 deletions

src/channel.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ extern HWND s_hwnd; /* Gvim's Window handle */
5858

5959
#ifdef WIN32
6060
static int
61-
fd_read(sock_T fd, char_u *buf, size_t len)
61+
fd_read(sock_T fd, char *buf, size_t len)
6262
{
6363
HANDLE h = (HANDLE)fd;
6464
DWORD nread;
@@ -69,7 +69,7 @@ fd_read(sock_T fd, char_u *buf, size_t len)
6969
}
7070

7171
static int
72-
fd_write(sock_T fd, char_u *buf, size_t len)
72+
fd_write(sock_T fd, char *buf, size_t len)
7373
{
7474
HANDLE h = (HANDLE)fd;
7575
DWORD nwrite;
@@ -1393,7 +1393,7 @@ channel_wait(channel_T *channel, sock_T fd, int timeout)
13931393
/* reading from a pipe, not a socket */
13941394
while (TRUE)
13951395
{
1396-
if (PeekNamedPipe(fd, NULL, 0, NULL, &nread, NULL) && nread > 0)
1396+
if (PeekNamedPipe((HANDLE)fd, NULL, 0, NULL, &nread, NULL) && nread > 0)
13971397
return OK;
13981398
diff = deadline - GetTickCount();
13991399
if (diff < 0)
@@ -1509,9 +1509,9 @@ channel_read(channel_T *channel, int which, char *func)
15091509
if (channel_wait(channel, fd, 0) == FAIL)
15101510
break;
15111511
if (use_socket)
1512-
len = sock_read(fd, buf, MAXMSGSIZE);
1512+
len = sock_read(fd, (char *)buf, MAXMSGSIZE);
15131513
else
1514-
len = fd_read(fd, buf, MAXMSGSIZE);
1514+
len = fd_read(fd, (char *)buf, MAXMSGSIZE);
15151515
if (len <= 0)
15161516
break; /* error or nothing more to read */
15171517

@@ -1713,9 +1713,9 @@ channel_send(channel_T *channel, char_u *buf, char *fun)
17131713
}
17141714

17151715
if (use_socket)
1716-
res = sock_write(fd, buf, len);
1716+
res = sock_write(fd, (char *)buf, len);
17171717
else
1718-
res = fd_write(fd, buf, len);
1718+
res = fd_write(fd, (char *)buf, len);
17191719
if (res != len)
17201720
{
17211721
if (!channel->ch_error && fun != NULL)

src/dosinst.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ run_command(char *cmd)
452452
/*
453453
* Append a backslash to "name" if there isn't one yet.
454454
*/
455-
static void
455+
void
456456
add_pathsep(char *name)
457457
{
458458
int len = strlen(name);

src/eval.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14554,7 +14554,7 @@ f_job_start(typval_T *argvars UNUSED, typval_T *rettv)
1455414554
#ifdef USE_ARGV
1455514555
mch_start_job(argv, job);
1455614556
#else
14557-
mch_start_job(cmd, job);
14557+
mch_start_job((char *)cmd, job);
1455814558
#endif
1455914559

1456014560
theend:
@@ -16410,7 +16410,7 @@ f_remote_peek(typval_T *argvars UNUSED, typval_T *rettv)
1641016410
return; /* type error; errmsg already given */
1641116411
}
1641216412
# ifdef WIN32
16413-
sscanf(serverid, SCANF_HEX_LONG_U, &n);
16413+
sscanf((const char *)serverid, SCANF_HEX_LONG_U, &n);
1641416414
if (n == 0)
1641516415
rettv->vval.v_number = -1;
1641616416
else
@@ -16456,7 +16456,7 @@ f_remote_read(typval_T *argvars UNUSED, typval_T *rettv)
1645616456
/* The server's HWND is encoded in the 'id' parameter */
1645716457
long_u n = 0;
1645816458

16459-
sscanf(serverid, SCANF_HEX_LONG_U, &n);
16459+
sscanf((char *)serverid, SCANF_HEX_LONG_U, &n);
1646016460
if (n != 0)
1646116461
r = serverGetReply((HWND)n, FALSE, TRUE, TRUE);
1646216462
if (r == NULL)
@@ -25415,7 +25415,7 @@ get_short_pathname(char_u **fnamep, char_u **bufp, int *fnamelen)
2541525415
char_u *newbuf;
2541625416

2541725417
len = *fnamelen;
25418-
l = GetShortPathName(*fnamep, *fnamep, len);
25418+
l = GetShortPathName((LPSTR)*fnamep, (LPSTR)*fnamep, len);
2541925419
if (l > len - 1)
2542025420
{
2542125421
/* If that doesn't work (not enough space), then save the string
@@ -25428,7 +25428,7 @@ get_short_pathname(char_u **fnamep, char_u **bufp, int *fnamelen)
2542825428
*fnamep = *bufp = newbuf;
2542925429

2543025430
/* Really should always succeed, as the buffer is big enough. */
25431-
l = GetShortPathName(*fnamep, *fnamep, l+1);
25431+
l = GetShortPathName((LPSTR)*fnamep, (LPSTR)*fnamep, l+1);
2543225432
}
2543325433

2543425434
*fnamelen = l;
@@ -25720,7 +25720,7 @@ modify_fname(
2572025720
p = alloc(_MAX_PATH + 1);
2572125721
if (p != NULL)
2572225722
{
25723-
if (GetLongPathName(*fnamep, p, _MAX_PATH))
25723+
if (GetLongPathName((LPSTR)*fnamep, (LPSTR)p, _MAX_PATH))
2572425724
{
2572525725
vim_free(*bufp);
2572625726
*bufp = *fnamep = p;

src/ex_cmds2.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4149,16 +4149,16 @@ ex_checktime(exarg_T *eap)
41494149
#if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
41504150
&& (defined(FEAT_EVAL) || defined(FEAT_MULTI_LANG))
41514151
# define HAVE_GET_LOCALE_VAL
4152-
static char *get_locale_val(int what);
4152+
static char_u *get_locale_val(int what);
41534153

4154-
static char *
4154+
static char_u *
41554155
get_locale_val(int what)
41564156
{
4157-
char *loc;
4157+
char_u *loc;
41584158

41594159
/* Obtain the locale value from the libraries. For DJGPP this is
41604160
* redefined and it doesn't use the arguments. */
4161-
loc = setlocale(what, NULL);
4161+
loc = (char_u *)setlocale(what, NULL);
41624162

41634163
# ifdef WIN32
41644164
if (loc != NULL)
@@ -4222,7 +4222,7 @@ gettext_lang(char_u *name)
42224222

42234223
for (i = 0; mtable[i] != NULL; i += 2)
42244224
if (STRNICMP(mtable[i], name, STRLEN(mtable[i])) == 0)
4225-
return mtable[i + 1];
4225+
return (char_u *)mtable[i + 1];
42264226
return name;
42274227
}
42284228
#endif
@@ -4239,13 +4239,13 @@ get_mess_lang(void)
42394239

42404240
# ifdef HAVE_GET_LOCALE_VAL
42414241
# if defined(LC_MESSAGES)
4242-
p = (char_u *)get_locale_val(LC_MESSAGES);
4242+
p = get_locale_val(LC_MESSAGES);
42434243
# else
42444244
/* This is necessary for Win32, where LC_MESSAGES is not defined and $LANG
42454245
* may be set to the LCID number. LC_COLLATE is the best guess, LC_TIME
42464246
* and LC_MONETARY may be set differently for a Japanese working in the
42474247
* US. */
4248-
p = (char_u *)get_locale_val(LC_COLLATE);
4248+
p = get_locale_val(LC_COLLATE);
42494249
# endif
42504250
# else
42514251
p = mch_getenv((char_u *)"LC_ALL");
@@ -4290,7 +4290,7 @@ get_mess_env(void)
42904290
p = NULL; /* ignore something like "1043" */
42914291
# ifdef HAVE_GET_LOCALE_VAL
42924292
if (p == NULL || *p == NUL)
4293-
p = (char_u *)get_locale_val(LC_CTYPE);
4293+
p = get_locale_val(LC_CTYPE);
42944294
# endif
42954295
}
42964296
}
@@ -4310,7 +4310,7 @@ set_lang_var(void)
43104310
char_u *loc;
43114311

43124312
# ifdef HAVE_GET_LOCALE_VAL
4313-
loc = (char_u *)get_locale_val(LC_CTYPE);
4313+
loc = get_locale_val(LC_CTYPE);
43144314
# else
43154315
/* setlocale() not supported: use the default value */
43164316
loc = (char_u *)"C";
@@ -4320,14 +4320,14 @@ set_lang_var(void)
43204320
/* When LC_MESSAGES isn't defined use the value from $LC_MESSAGES, fall
43214321
* back to LC_CTYPE if it's empty. */
43224322
# if defined(HAVE_GET_LOCALE_VAL) && defined(LC_MESSAGES)
4323-
loc = (char_u *)get_locale_val(LC_MESSAGES);
4323+
loc = get_locale_val(LC_MESSAGES);
43244324
# else
43254325
loc = get_mess_env();
43264326
# endif
43274327
set_vim_var_string(VV_LANG, loc, -1);
43284328

43294329
# ifdef HAVE_GET_LOCALE_VAL
4330-
loc = (char_u *)get_locale_val(LC_TIME);
4330+
loc = get_locale_val(LC_TIME);
43314331
# endif
43324332
set_vim_var_string(VV_LC_TIME, loc, -1);
43334333
}

src/ex_getln.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,8 @@ getcmdline(
626626
#endif
627627
if (vim_ispathsep(ccline.cmdbuff[j])
628628
#ifdef BACKSLASH_IN_FILENAME
629-
&& vim_strchr(" *?[{`$%#", ccline.cmdbuff[j + 1])
630-
== NULL
629+
&& vim_strchr((char_u *)" *?[{`$%#",
630+
ccline.cmdbuff[j + 1]) == NULL
631631
#endif
632632
)
633633
{

src/fileio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7480,11 +7480,11 @@ vim_tempname(
74807480
}
74817481
strcpy(buf4, "VIM");
74827482
buf4[2] = extra_char; /* make it "VIa", "VIb", etc. */
7483-
if (GetTempFileName(szTempFile, buf4, 0, itmp) == 0)
7483+
if (GetTempFileName(szTempFile, buf4, 0, (LPSTR)itmp) == 0)
74847484
return NULL;
74857485
if (!keep)
74867486
/* GetTempFileName() will create the file, we don't want that */
7487-
(void)DeleteFile(itmp);
7487+
(void)DeleteFile((LPSTR)itmp);
74887488

74897489
/* Backslashes in a temp file name cause problems when filtering with
74907490
* "sh". NOTE: This also checks 'shellcmdflag' to help those people who

src/if_cscope.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ cs_create_connection(int i)
839839
# ifdef __BORLANDC__
840840
# define OPEN_OH_ARGTYPE long
841841
# else
842-
# if (_MSC_VER >= 1300)
842+
# if (_MSC_VER >= 1300) || defined(__MINGW32__)
843843
# define OPEN_OH_ARGTYPE intptr_t
844844
# else
845845
# define OPEN_OH_ARGTYPE long
@@ -1423,7 +1423,7 @@ cs_insert_filelist(
14231423
/* On windows 9x GetFileInformationByHandle doesn't work, so skip it */
14241424
if (!mch_windows95())
14251425
{
1426-
switch (win32_fileinfo(fname, &bhfi))
1426+
switch (win32_fileinfo((char_u *)fname, &bhfi))
14271427
{
14281428
case FILEINFO_ENC_FAIL: /* enc_to_utf16() failed */
14291429
case FILEINFO_READ_FAIL: /* CreateFile() failed */
@@ -1459,7 +1459,8 @@ cs_insert_filelist(
14591459
&& csinfo[j].st_dev == sb->st_dev && csinfo[j].st_ino == sb->st_ino
14601460
#else
14611461
/* compare pathnames first */
1462-
&& ((fullpathcmp(csinfo[j].fname, fname, FALSE) & FPC_SAME)
1462+
&& ((fullpathcmp((char_u *)csinfo[j].fname,
1463+
(char_u *)fname, FALSE) & FPC_SAME)
14631464
/* if not Windows 9x, test index file attributes too */
14641465
|| (!mch_windows95()
14651466
&& csinfo[j].nVolume == bhfi.dwVolumeSerialNumber

src/if_perl.xs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949
# define __inline__ __inline
5050
#endif
5151

52+
#ifdef __GNUC__
53+
# pragma GCC diagnostic push
54+
# pragma GCC diagnostic ignored "-Wunused-variable"
55+
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
56+
#endif
57+
5258
#include <EXTERN.h>
5359
#include <perl.h>
5460
#include <XSUB.h>
@@ -1730,3 +1736,6 @@ Append(vimbuf, ...)
17301736
}
17311737
}
17321738

1739+
#ifdef __GNUC__
1740+
# pragma GCC diagnostic pop
1741+
#endif

src/if_python.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@
4343
# undef _DEBUG
4444
#endif
4545

46+
#ifdef HAVE_STRFTIME
47+
# undef HAVE_STRFTIME
48+
#endif
49+
#ifdef HAVE_STRING_H
50+
# undef HAVE_STRING_H
51+
#endif
52+
#ifdef HAVE_PUTENV
53+
# undef HAVE_PUTENV
54+
#endif
4655
#ifdef HAVE_STDARG_H
4756
# undef HAVE_STDARG_H /* Python's config.h defines it as well. */
4857
#endif

src/if_python3.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@
5151
# undef F_BLANK
5252
#endif
5353

54+
#ifdef HAVE_STRFTIME
55+
# undef HAVE_STRFTIME
56+
#endif
57+
#ifdef HAVE_STRING_H
58+
# undef HAVE_STRING_H
59+
#endif
60+
#ifdef HAVE_PUTENV
61+
# undef HAVE_PUTENV
62+
#endif
5463
#ifdef HAVE_STDARG_H
5564
# undef HAVE_STDARG_H /* Python's config.h defines it as well. */
5665
#endif

0 commit comments

Comments
 (0)