Cygwin: Fix warnings about narrowing conversions of NTSTATUS constants

Fix warnings with gcc 12 about narrowing conversions of NTSTATUS
constants when used as case labels, e.g:

> ../../../../src/winsup/cygwin/exceptions.cc: In static member function ‘static int exception::handle(EXCEPTION_RECORD*, void*, CONTEXT*, PDISPATCHER_CONTEXT)’:
> ../../../../src/winsup/cygwin/exceptions.cc:670:10: error: narrowing conversion of ‘-1073741682’ from ‘NTSTATUS’ {aka ‘int’} to ‘unsigned int’ [-Wnarrowing]

See also: c5bdf60ac4

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
This commit is contained in:
Jon Turney 2024-08-04 16:30:16 +01:00
parent a0482c612c
commit 367b69a280
No known key found for this signature in database
GPG Key ID: C7C86F0370285C81
4 changed files with 4 additions and 4 deletions

View File

@ -665,7 +665,7 @@ exception::handle (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT *in,
siginfo_t si = {}; siginfo_t si = {};
si.si_code = SI_KERNEL; si.si_code = SI_KERNEL;
/* Coerce win32 value to posix value. */ /* Coerce win32 value to posix value. */
switch (e->ExceptionCode) switch ((NTSTATUS) e->ExceptionCode)
{ {
case STATUS_FLOAT_DIVIDE_BY_ZERO: case STATUS_FLOAT_DIVIDE_BY_ZERO:
si.si_signo = SIGFPE; si.si_signo = SIGFPE;

View File

@ -23,7 +23,7 @@ extern GUID __cygwin_socket_guid;
/* Custom Cygwin-only status codes. */ /* Custom Cygwin-only status codes. */
#define STATUS_THREAD_SIGNALED ((NTSTATUS)0xe0000001) #define STATUS_THREAD_SIGNALED ((NTSTATUS)0xe0000001)
#define STATUS_THREAD_CANCELED ((NTSTATUS)0xe0000002) #define STATUS_THREAD_CANCELED ((NTSTATUS)0xe0000002)
#define STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION ((DWORD) 0xe0000269) #define STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION ((NTSTATUS) 0xe0000269)
/* Simplify checking for a transactional error code. */ /* Simplify checking for a transactional error code. */
#define NT_TRANSACTIONAL_ERROR(s) \ #define NT_TRANSACTIONAL_ERROR(s) \

View File

@ -118,7 +118,7 @@ pinfo_init (char **envp, int envc)
DWORD DWORD
pinfo::status_exit (DWORD x) pinfo::status_exit (DWORD x)
{ {
switch (x) switch ((NTSTATUS) x)
{ {
case STATUS_DLL_NOT_FOUND: case STATUS_DLL_NOT_FOUND:
{ {

View File

@ -1082,7 +1082,7 @@ child_info::proc_retry (HANDLE h)
if (!exit_code) if (!exit_code)
return EXITCODE_OK; return EXITCODE_OK;
sigproc_printf ("exit_code %y", exit_code); sigproc_printf ("exit_code %y", exit_code);
switch (exit_code) switch ((NTSTATUS) exit_code)
{ {
case STILL_ACTIVE: /* shouldn't happen */ case STILL_ACTIVE: /* shouldn't happen */
sigproc_printf ("STILL_ACTIVE? How'd we get here?"); sigproc_printf ("STILL_ACTIVE? How'd we get here?");