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

Brian Inglis Brian.Inglis@SystematicSW.ab.ca
Sun Aug 11 18:31:52 GMT 2024


On 2024-08-07 08:06, Corinna Vinschen wrote:
> On Aug  6 19:58, Jon Turney wrote:
>> On 05/08/2024 11:22, Corinna Vinschen wrote:
>>> On Aug  4 22:48, Jon Turney wrote:
>>>> Fix gcc 12 warnings about narrowing conversions of socket ioctl constants
>>>> when used as case labels, e.g:
>>>> [...]
>>> The only caller, fhandler_socket::ioctl, passes an unsigned int
>>> value to get_ifconf. Given how the value is defined, it would be
>>> more straightforward to convert get_ifconf to
>>>
>>>     get_ifconf (struct ifconf *ifc, unsigned int what);
>>>
>>> wouldn't it?
>>
>> Yeah, I'm not sure why I didn't do that.  I think I got confused about where
>> this is used from.

> LGTM.  I will additionally push a patch dropping the useless casts.

Hi folks,

Trying to rebuild got a couple of issues with gcc12 and likely recent updates to 
main, as my previous rebuild for /proc/cpuinfo with gcc11 was fine:

- picky g++

   CXX      net.o
In file included from 
/usr/src/newlib-cygwin/winsup/cygwin/include/cygwin/socket.h:47,
                  from /usr/src/newlib-cygwin/winsup/cygwin/include/cygwin/if.h:17,
                  from /usr/src/newlib-cygwin/winsup/cygwin/include/ifaddrs.h:42,
                  from /usr/src/newlib-cygwin/winsup/cygwin/net.cc:26:
/usr/src/newlib-cygwin/winsup/cygwin/net.cc: In function ‘int 
get_ifconf(ifconf*, int)’:
/usr/src/newlib-cygwin/winsup/cygwin/net.cc:1940:18: error: narrowing conversion 
of ‘2152756069’ from ‘long unsigned int’ to ‘int’ [-Wnarrowing]
  1940 |             case SIOCGIFFLAGS:
       |                  ^~~~~~~~~~~~
... and so on

50cf10dfa485 Cygwin: asm/socket.h: drop outdated casts

so change net.cc get_ifconf (struct ifconf *ifc, int what) to unsigned long, and 
where it is also declared in fhandler/socket.cc?

- __utoa (and __itoa) declared in stdlib.h inside #ifndef __CYGWIN__

   CC       libc/stdlib/libc_a-itoa.o
/usr/src/newlib-cygwin/newlib/libc/stdlib/itoa.c: In function ‘__itoa’:
/usr/src/newlib-cygwin/newlib/libc/stdlib/itoa.c:57:3: warning: implicit 
declaration of function ‘__utoa’; did you mean ‘__itoa’? 
[-Wimplicit-function-declaration]
    57 |   __utoa (uvalue, &str[i], base);
       |   ^~~~~~
       |   __itoa


31f7cd1e4332 Hide itoa, utoa, __itoa and __utoa in stdlib.h on Cygwin only

$ grep -C2 utoa ../../newlib/libc/include/stdlib.h
#ifndef __CYGWIN__
char *  __itoa (int, char *, int);
char *  __utoa (unsigned, char *, int);
# if __MISC_VISIBLE
char *  itoa (int, char *, int);
char *  utoa (unsigned, char *, int);
# endif
#endif

so should this be __INSIDE_CYGWIN__ instead or something else?

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                 -- Antoine de Saint-Exupéry
-------------- next part --------------
2024-08-10 22:01:35Z
2024-08-10 22:01:36Z
2024-08-10 22:04:02Z
...
make[2]: Entering directory '/usr/src/build64/x86_64-pc-cygwin/newlib'
/usr/bin/make "CC_FOR_BUILD=gcc" "CFLAGS=-g -O2" "CCASFLAGS=-g -O2" "CFLAGS_FOR_BUILD=-g -O2" "CFLAGS_FOR_TARGET=-g -O2" "INSTALL=/usr/bin/install -c" "LDFLAGS=" "LIBCFLAGS=-g -O2" "LIBCFLAGS_FOR_TARGET=-g -O2" "MAKE=/usr/bin/make" "MAKEINFO=makeinfo --split-size=5000000 --split-size=5000000 " "PICFLAG=" "PICFLAG_FOR_TARGET=" "SHELL=/bin/sh" "EXPECT=expect" "RUNTEST=runtest" "RUNTESTFLAGS=" "exec_prefix=/usr/src/install64/usr/bin" "infodir=/usr/src/install64/usr/share/info" "libdir=/usr/src/install64/usr/bin/lib" "prefix=/usr/src/install64/usr" "tooldir=/usr/src/install64/usr/bin/x86_64-pc-cygwin" "top_toollibdir=/usr/src/install64/usr/bin/x86_64-pc-cygwin/lib" "AR=ar " "AS=as" "CC=gcc -L/usr/src/build64/x86_64-pc-cygwin/winsup/cygwin -isystem /usr/src/newlib-cygwin/winsup/cygwin/include -B/usr/src/build64/x86_64-pc-cygwin/newlib/ -isystem /usr/src/build64/x86_64-pc-cygwin/newlib/targ-include -isystem /usr/src/newlib-cygwin/newlib/libc/include    -I/usr/src/newlib-cygwin/newlib/../winsup/cygwin/include" "LD=/usr/lib/gcc/x86_64-pc-cygwin/12/../../../../x86_64-pc-cygwin/bin/ld.exe" "LIBCFLAGS=-g -O2" "NM=nm" "PICFLAG=" "RANLIB=ranlib " "DESTDIR=/usr/src/install64" all-am
make[3]: Entering directory '/usr/src/build64/x86_64-pc-cygwin/newlib'
...
  CC       libc/stdlib/libc_a-itoa.o
/usr/src/newlib-cygwin/newlib/libc/stdlib/itoa.c: In function ‘__itoa’:
/usr/src/newlib-cygwin/newlib/libc/stdlib/itoa.c:57:3: warning: implicit declaration of function ‘__utoa’; did you mean ‘__itoa’? [-Wimplicit-function-declaration]
   57 |   __utoa (uvalue, &str[i], base);
      |   ^~~~~~
      |   __itoa
...
make[4]: Leaving directory '/usr/src/build64/x86_64-pc-cygwin/newlib'
make[3]: Leaving directory '/usr/src/build64/x86_64-pc-cygwin/newlib'
make[2]: Leaving directory '/usr/src/build64/x86_64-pc-cygwin/newlib'
make[2]: Entering directory '/usr/src/build64/x86_64-pc-cygwin/winsup'
make[3]: Entering directory '/usr/src/build64/x86_64-pc-cygwin/winsup/cygwin'
make[4]: Entering directory '/usr/src/build64/x86_64-pc-cygwin/winsup/cygwin'
...
  CXX      net.o
In file included from /usr/src/newlib-cygwin/winsup/cygwin/include/cygwin/socket.h:47,
                 from /usr/src/newlib-cygwin/winsup/cygwin/include/cygwin/if.h:17,
                 from /usr/src/newlib-cygwin/winsup/cygwin/include/ifaddrs.h:42,
                 from /usr/src/newlib-cygwin/winsup/cygwin/net.cc:26:
/usr/src/newlib-cygwin/winsup/cygwin/net.cc: In function ‘int get_ifconf(ifconf*, int)’:
/usr/src/newlib-cygwin/winsup/cygwin/net.cc:1940:18: error: narrowing conversion of ‘2152756069’ from ‘long unsigned int’ to ‘int’ [-Wnarrowing]
 1940 |             case SIOCGIFFLAGS:
      |                  ^~~~~~~~~~~~
/usr/src/newlib-cygwin/winsup/cygwin/net.cc:1943:18: error: narrowing conversion of ‘2148561764’ from ‘long unsigned int’ to ‘int’ [-Wnarrowing]
 1943 |             case SIOCGIFCONF:
      |                  ^~~~~~~~~~~
/usr/src/newlib-cygwin/winsup/cygwin/net.cc:1944:18: error: narrowing conversion of ‘2152756070’ from ‘long unsigned int’ to ‘int’ [-Wnarrowing]
 1944 |             case SIOCGIFADDR:
      |                  ^~~~~~~~~~~
/usr/src/newlib-cygwin/winsup/cygwin/net.cc:1948:18: error: narrowing conversion of ‘2152756072’ from ‘long unsigned int’ to ‘int’ [-Wnarrowing]
 1948 |             case SIOCGIFNETMASK:
      |                  ^~~~~~~~~~~~~~
/usr/src/newlib-cygwin/winsup/cygwin/net.cc:1952:18: error: narrowing conversion of ‘2152756078’ from ‘long unsigned int’ to ‘int’ [-Wnarrowing]
 1952 |             case SIOCGIFDSTADDR:
      |                  ^~~~~~~~~~~~~~
/usr/src/newlib-cygwin/winsup/cygwin/net.cc:1959:18: error: narrowing conversion of ‘2152756071’ from ‘long unsigned int’ to ‘int’ [-Wnarrowing]
 1959 |             case SIOCGIFBRDADDR:
      |                  ^~~~~~~~~~~~~~
/usr/src/newlib-cygwin/winsup/cygwin/net.cc:1970:18: error: narrowing conversion of ‘2152756073’ from ‘long unsigned int’ to ‘int’ [-Wnarrowing]
 1970 |             case SIOCGIFHWADDR:
      |                  ^~~~~~~~~~~~~
/usr/src/newlib-cygwin/winsup/cygwin/net.cc:1974:18: error: narrowing conversion of ‘2152756074’ from ‘long unsigned int’ to ‘int’ [-Wnarrowing]
 1974 |             case SIOCGIFMETRIC:
      |                  ^~~~~~~~~~~~~
/usr/src/newlib-cygwin/winsup/cygwin/net.cc:1977:18: error: narrowing conversion of ‘2152756075’ from ‘long unsigned int’ to ‘int’ [-Wnarrowing]
 1977 |             case SIOCGIFMTU:
      |                  ^~~~~~~~~~
/usr/src/newlib-cygwin/winsup/cygwin/net.cc:1980:18: error: narrowing conversion of ‘2152756076’ from ‘long unsigned int’ to ‘int’ [-Wnarrowing]
 1980 |             case SIOCGIFINDEX:
      |                  ^~~~~~~~~~~~
/usr/src/newlib-cygwin/winsup/cygwin/net.cc:1983:18: error: narrowing conversion of ‘2152756077’ from ‘long unsigned int’ to ‘int’ [-Wnarrowing]
 1983 |             case SIOCGIFFRNDLYNAM:
      |                  ^~~~~~~~~~~~~~~~
make[4]: *** [Makefile:2076: net.o] Error 1
make[4]: Leaving directory '/usr/src/build64/x86_64-pc-cygwin/winsup/cygwin'
make[3]: *** [Makefile:1186: all] Error 2
make[3]: Leaving directory '/usr/src/build64/x86_64-pc-cygwin/winsup/cygwin'
make[2]: *** [Makefile:395: all-recursive] Error 1
make[2]: Leaving directory '/usr/src/build64/x86_64-pc-cygwin/winsup'
make[1]: *** [Makefile:9464: all-target-winsup] Error 2
make[1]: Leaving directory '/usr/src/build64'
make: *** [Makefile:883: all] Error 2
2024-08-10 22:23:31Z


More information about the Cygwin-patches mailing list