build: globally suppress DJGPP warnings in FD_SET()

Replacing the many local `#pragma` used before this patch,
reducing the number of `__DJGPP__` guards from 58 to 13.

Closes #20299
This commit is contained in:
Viktor Szakats
2026-01-13 22:07:53 +01:00
parent ad8374aedc
commit 0431cbe71a
13 changed files with 13 additions and 157 deletions

View File

@@ -436,6 +436,10 @@ if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND MSVC)
endforeach()
endif()
if(DOS AND CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)
list(APPEND _picky "-Wno-arith-conversion") # Avoid warnings in DJGPP's built-in FD_SET() macro
endif()
if(_picky_nocheck OR _picky)
set(_picky_tmp "${_picky_nocheck}" "${_picky}")
string(REPLACE ";" " " _picky_tmp "${_picky_tmp}")

View File

@@ -598,6 +598,15 @@ if test "$compiler_id" = "INTEL_UNIX_C"; then
#
fi
case $host in
*msdosdjgpp)
if test "$compiler_num" -ge "1000"; then
dnl Avoid warnings in DJGPP's built-in FD_SET() macro
CFLAGS="$CFLAGS -Wno-arith-conversion"
fi
;;
esac
CURL_CFLAG_EXTRAS=""
if test "$want_werror" = "yes"; then
CURL_CFLAG_EXTRAS="-Werror"

View File

@@ -36,9 +36,6 @@
*/
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wsign-conversion"
#ifdef __DJGPP__
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
#elif defined(_MSC_VER)
#pragma warning(disable:4127) /* conditional expression is constant */
#endif

View File

@@ -480,17 +480,10 @@ void Curl_cshutdn_setfds(struct cshutdn *cshutdn,
curl_socket_t sock = ps.sockets[i];
if(!FDSET_SOCK(sock))
continue;
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
if(ps.actions[i] & CURL_POLL_IN)
FD_SET(sock, read_fd_set);
if(ps.actions[i] & CURL_POLL_OUT)
FD_SET(sock, write_fd_set);
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
if((ps.actions[i] & (CURL_POLL_OUT | CURL_POLL_IN)) &&
((int)sock > *maxfd))
*maxfd = (int)sock;

View File

@@ -1246,17 +1246,10 @@ CURLMcode curl_multi_fdset(CURLM *m,
if(!FDSET_SOCK(ps.sockets[i]))
/* pretend it does not exist */
continue;
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
if(ps.actions[i] & CURL_POLL_IN)
FD_SET(ps.sockets[i], read_fd_set);
if(ps.actions[i] & CURL_POLL_OUT)
FD_SET(ps.sockets[i], write_fd_set);
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
if((int)ps.sockets[i] > this_max_fd)
this_max_fd = (int)ps.sockets[i];
}

View File

@@ -65,14 +65,7 @@ static bool waitfd(int waitms, int fd)
timeout.tv_usec = (int)((waitms % 1000) * 1000);
FD_ZERO(&bits);
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(fd, &bits);
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
if(!select(fd + 1, &bits, NULL, NULL, &timeout))
return TRUE; /* timeout */
return FALSE;

View File

@@ -233,14 +233,7 @@ static void t530_updateFdSet(struct t530_Sockets *sockets, fd_set *fdset,
{
int i;
for(i = 0; i < sockets->count; ++i) {
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(sockets->sockets[i], fdset);
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
if(*maxFd < sockets->sockets[i] + 1) {
*maxFd = sockets->sockets[i] + 1;
}

View File

@@ -180,14 +180,7 @@ static void t582_updateFdSet(struct t582_Sockets *sockets, fd_set *fdset,
{
int i;
for(i = 0; i < sockets->count; ++i) {
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(sockets->sockets[i], fdset);
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
if(*maxFd < sockets->sockets[i] + 1) {
*maxFd = sockets->sockets[i] + 1;
}

View File

@@ -279,14 +279,7 @@ static void t758_updateFdSet(struct t758_Sockets *sockets, fd_set *fdset,
{
int i;
for(i = 0; i < sockets->count; ++i) {
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(sockets->sockets[i], fdset);
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
if(*maxFd < sockets->sockets[i] + 1) {
*maxFd = sockets->sockets[i] + 1;
}

View File

@@ -675,14 +675,7 @@ static bool mqttd_incoming(curl_socket_t listenfd)
FD_ZERO(&fds_err);
/* there is always a socket to wait for */
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(sockfd, &fds_read);
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
do {
/* select() blocking behavior call on blocking descriptors please */

View File

@@ -953,14 +953,7 @@ static bool juggle(curl_socket_t *sockfdp,
FD_ZERO(&fds_write);
FD_ZERO(&fds_err);
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET((curl_socket_t)fileno(stdin), &fds_read);
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
switch(*mode) {
@@ -969,14 +962,7 @@ static bool juggle(curl_socket_t *sockfdp,
/* server mode */
sockfd = listenfd;
/* there is always a socket to wait for */
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(sockfd, &fds_read);
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
maxfd = (int)sockfd;
break;
@@ -990,14 +976,7 @@ static bool juggle(curl_socket_t *sockfdp,
}
else {
/* there is always a socket to wait for */
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(sockfd, &fds_read);
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
maxfd = (int)sockfd;
}
break;
@@ -1007,14 +986,7 @@ static bool juggle(curl_socket_t *sockfdp,
sockfd = *sockfdp;
/* sockfd turns CURL_SOCKET_BAD when our connection has been closed */
if(CURL_SOCKET_BAD != sockfd) {
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(sockfd, &fds_read);
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
maxfd = (int)sockfd;
}
else {

View File

@@ -649,37 +649,16 @@ static bool socksd_incoming(curl_socket_t listenfd)
FD_ZERO(&fds_err);
/* there is always a socket to wait for */
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(sockfd, &fds_read);
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
for(i = 0; i < 2; i++) {
if(c[i].used) {
curl_socket_t fd = c[i].clientfd;
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(fd, &fds_read);
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
if((int)fd > maxfd)
maxfd = (int)fd;
fd = c[i].remotefd;
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(fd, &fds_read);
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
if((int)fd > maxfd)
maxfd = (int)fd;
}

View File

@@ -1118,14 +1118,7 @@ static int sws_get_request(curl_socket_t sock, struct sws_httprequest *req)
FD_ZERO(&input);
FD_ZERO(&output);
got = 0;
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(sock, &input);
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
do {
logmsg("Wait until readable");
rc = select((int)sock + 1, &input, &output, NULL, &timeout);
@@ -1321,14 +1314,7 @@ static curl_socket_t connect_to(const char *ipaddr, unsigned short port)
timeout.tv_sec = 1; /* 1000 ms */
FD_ZERO(&output);
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(serverfd, &output);
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
while(1) {
rc = select((int)serverfd + 1, NULL, &output, NULL, &timeout);
if(rc < 0 && SOCKERRNO != SOCKEINTR)
@@ -1453,14 +1439,7 @@ static void http_connect(curl_socket_t *infdp,
/* listener socket is monitored to allow client to establish
secondary tunnel only when this tunnel is not established
and primary one is fully operational */
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(rootfd, &input);
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
maxfd = rootfd;
}
@@ -1470,28 +1449,14 @@ static void http_connect(curl_socket_t *infdp,
if(clientfd[i] != CURL_SOCKET_BAD) {
if(poll_client_rd[i]) {
/* unless told not to do so, monitor readability */
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(clientfd[i], &input);
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
if(clientfd[i] > maxfd)
maxfd = clientfd[i];
}
if(poll_client_wr[i] && toc[i]) {
/* unless told not to do so, monitor writability
if there is data ready to be sent to client */
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(clientfd[i], &output);
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
if(clientfd[i] > maxfd)
maxfd = clientfd[i];
}
@@ -1500,28 +1465,14 @@ static void http_connect(curl_socket_t *infdp,
if(serverfd[i] != CURL_SOCKET_BAD) {
if(poll_server_rd[i]) {
/* unless told not to do so, monitor readability */
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(serverfd[i], &input);
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
if(serverfd[i] > maxfd)
maxfd = serverfd[i];
}
if(poll_server_wr[i] && tos[i]) {
/* unless told not to do so, monitor writability
if there is data ready to be sent to server */
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(serverfd[i], &output);
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
if(serverfd[i] > maxfd)
maxfd = serverfd[i];
}
@@ -2343,14 +2294,7 @@ static int test_sws(int argc, char *argv[])
for(socket_idx = 0; socket_idx < num_sockets; ++socket_idx) {
/* Listen on all sockets */
#ifdef __DJGPP__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(all_sockets[socket_idx], &input);
#ifdef __DJGPP__
#pragma GCC diagnostic pop
#endif
if(all_sockets[socket_idx] > maxfd)
maxfd = all_sockets[socket_idx];
}