From 9213b22726eeed2117a341ff34d7f0eadeb734c3 Mon Sep 17 00:00:00 2001 From: sisyphus Date: Tue, 13 Feb 2024 07:51:45 +1100 Subject: [PATCH] Silence compilation warnings (PR 21925). --- win32/win32.c | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/win32/win32.c b/win32/win32.c index 2e62bc04482b..ba694a86d408 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -132,7 +132,9 @@ static int terminate_process(DWORD pid, HANDLE process_handle, int sig); static int my_killpg(int pid, int sig); static int my_kill(int pid, int sig); static void out_of_memory(const char *context, STRLEN len); +#ifdef _DEBUG static char* wstr_to_str(const wchar_t* wstr); +#endif static long filetime_to_clock(PFILETIME ft); static BOOL filetime_from_time(PFILETIME ft, time_t t); static char* create_command_line(char *cname, STRLEN clen, @@ -1199,6 +1201,9 @@ int chown(const char *path, uid_t owner, gid_t group) { /* XXX noop */ + PERL_UNUSED_ARG(path); + PERL_UNUSED_ARG(owner); + PERL_UNUSED_ARG(group); return 0; } @@ -1455,7 +1460,7 @@ win32_kill(int pid, int sig) /* kill -9 style un-graceful exit */ /* Do a wait to make sure child starts and isn't in DLL * Loader Lock */ - HWND hwnd = get_hwnd_delay(aTHX, child, 5); + (void)get_hwnd_delay(aTHX, child, 5); if (TerminateThread(hProcess, sig)) { /* Allow the scheduler to finish cleaning up the other * thread. @@ -1856,7 +1861,6 @@ DllExport int win32_stat(const char *path, Stat_t *sbuf) { dTHX; - BOOL expect_dir = FALSE; int result; HANDLE handle; DWORD reparse_type = 0; @@ -1937,8 +1941,6 @@ translate_to_errno(void) static BOOL is_symlink(HANDLE h) { MY_REPARSE_DATA_BUFFER linkdata; - const MY_SYMLINK_REPARSE_BUFFER * const sd = - &linkdata.Data.SymbolicLinkReparseBuffer; DWORD linkdata_returned; 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) Perl_croak_nocontext("%s not implemented!\n", fname); } +#ifdef _DEBUG /* Converts a wide character (UTF-16) string to the Windows ANSI code page, * potentially using the system's default replacement character for any * unrepresentable characters. The caller must free() the returned string. */ @@ -2260,6 +2263,7 @@ wstr_to_str(const wchar_t* wstr) str, len, NULL, &used_default); return str; } +#endif /* The win32_ansipath() function takes a Unicode filename and converts it * into the current Windows codepage. If some characters cannot be mapped, @@ -2604,6 +2608,7 @@ DllExport int win32_gettimeofday(struct timeval *tp, void *not_used) { FT_t ft; + PERL_UNUSED_ARG(not_used); /* this returns time in 100-nanosecond units (i.e. tens of usecs) */ GetSystemTimeAsFileTime(&ft.ft_val); @@ -3543,25 +3548,18 @@ do_popen(const char *mode, const char *command, IV narg, SV **args) { int p[2]; int handles[3]; int parent, child; - int stdfd; int ourmode; int childpid; - DWORD nhandle; - int lock_held = 0; const char **args_pvs = NULL; /* establish which ends read and write */ if (strchr(mode,'w')) { - stdfd = 0; /* stdin */ parent = 1; child = 0; - nhandle = STD_INPUT_HANDLE; } else if (strchr(mode,'r')) { - stdfd = 1; /* stdout */ parent = 0; child = 1; - nhandle = STD_OUTPUT_HANDLE; } else return NULL; @@ -3805,7 +3803,6 @@ win32_symlink(const char *oldfile, const char *newfile) /* dest_path = oldfile; already done */ } else if (oldfile[0] != '\\') { - size_t newfile_len = strlen(newfile); const char *last_slash = strrchr(newfile, '/'); const char *last_bslash = strrchr(newfile, '\\'); const char *end_dir = last_slash && last_bslash @@ -3910,10 +3907,11 @@ win32_chsize(int fd, Off_t size) /* must grow the file, padding with nulls */ char b[4096]; int oldmode = win32_setmode(fd, O_BINARY); - size_t count; + Off_t count; memset(b, '\0', sizeof(b)); do { - count = extend >= sizeof(b) ? sizeof(b) : (size_t)extend; + /* Casts to 'Off_t' avoid '[-Wsign-compare]' warning */ + count = extend >= (Off_t)sizeof(b) ? (Off_t)sizeof(b) : extend; count = win32_write(fd, b, count); if ((int)count < 0) { retval = -1; @@ -4143,6 +4141,7 @@ DllExport int win32_mkdir(const char *dir, int mode) { dTHX; + PERL_UNUSED_ARG(mode); return mkdir(PerlDir_mapA(dir)); /* just ignore mode */ } @@ -4182,7 +4181,7 @@ static char * create_command_line(char *cname, STRLEN clen, const char * const *args) { PERL_DEB(dTHX;) - int index, argc; + int index; char *cmd, *ptr; const char *arg; STRLEN len = 0; @@ -4252,7 +4251,6 @@ create_command_line(char *cname, STRLEN clen, const char * const *args) } DEBUG_p(PerlIO_printf(Perl_debug_log, "\n")); - argc = index; Newx(cmd, len, char); ptr = cmd; @@ -4449,6 +4447,7 @@ win32_get_childenv(void) DllExport void win32_free_childenv(void* d) { + PERL_UNUSED_ARG(d); } DllExport void @@ -4744,7 +4743,9 @@ win32_fgets(char *s, int n, FILE *pf) DllExport char* win32_gets(char *s) { + GCC_DIAG_IGNORE_STMT(-Wattribute-warning); /* gets() only for compat */ return gets(s); + GCC_DIAG_RESTORE_STMT; } DllExport int @@ -5006,6 +5007,7 @@ XS(w32_SetChildShowWindow) XS(w32_GetCwd) { dXSARGS; + PERL_UNUSED_VAR(items); /* Make the host for current directory */ char* ptr = PerlEnv_get_childdir(); /* @@ -5258,7 +5260,7 @@ win32_hook_imported_function_in_module( = (PIMAGE_THUNK_DATA)(image_base + idt->FirstThunk); ULONG_PTR address_of_data; - for (; address_of_data = ilt->u1.AddressOfData; ++ilt, ++iat) { + for (; (address_of_data = ilt->u1.AddressOfData); ++ilt, ++iat) { /* Ordinal imports are quite rare, so skipping them will most likely * not cause any problems. */ BOOL is_ordinal @@ -5346,12 +5348,12 @@ my_CloseHandle(HANDLE h) } } - if (maybe_socket) + if (maybe_socket) { if (closesocket((SOCKET)h) == 0) return TRUE; else if (WSAGetLastError() != WSAENOTSOCK) return FALSE; - + } return CloseHandle_orig(h); } @@ -5414,6 +5416,8 @@ win32_unhook_closehandle_in_crt() void Perl_win32_init(int *argcp, char ***argvp) { + PERL_UNUSED_ARG(argcp); + PERL_UNUSED_ARG(argvp); #ifdef SET_INVALID_PARAMETER_HANDLER _invalid_parameter_handler oldHandler, newHandler; newHandler = my_invalid_parameter_handler; @@ -5563,7 +5567,8 @@ win32_process_message(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) * complexity of getting the correct context passed into * win32_create_message_window() */ dTHX; - + PERL_UNUSED_ARG(hwnd); + PERL_UNUSED_ARG(lParam); switch(msg) { #ifdef USE_ITHREADS @@ -5649,6 +5654,7 @@ win32_csighandler(int sig) dTHXa(PERL_GET_SIG_CONTEXT); Perl_warn(aTHX_ "Got signal %d",sig); #endif + PERL_UNUSED_ARG(sig); /* Does nothing */ }