Skip to content

Commit 35d7a2f

Browse files
committed
patch 8.2.5073: clang on MS-Windows produces warnings
Problem: Clang on MS-Windows produces warnings. Solution: Avoid the warnings. (Yegappan Lakshmanan, closes #10546)
1 parent 63f3260 commit 35d7a2f

12 files changed

Lines changed: 137 additions & 105 deletions

File tree

src/dosinst.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ static int num_windows;
439439
*/
440440
//ARGSUSED
441441
static BOOL CALLBACK
442-
window_cb(HWND hwnd, LPARAM lparam)
442+
window_cb(HWND hwnd, LPARAM lparam UNUSED)
443443
{
444444
char title[256];
445445

@@ -1170,7 +1170,7 @@ init_bat_choices(void)
11701170
* Install the vimrc file.
11711171
*/
11721172
static void
1173-
install_vimrc(int idx)
1173+
install_vimrc(int idx UNUSED)
11741174
{
11751175
FILE *fd, *tfd;
11761176
char *fname;
@@ -1891,7 +1891,7 @@ build_shortcut(
18911891
* Create shortcut(s) in the Start Menu\Programs\Vim folder.
18921892
*/
18931893
static void
1894-
install_start_menu(int idx)
1894+
install_start_menu(int idx UNUSED)
18951895
{
18961896
need_uninstall_entry = 1;
18971897
printf("Creating start menu\n");

src/dosinst.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ char *searchpath(char *name);
7373
# define KEY_WOW64_32KEY 0x0200
7474
# endif
7575

76+
#ifdef __MINGW32__
77+
# define UNUSED __attribute__((unused))
78+
#else
79+
# define UNUSED
80+
#endif
81+
7682
#define VIM_STARTMENU "Programs\\Vim " VIM_VERSION_SHORT
7783

7884
int interactive; // non-zero when running interactively
@@ -450,7 +456,7 @@ mch_chdir(char *path)
450456
* Expand the executable name into a full path name.
451457
*/
452458
static char *
453-
my_fullpath(char *buf, char *fname, int len)
459+
my_fullpath(char *buf, char *fname UNUSED, int len)
454460
{
455461
// Only GetModuleFileName() will get the long file name path.
456462
// GetFullPathName() may still use the short (FAT) name.

src/gui_dwrite.cpp

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@
5252
# define __out SAL__out
5353
#endif
5454

55+
#ifdef __MINGW32__
56+
# define UNUSED __attribute__((unused))
57+
#else
58+
# define UNUSED
59+
#endif
60+
5561
#if (defined(_MSC_VER) && (_MSC_VER >= 1700)) || (__cplusplus >= 201103L)
5662
# define FINAL final
5763
#else
@@ -419,15 +425,15 @@ class TextRenderer FINAL : public IDWriteTextRenderer
419425
}
420426

421427
IFACEMETHOD(IsPixelSnappingDisabled)(
422-
__maybenull void* clientDrawingContext,
428+
__maybenull void* clientDrawingContext UNUSED,
423429
__out BOOL* isDisabled)
424430
{
425431
*isDisabled = FALSE;
426432
return S_OK;
427433
}
428434

429435
IFACEMETHOD(GetCurrentTransform)(
430-
__maybenull void* clientDrawingContext,
436+
__maybenull void* clientDrawingContext UNUSED,
431437
__out DWRITE_MATRIX* transform)
432438
{
433439
// forward the render target's transform
@@ -437,7 +443,7 @@ class TextRenderer FINAL : public IDWriteTextRenderer
437443
}
438444

439445
IFACEMETHOD(GetPixelsPerDip)(
440-
__maybenull void* clientDrawingContext,
446+
__maybenull void* clientDrawingContext UNUSED,
441447
__out FLOAT* pixelsPerDip)
442448
{
443449
float dpiX, unused;
@@ -447,33 +453,33 @@ class TextRenderer FINAL : public IDWriteTextRenderer
447453
}
448454

449455
IFACEMETHOD(DrawUnderline)(
450-
__maybenull void* clientDrawingContext,
451-
FLOAT baselineOriginX,
452-
FLOAT baselineOriginY,
453-
__in DWRITE_UNDERLINE const* underline,
454-
IUnknown* clientDrawingEffect)
456+
__maybenull void* clientDrawingContext UNUSED,
457+
FLOAT baselineOriginX UNUSED,
458+
FLOAT baselineOriginY UNUSED,
459+
__in DWRITE_UNDERLINE const* underline UNUSED,
460+
IUnknown* clientDrawingEffect UNUSED)
455461
{
456462
return E_NOTIMPL;
457463
}
458464

459465
IFACEMETHOD(DrawStrikethrough)(
460-
__maybenull void* clientDrawingContext,
461-
FLOAT baselineOriginX,
462-
FLOAT baselineOriginY,
463-
__in DWRITE_STRIKETHROUGH const* strikethrough,
464-
IUnknown* clientDrawingEffect)
466+
__maybenull void* clientDrawingContext UNUSED,
467+
FLOAT baselineOriginX UNUSED,
468+
FLOAT baselineOriginY UNUSED,
469+
__in DWRITE_STRIKETHROUGH const* strikethrough UNUSED,
470+
IUnknown* clientDrawingEffect UNUSED)
465471
{
466472
return E_NOTIMPL;
467473
}
468474

469475
IFACEMETHOD(DrawInlineObject)(
470-
__maybenull void* clientDrawingContext,
471-
FLOAT originX,
472-
FLOAT originY,
473-
IDWriteInlineObject* inlineObject,
474-
BOOL isSideways,
475-
BOOL isRightToLeft,
476-
IUnknown* clientDrawingEffect)
476+
__maybenull void* clientDrawingContext UNUSED,
477+
FLOAT originX UNUSED,
478+
FLOAT originY UNUSED,
479+
IDWriteInlineObject* inlineObject UNUSED,
480+
BOOL isSideways UNUSED,
481+
BOOL isRightToLeft UNUSED,
482+
IUnknown* clientDrawingEffect UNUSED)
477483
{
478484
return E_NOTIMPL;
479485
}
@@ -482,10 +488,10 @@ class TextRenderer FINAL : public IDWriteTextRenderer
482488
__maybenull void* clientDrawingContext,
483489
FLOAT baselineOriginX,
484490
FLOAT baselineOriginY,
485-
DWRITE_MEASURING_MODE measuringMode,
491+
DWRITE_MEASURING_MODE measuringMode UNUSED,
486492
__in DWRITE_GLYPH_RUN const* glyphRun,
487-
__in DWRITE_GLYPH_RUN_DESCRIPTION const* glyphRunDescription,
488-
IUnknown* clientDrawingEffect)
493+
__in DWRITE_GLYPH_RUN_DESCRIPTION const* glyphRunDescription UNUSED,
494+
IUnknown* clientDrawingEffect UNUSED)
489495
{
490496
TextRendererContext *context =
491497
reinterpret_cast<TextRendererContext*>(clientDrawingContext);

src/gui_w32.c

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ stubGetDpiForSystem(void)
392392
}
393393

394394
static int WINAPI
395-
stubGetSystemMetricsForDpi(int nIndex, UINT dpi)
395+
stubGetSystemMetricsForDpi(int nIndex, UINT dpi UNUSED)
396396
{
397397
return GetSystemMetrics(nIndex);
398398
}
@@ -4149,7 +4149,7 @@ init_mouse_wheel(void)
41494149
* Mouse scroll event handler.
41504150
*/
41514151
static void
4152-
_OnMouseWheel(HWND hwnd, WPARAM wParam, LPARAM lParam, int horizontal)
4152+
_OnMouseWheel(HWND hwnd UNUSED, WPARAM wParam, LPARAM lParam, int horizontal)
41534153
{
41544154
int button;
41554155
win_T *wp;
@@ -4336,9 +4336,10 @@ static HWND hwndTip = NULL;
43364336
static void
43374337
show_sizing_tip(int cols, int rows)
43384338
{
4339-
TOOLINFOA ti = {sizeof(ti)};
4339+
TOOLINFOA ti;
43404340
char buf[32];
43414341

4342+
ti.cbSize = sizeof(ti);
43424343
ti.hwnd = s_hwnd;
43434344
ti.uId = (UINT_PTR)s_hwnd;
43444345
ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
@@ -4636,7 +4637,7 @@ _OnMenuSelect(HWND hwnd, WPARAM wParam, LPARAM lParam)
46364637
#endif
46374638

46384639
static LRESULT
4639-
_OnDpiChanged(HWND hwnd, UINT xdpi, UINT ydpi, RECT *rc)
4640+
_OnDpiChanged(HWND hwnd, UINT xdpi UNUSED, UINT ydpi, RECT *rc UNUSED)
46404641
{
46414642
s_dpi = ydpi;
46424643
s_in_dpichanged = TRUE;
@@ -5106,12 +5107,12 @@ load_dpi_func(void)
51065107
if (hUser32 == NULL)
51075108
goto fail;
51085109

5109-
pGetDpiForSystem = (void*)GetProcAddress(hUser32, "GetDpiForSystem");
5110-
pGetDpiForWindow = (void*)GetProcAddress(hUser32, "GetDpiForWindow");
5111-
pGetSystemMetricsForDpi = (void*)GetProcAddress(hUser32, "GetSystemMetricsForDpi");
5110+
pGetDpiForSystem = (UINT (WINAPI *)(void))GetProcAddress(hUser32, "GetDpiForSystem");
5111+
pGetDpiForWindow = (UINT (WINAPI *)(HWND))GetProcAddress(hUser32, "GetDpiForWindow");
5112+
pGetSystemMetricsForDpi = (int (WINAPI *)(int, UINT))GetProcAddress(hUser32, "GetSystemMetricsForDpi");
51125113
//pGetWindowDpiAwarenessContext = (void*)GetProcAddress(hUser32, "GetWindowDpiAwarenessContext");
5113-
pSetThreadDpiAwarenessContext = (void*)GetProcAddress(hUser32, "SetThreadDpiAwarenessContext");
5114-
pGetAwarenessFromDpiAwarenessContext = (void*)GetProcAddress(hUser32, "GetAwarenessFromDpiAwarenessContext");
5114+
pSetThreadDpiAwarenessContext = (DPI_AWARENESS_CONTEXT (WINAPI *)(DPI_AWARENESS_CONTEXT))GetProcAddress(hUser32, "SetThreadDpiAwarenessContext");
5115+
pGetAwarenessFromDpiAwarenessContext = (DPI_AWARENESS (WINAPI *)(DPI_AWARENESS_CONTEXT))GetProcAddress(hUser32, "GetAwarenessFromDpiAwarenessContext");
51155116

51165117
if (pSetThreadDpiAwarenessContext != NULL)
51175118
{
@@ -7799,8 +7800,9 @@ initialise_toolbar(void)
77997800
update_toolbar_size(void)
78007801
{
78017802
int w, h;
7802-
TBMETRICS tbm = {sizeof(TBMETRICS)};
7803+
TBMETRICS tbm;
78037804

7805+
tbm.cbSize = sizeof(TBMETRICS);
78047806
tbm.dwMask = TBMF_PAD | TBMF_BUTTONSPACING;
78057807
SendMessage(s_toolbarhwnd, TB_GETMETRICS, 0, (LPARAM)&tbm);
78067808
//TRACE("Pad: %d, %d", tbm.cxPad, tbm.cyPad);
@@ -8043,27 +8045,27 @@ dyn_imm_load(void)
80438045
return;
80448046

80458047
pImmGetCompositionStringW
8046-
= (void *)GetProcAddress(hLibImm, "ImmGetCompositionStringW");
8048+
= (LONG (WINAPI *)(HIMC, DWORD, LPVOID, DWORD))GetProcAddress(hLibImm, "ImmGetCompositionStringW");
80478049
pImmGetContext
8048-
= (void *)GetProcAddress(hLibImm, "ImmGetContext");
8050+
= (HIMC (WINAPI *)(HWND))GetProcAddress(hLibImm, "ImmGetContext");
80498051
pImmAssociateContext
8050-
= (void *)GetProcAddress(hLibImm, "ImmAssociateContext");
8052+
= (HIMC (WINAPI *)(HWND, HIMC))GetProcAddress(hLibImm, "ImmAssociateContext");
80518053
pImmReleaseContext
8052-
= (void *)GetProcAddress(hLibImm, "ImmReleaseContext");
8054+
= (BOOL (WINAPI *)(HWND, HIMC))GetProcAddress(hLibImm, "ImmReleaseContext");
80538055
pImmGetOpenStatus
8054-
= (void *)GetProcAddress(hLibImm, "ImmGetOpenStatus");
8056+
= (BOOL (WINAPI *)(HIMC))GetProcAddress(hLibImm, "ImmGetOpenStatus");
80558057
pImmSetOpenStatus
8056-
= (void *)GetProcAddress(hLibImm, "ImmSetOpenStatus");
8058+
= (BOOL (WINAPI *)(HIMC, BOOL))GetProcAddress(hLibImm, "ImmSetOpenStatus");
80578059
pImmGetCompositionFontW
8058-
= (void *)GetProcAddress(hLibImm, "ImmGetCompositionFontW");
8060+
= (BOOL (WINAPI *)(HIMC, LPLOGFONTW))GetProcAddress(hLibImm, "ImmGetCompositionFontW");
80598061
pImmSetCompositionFontW
8060-
= (void *)GetProcAddress(hLibImm, "ImmSetCompositionFontW");
8062+
= (BOOL (WINAPI *)(HIMC, LPLOGFONTW))GetProcAddress(hLibImm, "ImmSetCompositionFontW");
80618063
pImmSetCompositionWindow
8062-
= (void *)GetProcAddress(hLibImm, "ImmSetCompositionWindow");
8064+
= (BOOL (WINAPI *)(HIMC, LPCOMPOSITIONFORM))GetProcAddress(hLibImm, "ImmSetCompositionWindow");
80638065
pImmGetConversionStatus
8064-
= (void *)GetProcAddress(hLibImm, "ImmGetConversionStatus");
8066+
= (BOOL (WINAPI *)(HIMC, LPDWORD, LPDWORD))GetProcAddress(hLibImm, "ImmGetConversionStatus");
80658067
pImmSetConversionStatus
8066-
= (void *)GetProcAddress(hLibImm, "ImmSetConversionStatus");
8068+
= (BOOL (WINAPI *)(HIMC, DWORD, DWORD))GetProcAddress(hLibImm, "ImmSetConversionStatus");
80678069

80688070
if ( pImmGetCompositionStringW == NULL
80698071
|| pImmGetContext == NULL

src/iscygpty.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@
5656
# endif
5757
#endif // USE_FILEEXTD
5858

59+
#ifdef __MINGW32__
60+
# define UNUSED __attribute__((unused))
61+
#else
62+
# define UNUSED
63+
#endif
5964

6065
#include "iscygpty.h"
6166

@@ -70,10 +75,10 @@ static pfnGetFileInformationByHandleEx pGetFileInformationByHandleEx = NULL;
7075

7176
# ifndef USE_FILEEXTD
7277
static BOOL WINAPI stub_GetFileInformationByHandleEx(
73-
HANDLE hFile,
74-
FILE_INFO_BY_HANDLE_CLASS FileInformationClass,
75-
LPVOID lpFileInformation,
76-
DWORD dwBufferSize)
78+
HANDLE hFile UNUSED,
79+
FILE_INFO_BY_HANDLE_CLASS FileInformationClass UNUSED,
80+
LPVOID lpFileInformation UNUSED,
81+
DWORD dwBufferSize UNUSED)
7782
{
7883
return FALSE;
7984
}

src/libvterm/src/vterm_internal.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77

88
#if defined(__GNUC__) && !defined(__MINGW32__)
99
# define INTERNAL __attribute__((visibility("internal")))
10-
# define UNUSED __attribute__((unused))
1110
#else
1211
# define INTERNAL
12+
#endif
13+
14+
#if defined(__GNUC__) || defined(__MINGW32__)
15+
# define UNUSED __attribute__((unused))
16+
#else
1317
# define UNUSED
1418
#endif
1519

src/mbyte.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4922,13 +4922,18 @@ iconv_enabled(int verbose)
49224922
return FALSE;
49234923
}
49244924

4925-
iconv = (void *)GetProcAddress(hIconvDLL, "libiconv");
4926-
iconv_open = (void *)GetProcAddress(hIconvDLL, "libiconv_open");
4927-
iconv_close = (void *)GetProcAddress(hIconvDLL, "libiconv_close");
4928-
iconvctl = (void *)GetProcAddress(hIconvDLL, "libiconvctl");
4929-
iconv_errno = get_dll_import_func(hIconvDLL, "_errno");
4925+
iconv = (size_t (*)(iconv_t, const char **,
4926+
size_t *, char **, size_t *))
4927+
GetProcAddress(hIconvDLL, "libiconv");
4928+
iconv_open = (iconv_t (*)(const char *, const char *))
4929+
GetProcAddress(hIconvDLL, "libiconv_open");
4930+
iconv_close = (int (*)(iconv_t))
4931+
GetProcAddress(hIconvDLL, "libiconv_close");
4932+
iconvctl = (int (*)(iconv_t, int, void *))
4933+
GetProcAddress(hIconvDLL, "libiconvctl");
4934+
iconv_errno = (int *(*)(void))get_dll_import_func(hIconvDLL, "_errno");
49304935
if (iconv_errno == NULL)
4931-
iconv_errno = (void *)GetProcAddress(hMsvcrtDLL, "_errno");
4936+
iconv_errno = (int *(*)(void))GetProcAddress(hMsvcrtDLL, "_errno");
49324937
if (iconv == NULL || iconv_open == NULL || iconv_close == NULL
49334938
|| iconvctl == NULL || iconv_errno == NULL)
49344939
{

0 commit comments

Comments
 (0)