Skip to content

Commit 331d832

Browse files
committed
Silence compilation warnings (PR 21925).
1 parent b7ed279 commit 331d832

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

win32/win32.c

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ static int terminate_process(DWORD pid, HANDLE process_handle, int sig);
132132
static int my_killpg(int pid, int sig);
133133
static int my_kill(int pid, int sig);
134134
static void out_of_memory(const char *context, STRLEN len);
135+
#ifdef _DEBUG
135136
static char* wstr_to_str(const wchar_t* wstr);
137+
#endif
136138
static long filetime_to_clock(PFILETIME ft);
137139
static BOOL filetime_from_time(PFILETIME ft, time_t t);
138140
static char* create_command_line(char *cname, STRLEN clen,
@@ -1199,6 +1201,9 @@ int
11991201
chown(const char *path, uid_t owner, gid_t group)
12001202
{
12011203
/* XXX noop */
1204+
PERL_UNUSED_ARG(path);
1205+
PERL_UNUSED_ARG(owner);
1206+
PERL_UNUSED_ARG(group);
12021207
return 0;
12031208
}
12041209

@@ -1455,7 +1460,7 @@ win32_kill(int pid, int sig)
14551460
/* kill -9 style un-graceful exit */
14561461
/* Do a wait to make sure child starts and isn't in DLL
14571462
* Loader Lock */
1458-
HWND hwnd = get_hwnd_delay(aTHX, child, 5);
1463+
(void)get_hwnd_delay(aTHX, child, 5);
14591464
if (TerminateThread(hProcess, sig)) {
14601465
/* Allow the scheduler to finish cleaning up the other
14611466
* thread.
@@ -1856,7 +1861,6 @@ DllExport int
18561861
win32_stat(const char *path, Stat_t *sbuf)
18571862
{
18581863
dTHX;
1859-
BOOL expect_dir = FALSE;
18601864
int result;
18611865
HANDLE handle;
18621866
DWORD reparse_type = 0;
@@ -1937,8 +1941,6 @@ translate_to_errno(void)
19371941
static BOOL
19381942
is_symlink(HANDLE h) {
19391943
MY_REPARSE_DATA_BUFFER linkdata;
1940-
const MY_SYMLINK_REPARSE_BUFFER * const sd =
1941-
&linkdata.Data.SymbolicLinkReparseBuffer;
19421944
DWORD linkdata_returned;
19431945

19441946
if (!DeviceIoControl(h, FSCTL_GET_REPARSE_POINT, NULL, 0, &linkdata, sizeof(linkdata), &linkdata_returned, NULL)) {
@@ -2243,6 +2245,7 @@ win32_croak_not_implemented(const char * fname)
22432245
Perl_croak_nocontext("%s not implemented!\n", fname);
22442246
}
22452247

2248+
#ifdef _DEBUG
22462249
/* Converts a wide character (UTF-16) string to the Windows ANSI code page,
22472250
* potentially using the system's default replacement character for any
22482251
* unrepresentable characters. The caller must free() the returned string. */
@@ -2260,6 +2263,7 @@ wstr_to_str(const wchar_t* wstr)
22602263
str, len, NULL, &used_default);
22612264
return str;
22622265
}
2266+
#endif
22632267

22642268
/* The win32_ansipath() function takes a Unicode filename and converts it
22652269
* into the current Windows codepage. If some characters cannot be mapped,
@@ -2604,6 +2608,7 @@ DllExport int
26042608
win32_gettimeofday(struct timeval *tp, void *not_used)
26052609
{
26062610
FT_t ft;
2611+
PERL_UNUSED_ARG(not_used);
26072612

26082613
/* this returns time in 100-nanosecond units (i.e. tens of usecs) */
26092614
GetSystemTimeAsFileTime(&ft.ft_val);
@@ -3543,25 +3548,18 @@ do_popen(const char *mode, const char *command, IV narg, SV **args) {
35433548
int p[2];
35443549
int handles[3];
35453550
int parent, child;
3546-
int stdfd;
35473551
int ourmode;
35483552
int childpid;
3549-
DWORD nhandle;
3550-
int lock_held = 0;
35513553
const char **args_pvs = NULL;
35523554

35533555
/* establish which ends read and write */
35543556
if (strchr(mode,'w')) {
3555-
stdfd = 0; /* stdin */
35563557
parent = 1;
35573558
child = 0;
3558-
nhandle = STD_INPUT_HANDLE;
35593559
}
35603560
else if (strchr(mode,'r')) {
3561-
stdfd = 1; /* stdout */
35623561
parent = 0;
35633562
child = 1;
3564-
nhandle = STD_OUTPUT_HANDLE;
35653563
}
35663564
else
35673565
return NULL;
@@ -3805,7 +3803,6 @@ win32_symlink(const char *oldfile, const char *newfile)
38053803
/* dest_path = oldfile; already done */
38063804
}
38073805
else if (oldfile[0] != '\\') {
3808-
size_t newfile_len = strlen(newfile);
38093806
const char *last_slash = strrchr(newfile, '/');
38103807
const char *last_bslash = strrchr(newfile, '\\');
38113808
const char *end_dir = last_slash && last_bslash
@@ -3910,10 +3907,11 @@ win32_chsize(int fd, Off_t size)
39103907
/* must grow the file, padding with nulls */
39113908
char b[4096];
39123909
int oldmode = win32_setmode(fd, O_BINARY);
3913-
size_t count;
3910+
Off_t count;
39143911
memset(b, '\0', sizeof(b));
39153912
do {
3916-
count = extend >= sizeof(b) ? sizeof(b) : (size_t)extend;
3913+
/* Casts to 'Off_t' avoid '[-Wsign-compare]' warning */
3914+
count = extend >= (Off_t)sizeof(b) ? (Off_t)sizeof(b) : extend;
39173915
count = win32_write(fd, b, count);
39183916
if ((int)count < 0) {
39193917
retval = -1;
@@ -4143,6 +4141,7 @@ DllExport int
41434141
win32_mkdir(const char *dir, int mode)
41444142
{
41454143
dTHX;
4144+
PERL_UNUSED_ARG(mode);
41464145
return mkdir(PerlDir_mapA(dir)); /* just ignore mode */
41474146
}
41484147

@@ -4182,7 +4181,7 @@ static char *
41824181
create_command_line(char *cname, STRLEN clen, const char * const *args)
41834182
{
41844183
PERL_DEB(dTHX;)
4185-
int index, argc;
4184+
int index;
41864185
char *cmd, *ptr;
41874186
const char *arg;
41884187
STRLEN len = 0;
@@ -4252,7 +4251,6 @@ create_command_line(char *cname, STRLEN clen, const char * const *args)
42524251
}
42534252
DEBUG_p(PerlIO_printf(Perl_debug_log, "\n"));
42544253

4255-
argc = index;
42564254
Newx(cmd, len, char);
42574255
ptr = cmd;
42584256

@@ -4449,6 +4447,7 @@ win32_get_childenv(void)
44494447
DllExport void
44504448
win32_free_childenv(void* d)
44514449
{
4450+
PERL_UNUSED_ARG(d);
44524451
}
44534452

44544453
DllExport void
@@ -4744,7 +4743,9 @@ win32_fgets(char *s, int n, FILE *pf)
47444743
DllExport char*
47454744
win32_gets(char *s)
47464745
{
4746+
GCC_DIAG_IGNORE_STMT(-Wattribute-warning); /* gets() only for compat */
47474747
return gets(s);
4748+
GCC_DIAG_RESTORE_STMT;
47484749
}
47494750

47504751
DllExport int
@@ -5006,6 +5007,7 @@ XS(w32_SetChildShowWindow)
50065007
XS(w32_GetCwd)
50075008
{
50085009
dXSARGS;
5010+
PERL_UNUSED_VAR(items);
50095011
/* Make the host for current directory */
50105012
char* ptr = PerlEnv_get_childdir();
50115013
/*
@@ -5258,7 +5260,7 @@ win32_hook_imported_function_in_module(
52585260
= (PIMAGE_THUNK_DATA)(image_base + idt->FirstThunk);
52595261

52605262
ULONG_PTR address_of_data;
5261-
for (; address_of_data = ilt->u1.AddressOfData; ++ilt, ++iat) {
5263+
for (; (address_of_data = ilt->u1.AddressOfData); ++ilt, ++iat) {
52625264
/* Ordinal imports are quite rare, so skipping them will most likely
52635265
* not cause any problems. */
52645266
BOOL is_ordinal
@@ -5346,12 +5348,12 @@ my_CloseHandle(HANDLE h)
53465348
}
53475349
}
53485350

5349-
if (maybe_socket)
5351+
if (maybe_socket) {
53505352
if (closesocket((SOCKET)h) == 0)
53515353
return TRUE;
53525354
else if (WSAGetLastError() != WSAENOTSOCK)
53535355
return FALSE;
5354-
5356+
}
53555357
return CloseHandle_orig(h);
53565358
}
53575359

@@ -5414,6 +5416,8 @@ win32_unhook_closehandle_in_crt()
54145416
void
54155417
Perl_win32_init(int *argcp, char ***argvp)
54165418
{
5419+
PERL_UNUSED_ARG(argcp);
5420+
PERL_UNUSED_ARG(argvp);
54175421
#ifdef SET_INVALID_PARAMETER_HANDLER
54185422
_invalid_parameter_handler oldHandler, newHandler;
54195423
newHandler = my_invalid_parameter_handler;
@@ -5563,7 +5567,8 @@ win32_process_message(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
55635567
* complexity of getting the correct context passed into
55645568
* win32_create_message_window() */
55655569
dTHX;
5566-
5570+
PERL_UNUSED_ARG(hwnd);
5571+
PERL_UNUSED_ARG(lParam);
55675572
switch(msg) {
55685573

55695574
#ifdef USE_ITHREADS
@@ -5649,6 +5654,7 @@ win32_csighandler(int sig)
56495654
dTHXa(PERL_GET_SIG_CONTEXT);
56505655
Perl_warn(aTHX_ "Got signal %d",sig);
56515656
#endif
5657+
PERL_UNUSED_ARG(sig);
56525658
/* Does nothing */
56535659
}
56545660

0 commit comments

Comments
 (0)