From 367b69a2803d4c0e4812b786f8f35865969f6636 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Sun, 4 Aug 2024 16:30:16 +0100 Subject: [PATCH] Cygwin: Fix warnings about narrowing conversions of NTSTATUS constants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: c5bdf60ac46401a51a7e974333d9622966e22d67 Signed-off-by: Jon Turney --- winsup/cygwin/exceptions.cc | 2 +- winsup/cygwin/local_includes/ntdll.h | 2 +- winsup/cygwin/pinfo.cc | 2 +- winsup/cygwin/sigproc.cc | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 28d0431d5..3195d5719 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -665,7 +665,7 @@ exception::handle (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT *in, siginfo_t si = {}; si.si_code = SI_KERNEL; /* Coerce win32 value to posix value. */ - switch (e->ExceptionCode) + switch ((NTSTATUS) e->ExceptionCode) { case STATUS_FLOAT_DIVIDE_BY_ZERO: si.si_signo = SIGFPE; diff --git a/winsup/cygwin/local_includes/ntdll.h b/winsup/cygwin/local_includes/ntdll.h index 7737ae503..4497fe53f 100644 --- a/winsup/cygwin/local_includes/ntdll.h +++ b/winsup/cygwin/local_includes/ntdll.h @@ -23,7 +23,7 @@ extern GUID __cygwin_socket_guid; /* Custom Cygwin-only status codes. */ #define STATUS_THREAD_SIGNALED ((NTSTATUS)0xe0000001) #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. */ #define NT_TRANSACTIONAL_ERROR(s) \ diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index 7f1f41d79..e31a67d8f 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -118,7 +118,7 @@ pinfo_init (char **envp, int envc) DWORD pinfo::status_exit (DWORD x) { - switch (x) + switch ((NTSTATUS) x) { case STATUS_DLL_NOT_FOUND: { diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 86e4e607a..99fa3c342 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -1082,7 +1082,7 @@ child_info::proc_retry (HANDLE h) if (!exit_code) return EXITCODE_OK; sigproc_printf ("exit_code %y", exit_code); - switch (exit_code) + switch ((NTSTATUS) exit_code) { case STILL_ACTIVE: /* shouldn't happen */ sigproc_printf ("STILL_ACTIVE? How'd we get here?");