[PATCH 5/6] Cygwin: Fix warnings about narrowing conversions of socket ioctls
Brian Inglis
Brian.Inglis@SystematicSW.ab.ca
Sun Aug 11 21:37:35 GMT 2024
On 2024-08-11 12:31, Brian Inglis wrote:
> 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?
Sorry folks,
Did not notice patches 5-6/6 have not yet been applied.
Apply both okay and rebuild proceeding.
--
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
More information about the Cygwin-patches
mailing list