Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <10dead9f-55f9-4426-adcb-1d25769e6fc0@brad-house.com>
Date: Tue, 16 Jul 2024 10:05:06 -0400
From: Brad House <brad@...d-house.com>
To: musl@...ts.openwall.com
Subject: [PATCH 1/1] FD_SET() and FD_ISSET() warn on -Wsign-conversion

I'm the maintainer of c-ares (https://c-ares.org) and have been scanning 
the CI build logs for various systems to catch warnings, and on Alpine 
Linux (which obviously uses musl c) we always get these warnings:

/tmp/cirrus-ci-build/src/lib/ares_event_select.c: In function 
'ares_evsys_select_wait':
/tmp/cirrus-ci-build/src/lib/ares_event_select.c:95:7: warning: 
conversion to 'long unsigned int' from 'ares_socket_t' {aka 'int'} may 
change the sign of the result [-Wsign-conversion]
    95 |       FD_SET(ev->fd, &read_fds);
       |       ^~~~~~
/tmp/cirrus-ci-build/src/lib/ares_event_select.c:95:7: warning: 
conversion to 'long unsigned int' from 'ares_socket_t' {aka 'int'} may 
change the sign of the result [-Wsign-conversion]
/tmp/cirrus-ci-build/src/lib/ares_event_select.c:98:7: warning: 
conversion to 'long unsigned int' from 'ares_socket_t' {aka 'int'} may 
change the sign of the result [-Wsign-conversion]
    98 |       FD_SET(ev->fd, &write_fds);
       |       ^~~~~~
/tmp/cirrus-ci-build/src/lib/ares_event_select.c:98:7: warning: 
conversion to 'long unsigned int' from 'ares_socket_t' {aka 'int'} may 
change the sign of the result [-Wsign-conversion]
/tmp/cirrus-ci-build/src/lib/ares_event_select.c:122:11: warning: 
conversion to 'long unsigned int' from 'ares_socket_t' {aka 'int'} may 
change the sign of the result [-Wsign-conversion]
   122 |       if (FD_ISSET(fdlist[i], &read_fds)) {
       |           ^~~~~~~~
/tmp/cirrus-ci-build/src/lib/ares_event_select.c:122:11: warning: 
conversion to 'long unsigned int' from 'ares_socket_t' {aka 'int'} may 
change the sign of the result [-Wsign-conversion]
/tmp/cirrus-ci-build/src/lib/ares_event_select.c:126:11: warning: 
conversion to 'long unsigned int' from 'ares_socket_t' {aka 'int'} may 
change the sign of the result [-Wsign-conversion]
   126 |       if (FD_ISSET(fdlist[i], &write_fds)) {
       |           ^~~~~~~~
/tmp/cirrus-ci-build/src/lib/ares_event_select.c:126:11: warning: 
conversion to 'long unsigned int' from 'ares_socket_t' {aka 'int'} may 
change the sign of the result [-Wsign-conversion]

full build output: 
https://cirrus-ci.com/task/6416020481507328?logs=main#L401

Sockets / File Descriptors in POSIX are defined as 'int', so it seems 
bad to have the standard C library complain when you pass an 'int' to a 
macro that should be expecting an 'int'.  I know -Wsign-conversion 
probably isn't a common warning flag to test with but its part of our 
default set of warnings.

I've attached a patch that will silence this warning, but otherwise not 
impact the behavior.

-Brad

View attachment "musl-fd_set-warning-fix.patch" of type "text/plain" (1241 bytes)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.