diff options
author | Steve Hay <steve.m.hay@googlemail.com> | 2012-09-11 08:36:03 +0100 |
---|---|---|
committer | Steve Hay <steve.m.hay@googlemail.com> | 2012-09-11 08:36:03 +0100 |
commit | d52ca5864fb3a97285307ef39f49ddb1555e62cc (patch) | |
tree | 6ffa072ef3ef464481c012b3f9cf58fda5f15dd9 /win32/win32.c | |
parent | 00a0ae2877906b27fbce91f4f1393386dc1b821e (diff) | |
download | perl-d52ca5864fb3a97285307ef39f49ddb1555e62cc.tar.gz |
Silence invalid parameter messages from win32_signal
This is the first step towards enabling the invalid parameter handler
without it causing undue noise. In this case the invalid parameters are
intentional, so provide a means to silence messages about them.
There is still noise from win32_close() and win32_select() which needs
resolving by some means too before the handler can be switched on without
its output causing test failures.
Diffstat (limited to 'win32/win32.c')
-rw-r--r-- | win32/win32.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/win32/win32.c b/win32/win32.c index 4f292b2a4d..c2ad58fbc5 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -115,6 +115,7 @@ END_EXTERN_C #endif #ifdef SET_INVALID_PARAMETER_HANDLER +static BOOL set_silent_invalid_parameter_handler(BOOL newvalue); static void my_invalid_parameter_handler(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved); @@ -164,6 +165,18 @@ END_EXTERN_C static OSVERSIONINFO g_osver = {0, 0, 0, 0, 0, ""}; #ifdef SET_INVALID_PARAMETER_HANDLER +static BOOL silent_invalid_parameter_handler = FALSE; + +static BOOL +set_silent_invalid_parameter_handler(BOOL newvalue) +{ +# ifdef _DEBUG + BOOL oldvalue = silent_invalid_parameter_handler; + silent_invalid_parameter_handler = newvalue; + return oldvalue; +# endif +} + static void my_invalid_parameter_handler(const wchar_t* expression, const wchar_t* function, @@ -175,6 +188,8 @@ my_invalid_parameter_handler(const wchar_t* expression, char* ansi_expression; char* ansi_function; char* ansi_file; + if (silent_invalid_parameter_handler) + return; ansi_expression = wstr_to_str(expression); ansi_function = wstr_to_str(function); ansi_file = wstr_to_str(file); @@ -4343,7 +4358,16 @@ win32_signal(int sig, Sighandler_t subcode) dTHX; if (sig < SIG_SIZE) { int save_errno = errno; - Sighandler_t result = signal(sig, subcode); + Sighandler_t result; +#ifdef SET_INVALID_PARAMETER_HANDLER + /* Silence our invalid parameter handler since we expect to make some + * calls with invalid signal numbers giving a SIG_ERR result. */ + BOOL oldvalue = set_silent_invalid_parameter_handler(TRUE); +#endif + result = signal(sig, subcode); +#ifdef SET_INVALID_PARAMETER_HANDLER + set_silent_invalid_parameter_handler(oldvalue); +#endif if (result == SIG_ERR) { result = w32_sighandler[sig]; errno = save_errno; |