msvc: drop exception, make BIT() a bitfield with Visual Studio

Add casts to `bool`, or use `bit` type in local variables, where
neccessary to avoid MSVC compiler warnings C4242.

Note: There may remain places needing the above updates, where not
tested in CI, and missed in manual review.

Also:
- urldata: convert struct field `connect_only` to bitfield to match its
  counterpart in another struct.
- rename curl-specific `bit` type to `curl_bit`.

Closes #20142
This commit is contained in:
Viktor Szakats 2026-01-01 16:38:56 +01:00
parent 57ff2d6c91
commit 85c841cb45
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
32 changed files with 73 additions and 73 deletions

View file

@ -623,7 +623,7 @@ static void multi_done_locked(struct connectdata *conn,
Curl_resolv_unlink(data, &data->state.dns[1]);
Curl_dnscache_prune(data);
if(multi_conn_should_close(conn, data, mdctx->premature)) {
if(multi_conn_should_close(conn, data, (bool)mdctx->premature)) {
#ifndef CURL_DISABLE_VERBOSE_STRINGS
CURL_TRC_M(data, "multi_done, terminating conn #%" FMT_OFF_T " to %s:%d, "
"forbid=%d, close=%d, premature=%d, conn_multiplex=%d",
@ -632,7 +632,7 @@ static void multi_done_locked(struct connectdata *conn,
Curl_conn_is_multiplex(conn, FIRSTSOCKET));
#endif
connclose(conn, "disconnecting");
Curl_conn_terminate(data, conn, mdctx->premature);
Curl_conn_terminate(data, conn, (bool)mdctx->premature);
}
else if(!Curl_conn_get_max_concurrent(data, conn, FIRSTSOCKET)) {
#ifndef CURL_DISABLE_VERBOSE_STRINGS
@ -640,7 +640,7 @@ static void multi_done_locked(struct connectdata *conn,
" by server, not reusing", conn->connection_id, host, port);
#endif
connclose(conn, "server shutdown");
Curl_conn_terminate(data, conn, mdctx->premature);
Curl_conn_terminate(data, conn, (bool)mdctx->premature);
}
else {
/* the connection is no longer in use by any transfer */
@ -1629,7 +1629,7 @@ CURLMcode curl_multi_wakeup(CURLM *m)
*/
static bool multi_ischanged(struct Curl_multi *multi, bool clear)
{
bool retval = multi->recheckstate;
bool retval = (bool)multi->recheckstate;
if(clear)
multi->recheckstate = FALSE;
return retval;