From b42341b132b303822e5c8673222853ff8db2ee9a Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sun, 2 Nov 2025 11:04:37 -0700 Subject: [PATCH 01/11] locale.c: Initialize variable to silence compiler The compiler used on MingW doesn't realize that there is no path that keeps this from being initialized --- locale.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/locale.c b/locale.c index 4992f5e937ad..5773f9ebd48c 100644 --- a/locale.c +++ b/locale.c @@ -1474,7 +1474,9 @@ S_parse_LC_ALL_string(pTHX_ const char * string, } } - const char * msg; + /* Some compilers don't realize all paths initialize this */ + const char * msg = NULL; + const char * display_start = s; const char * display_end = e; From d59731868a5963824fe3232f6eee1ef1ed951c67 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sun, 2 Nov 2025 11:07:36 -0700 Subject: [PATCH 02/11] Add a bunch of PERL_UNUSED_ARG calls These should silence warnings on MingW. --- mg.c | 1 + perl.c | 4 +++- pp_sys.c | 1 + util.c | 1 + win32/win32sck.c | 7 +++++++ 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mg.c b/mg.c index 4dad61f3e41c..08c8e23ebd32 100644 --- a/mg.c +++ b/mg.c @@ -3803,6 +3803,7 @@ Perl_perly_sighandler(int sig, Siginfo_t *sip PERL_UNUSED_DECL, /* Not clear if this will work */ /* XXX not clear if this should be protected by 'if (safe)' * too */ + PERL_UNUSED_ARG(safe); (void)rsignal(sig, SIG_IGN); (void)rsignal(sig, PL_csighandlerp); diff --git a/perl.c b/perl.c index 12117d04e5f1..1881ffc51739 100644 --- a/perl.c +++ b/perl.c @@ -4406,7 +4406,9 @@ S_init_ids(pTHX) bool Perl_doing_taint(int argc, char *argv[], char *envp[]) { -#ifndef PERL_IMPLICIT_SYS +#ifdef PERL_IMPLICIT_SYS + PERL_UNUSED_ARG(envp); +#else /* If we have PERL_IMPLICIT_SYS we can't call getuid() et alia * before we have an interpreter-- and the whole point of this * function is to be called at such an early stage. If you are on diff --git a/pp_sys.c b/pp_sys.c index 9a47afd82bc3..ed8fe9732458 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -5558,6 +5558,7 @@ PP_wrapped(pp_shostent, 1, 0) { dSP; const int stayopen = TOPi; + PERL_UNUSED_VAR(stayopen); switch(PL_op->op_type) { case OP_SHOSTENT: #ifdef HAS_SETHOSTENT diff --git a/util.c b/util.c index eddba602d12a..7d037f65ee11 100644 --- a/util.c +++ b/util.c @@ -2940,6 +2940,7 @@ Perl_rsignal(pTHX_ int signo, Sighandler_t handler) static Signal_t sig_trap(int signo) { + PERL_UNUSED_ARG(signo); PL_sig_trapped++; } diff --git a/win32/win32sck.c b/win32/win32sck.c index 7289a47d9b0b..6bfdee4f9e86 100644 --- a/win32/win32sck.c +++ b/win32/win32sck.c @@ -780,6 +780,7 @@ win32_getnetent(void) struct netent * win32_getnetbyname(char *name) { + PERL_UNUSED_ARG(name); win32_croak_not_implemented("getnetbyname"); return (struct netent *)NULL; } @@ -787,6 +788,8 @@ win32_getnetbyname(char *name) struct netent * win32_getnetbyaddr(long net, int type) { + PERL_UNUSED_ARG(net); + PERL_UNUSED_ARG(type); win32_croak_not_implemented("getnetbyaddr"); return (struct netent *)NULL; } @@ -808,6 +811,7 @@ win32_getservent(void) void win32_sethostent(int stayopen) { + PERL_UNUSED_ARG(stayopen); win32_croak_not_implemented("sethostent"); } @@ -815,6 +819,7 @@ win32_sethostent(int stayopen) void win32_setnetent(int stayopen) { + PERL_UNUSED_ARG(stayopen); win32_croak_not_implemented("setnetent"); } @@ -822,6 +827,7 @@ win32_setnetent(int stayopen) void win32_setprotoent(int stayopen) { + PERL_UNUSED_ARG(stayopen); win32_croak_not_implemented("setprotoent"); } @@ -829,6 +835,7 @@ win32_setprotoent(int stayopen) void win32_setservent(int stayopen) { + PERL_UNUSED_ARG(stayopen); win32_croak_not_implemented("setservent"); } From 523e40c29c135d962b6bd3a3bce418e931758ab0 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sun, 2 Nov 2025 11:09:25 -0700 Subject: [PATCH 03/11] win32.h: #undef a macro before redefining it This silences a compiler warning --- win32/win32.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/win32/win32.h b/win32/win32.h index 1b69d153c1f7..cd12a2fe3721 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -133,7 +133,8 @@ # define NOMEMMGR /* GUI IPC RPC malloc buffers */ # define NOMENUS /* GUI Menu obj */ # define NOMETAFILE /* file format for half rendered graphics */ -# define NOMINMAX /* "Macros min(a,b) and max(a,b)" OBSOL/UNIMPL/FUT */ +# undef NOMINMAX /* "Macros min(a,b) and max(a,b)" OBSOL/UNIMPL/FUT */ +# define NOMINMAX # define NOMSG /* GUI Message loop */ /* #define NONLS "Wide" Code Page conversion APIs */ /* OBSOL/UNIMPL/FUT "OpenFile(), OemToAnsi, AnsiToOem" etc */ From f1e29913ec8d26a93f1dc0d834c97d845caff84b Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sun, 2 Nov 2025 11:10:21 -0700 Subject: [PATCH 04/11] win32/vmem.h: Comment tag after #endif This should be in a comment even though the compilers on Windows tolerate it, but with a warning --- win32/vmem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win32/vmem.h b/win32/vmem.h index 3d5492958756..69abf08d4b13 100644 --- a/win32/vmem.h +++ b/win32/vmem.h @@ -210,7 +210,7 @@ VMem::VMem(void) { #ifdef _USE_LINKED_LIST InitializeCriticalSection(&m_cs); -#endif _USE_LINKED_LIST +#endif /* _USE_LINKED_LIST */ m_lRefCount = 1; return; } From 0d906e2010b07e07f2f7d840e076a7f0e0b38467 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sun, 2 Nov 2025 11:12:04 -0700 Subject: [PATCH 05/11] win32/vmem.h: White-space only Make this macro more legible, while silencing some compiler warnings about the if statements looking like they are intended to apply to more than they actually do. --- win32/vmem.h | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/win32/vmem.h b/win32/vmem.h index 69abf08d4b13..e59096d9bf21 100644 --- a/win32/vmem.h +++ b/win32/vmem.h @@ -61,28 +61,33 @@ inline void MEMODSlx(char *str, long x) Even though perl links with ucrtbase.dll, there is alot of overhead for using ::new() operator. Just implement our own ::new(), more C-style. */ #define VMEM_H_NEW_OP \ - void* operator new(size_t size) noexcept { \ - void * p = (void*)win32_malloc(size); \ - if(!p) noperl_die("%s%s","Out of memory in perl:", "???"); return p; }; \ - void* operator new[](size_t size) noexcept { \ - void * p = (void*)win32_malloc(size); \ - if(!p) noperl_die("%s%s","Out of memory in perl:", "???"); return p; }; \ - void* operator new( size_t size, int block_use, \ - char const* file_name, int line_number) noexcept { \ - UNREFERENCED_PARAMETER(block_use); \ - UNREFERENCED_PARAMETER(file_name); \ - UNREFERENCED_PARAMETER(line_number); \ - void * p = (void*)win32_malloc(size); \ - if(!p) noperl_die("%s%s","Out of memory in perl:", "???"); return p; \ - }; \ - void* operator new[]( size_t size, int block_use, \ - char const* file_name, int line_number) noexcept { \ - UNREFERENCED_PARAMETER(block_use); \ - UNREFERENCED_PARAMETER(file_name); \ - UNREFERENCED_PARAMETER(line_number); \ - void * p = (void*)win32_malloc(size); \ - if(!p) noperl_die("%s%s","Out of memory in perl:", "???"); return p; }; \ - void operator delete (void* p) noexcept { win32_free(p); return; }; \ + void* operator new(size_t size) noexcept { \ + void * p = (void*)win32_malloc(size); \ + if (!p) noperl_die("%s%s","Out of memory in perl:", "???"); \ + return p; \ + }; \ + void* operator new[](size_t size) noexcept { \ + void * p = (void*)win32_malloc(size); \ + if (!p) noperl_die("%s%s","Out of memory in perl:", "???"); \ + return p; }; \ + void* operator new( size_t size, int block_use, \ + char const* file_name, int line_number) noexcept {\ + UNREFERENCED_PARAMETER(block_use); \ + UNREFERENCED_PARAMETER(file_name); \ + UNREFERENCED_PARAMETER(line_number); \ + void * p = (void*)win32_malloc(size); \ + if(!p) noperl_die("%s%s","Out of memory in perl:", "???"); \ + return p; \ + }; \ + void* operator new[]( size_t size, int block_use, \ + char const* file_name, int line_number) noexcept {\ + UNREFERENCED_PARAMETER(block_use); \ + UNREFERENCED_PARAMETER(file_name); \ + UNREFERENCED_PARAMETER(line_number); \ + void * p = (void*)win32_malloc(size); \ + if(!p) noperl_die("%s%s","Out of memory in perl:", "???"); \ + return p; }; \ + void operator delete (void* p) noexcept { win32_free(p); return; }; \ void operator delete[] (void* p) noexcept { win32_free(p); return; } From be61a0d8cb281a181f8b6f4483fea160fca1d0fa Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sun, 2 Nov 2025 11:14:36 -0700 Subject: [PATCH 06/11] win32/fcrypt.c: Collapse some conditionals We have macros that including perl.h gets us access to, and do the same thing more quickly than this did. --- win32/fcrypt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/win32/fcrypt.c b/win32/fcrypt.c index f2836eddd250..88a23f341d11 100644 --- a/win32/fcrypt.c +++ b/win32/fcrypt.c @@ -2,6 +2,8 @@ /* Copyright (C) 1993 Eric Young - see README for more details */ #include #include +#include "EXTERN.h" +#include "perl.h" /* Eric Young. * This version of crypt has been developed from my MIT compatible @@ -466,12 +468,10 @@ unsigned const char cov_2char[64]={ }; /* the salt for classic DES crypt (which is all we implement here) - permits [./0-9A-Za-z], since '.' and '/' immediately precede - '0' we don't need individual checks for '.' and '/' + permits [./0-9A-Za-z], since '.' and '/' are adjacent, we don't need + individual checks for them */ -#define good_for_salt(c) \ - ((c) >= '.' && (c) <= '9' || (c) >= 'A' && (c) <= 'Z' || \ - (c) >= 'a' && (c) <= 'z') +#define good_for_salt(c) (isALPHANUMERIC(c) || inRANGE((c), '.', '/')) char * des_fcrypt(const char *buf, const char *salt, char *buff) From 8f4a5ab212541dcbaa75cf77f9644e5f79d332ec Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sun, 2 Nov 2025 11:17:24 -0700 Subject: [PATCH 07/11] pp_hot.c: Don't use signed char as an array index The MingW compiler spotted this. The code prior to these uses already has made sure these indices are positive, so casting to unsigned works. --- pp_hot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pp_hot.c b/pp_hot.c index e95553463f7d..73ea8e3129fe 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -359,7 +359,7 @@ PP(pp_aelemfastlex_store) /* inlined av_fetch() for simple cases ... */ if (!SvRMAGICAL(av) && key >=0 && key <= AvFILLp(av)) { - targ = AvARRAY(av)[key]; + targ = AvARRAY(av)[ (U8) key ]; } /* ... else do it the hard way */ if (!targ) { @@ -2033,7 +2033,7 @@ PP(pp_aelemfast) /* inlined av_fetch() for simple cases ... */ if (!SvRMAGICAL(av) && key >= 0 && key <= AvFILLp(av)) { - sv = AvARRAY(av)[key]; + sv = AvARRAY(av)[ (U8) key ]; if (sv) goto ret; if (!lval) { From 6c24ffa4f416bc85832ec7d6a8647e4736cac497 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sun, 2 Nov 2025 11:21:55 -0700 Subject: [PATCH 08/11] toke.c: Initialize variable to avoid compiler warning The MingW compiler thinks this can be used unininitalized, even though I don't think it can. Just initialize it to 0. --- toke.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toke.c b/toke.c index ece6bb56d5e5..af34fd672211 100644 --- a/toke.c +++ b/toke.c @@ -12458,7 +12458,7 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp) const char *lastub = NULL; /* position of last underbar */ static const char* const number_too_long = "Number too long"; bool warned_about_underscore = 0; - I32 shift; /* shift per digit for hex/oct/bin, hoisted here for fp */ + I32 shift = 0; /* shift per digit for hex/oct/bin, hoisted here for fp */ #define WARN_ABOUT_UNDERSCORE() \ do { \ if (!warned_about_underscore) { \ From 828f9252bfbb7637e3369c55c9d0ed25bfb8a825 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sun, 2 Nov 2025 11:23:14 -0700 Subject: [PATCH 09/11] pp_hot.c: Initialize variable to avoid compiler warning The MingW compiler thinks this can be used unininitalized. --- pp_hot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pp_hot.c b/pp_hot.c index 73ea8e3129fe..89e0c8cbf9e2 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -1590,7 +1590,7 @@ PP(pp_readline) SvGETMAGIC(arg); /* unrolled tryAMAGICunTARGETlist(iter_amg, 0) */ - SV *tmpsv; + SV *tmpsv = NULL; U8 gimme = GIMME_V; if (UNLIKELY(SvAMAGIC(arg) && (tmpsv = amagic_call(arg, &PL_sv_undef, iter_amg, From 7d90fb460bae4c476fb50f41f1c3e0c35b7cc913 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sun, 2 Nov 2025 11:24:22 -0700 Subject: [PATCH 10/11] pp_sys.c: Initialize variable to avoid compiler warning The MingW compiler thinks this can be used unininitalized --- pp_sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pp_sys.c b/pp_sys.c index ed8fe9732458..4e542c6c1ca7 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -392,7 +392,7 @@ PP(pp_glob) /* unrolled tryAMAGICunTARGETlist(iter_amg, (PL_op->op_flags & OPf_SPECIAL)); */ - SV *tmpsv; + SV *tmpsv = NULL; U8 gimme = GIMME_V; if (UNLIKELY(SvAMAGIC(arg) && (tmpsv = amagic_call(arg, &PL_sv_undef, iter_amg, From 6fb21d69a83e1c194e85e936ab62dea5c142a51d Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Tue, 4 Nov 2025 09:08:37 -0700 Subject: [PATCH 11/11] win32/perllib.c: Omit unused formal parameter name to silence a compiler warning --- win32/perllib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win32/perllib.c b/win32/perllib.c index efae2d817b8d..15cef6ebb731 100644 --- a/win32/perllib.c +++ b/win32/perllib.c @@ -261,7 +261,7 @@ EXTERN_C /* GCC in C++ mode mangles the name, otherwise */ BOOL APIENTRY DllMain(HINSTANCE hModule, /* DLL module handle */ DWORD fdwReason, /* reason called */ - LPVOID lpvReserved) /* reserved */ + LPVOID) /* reserved */ { switch (fdwReason) { /* The DLL is attaching to a process due to process