[PATCH 5/6] Cygwin: Fix warnings about narrowing conversions of socket ioctls

Jon Turney jon.turney@dronecode.org.uk
Sun Aug 4 21:48:26 GMT 2024


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

> ../../../../src/winsup/cygwin/net.cc: In function ‘int get_ifconf(ifconf*, int)’:
> ../../../../src/winsup/cygwin/net.cc:1940:18: error: narrowing conversion of ‘2152756069’ from ‘long int’ to ‘int’ [-Wnarrowing]
---
 winsup/cygwin/net.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index 08c584fe5..b76af2d19 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -1935,7 +1935,7 @@ get_ifconf (struct ifconf *ifc, int what)
 	{
 	  ++cnt;
 	  strcpy (ifr->ifr_name, ifp->ifa_name);
-	  switch (what)
+	  switch ((long int)what)
 	    {
 	    case SIOCGIFFLAGS:
 	      ifr->ifr_flags = ifp->ifa_ifa.ifa_flags;
-- 
2.45.1



More information about the Cygwin-patches mailing list