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

@ -3240,7 +3240,7 @@ static X509_STORE *ossl_get_cached_x509_store(struct Curl_cfilter *cf,
!ossl_cached_x509_store_expired(data, share) &&
!ossl_cached_x509_store_different(cf, data, share)) {
store = share->store;
*pempty = share->store_is_empty;
*pempty = (bool)share->store_is_empty;
}
return store;
@ -3333,7 +3333,7 @@ CURLcode Curl_ssl_setup_x509_store(struct Curl_cfilter *cf,
result = ossl_populate_x509_store(cf, data, octx, store);
if(result == CURLE_OK && cache_criteria_met) {
ossl_set_cached_x509_store(cf, data, store, octx->store_is_empty);
ossl_set_cached_x509_store(cf, data, store, (bool)octx->store_is_empty);
}
}
@ -5017,7 +5017,7 @@ static bool ossl_data_pending(struct Curl_cfilter *cf,
{
struct ssl_connect_data *connssl = cf->ctx;
(void)data;
return connssl->input_pending;
return (bool)connssl->input_pending;
}
static CURLcode ossl_send(struct Curl_cfilter *cf,

View file

@ -83,7 +83,7 @@ static bool cr_data_pending(struct Curl_cfilter *cf,
(void)data;
DEBUGASSERT(ctx && ctx->backend);
backend = (struct rustls_ssl_backend_data *)ctx->backend;
return backend->data_in_pending;
return (bool)backend->data_in_pending;
}
struct io_ctx {

View file

@ -1716,7 +1716,7 @@ static CURLcode cf_ssl_create(struct Curl_cfilter **pcf,
#else
ctx = cf_ctx_new(data, alpn_get_spec(data->state.http_neg.wanted,
data->state.http_neg.preferred,
conn->bits.tls_enable_alpn));
(bool)conn->bits.tls_enable_alpn));
#endif
if(!ctx) {
result = CURLE_OUT_OF_MEMORY;
@ -1767,7 +1767,7 @@ static CURLcode cf_ssl_proxy_create(struct Curl_cfilter **pcf,
struct ssl_connect_data *ctx;
CURLcode result;
/* ALPN is default, but if user explicitly disables it, obey */
bool use_alpn = data->set.ssl_enable_alpn;
bool use_alpn = (bool)data->set.ssl_enable_alpn;
http_majors wanted = CURL_HTTP_V1x;
(void)conn;