build: fix -Wconversion/-Wsign-conversion warnings

Fix remaining warnings in examples and tests which are not suppressed
by the pragma in `lib/curl_setup.h`.

Silence a toolchain issue causing warnings in `FD_SET()` calls with
older Cygwin/MSYS2 builds. Likely fixed on 2020-08-03 by:
https://cygwin.com/git/?p=newlib-cygwin.git;a=commitdiff;h=5717262b8ecfed0f7fab63e2c09c78991e36f9dd

Follow-up to 2dbe75bd7f #12492

Closes #12557
This commit is contained in:
Viktor Szakats 2023-12-19 19:16:03 +00:00
parent 2dbe75bd7f
commit 95a882d268
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
10 changed files with 32 additions and 24 deletions

View file

@ -44,6 +44,13 @@ static int wait_on_socket(curl_socket_t sockfd, int for_recv, long timeout_ms)
FD_ZERO(&outfd);
FD_ZERO(&errfd);
/* Avoid this warning with pre-2020 Cygwin/MSYS releases:
* warning: conversion to 'long unsigned int' from 'curl_socket_t' {aka 'int'} may change the sign of the result [-Wsign-conversion]
*/
#if defined(__GNUC__) && defined(__CYGWIN__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
FD_SET(sockfd, &errfd); /* always check for error */
if(for_recv) {
@ -52,6 +59,9 @@ static int wait_on_socket(curl_socket_t sockfd, int for_recv, long timeout_ms)
else {
FD_SET(sockfd, &outfd);
}
#if defined(__GNUC__) && defined(__CYGWIN__)
#pragma GCC diagnostic pop
#endif
/* select() returns the number of signalled sockets or -1 */
res = select((int)sockfd + 1, &infd, &outfd, &errfd, &tv);