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

@ -1519,7 +1519,7 @@ static CURLcode ftp_state_type(struct Curl_easy *data,
information. Which in FTP cannot be much more than the file size and
date. */
if(data->req.no_body && ftpc->file &&
ftp_need_type(ftpc, data->state.prefer_ascii)) {
ftp_need_type(ftpc, (bool)data->state.prefer_ascii)) {
/* The SIZE command is _not_ RFC 959 specified, and therefore many servers
may not support it! It is however the only way we have to get a file's
size! */
@ -1529,7 +1529,8 @@ static CURLcode ftp_state_type(struct Curl_easy *data,
/* Some servers return different sizes for different modes, and thus we
must set the proper type before we check the size */
result = ftp_nb_type(data, ftpc, ftp, data->state.prefer_ascii, FTP_TYPE);
result = ftp_nb_type(data, ftpc, ftp, (bool)data->state.prefer_ascii,
FTP_TYPE);
if(result)
return result;
}
@ -1570,7 +1571,7 @@ static CURLcode ftp_state_ul_setup(struct Curl_easy *data,
bool sizechecked)
{
CURLcode result = CURLE_OK;
bool append = data->set.remote_append;
curl_bit append = data->set.remote_append;
if((data->state.resume_from && !sizechecked) ||
((data->state.resume_from > 0) && sizechecked)) {
@ -2239,7 +2240,7 @@ static CURLcode ftp_do_more(struct Curl_easy *data, int *completep)
}
}
else if(data->state.upload) {
result = ftp_nb_type(data, ftpc, ftp, data->state.prefer_ascii,
result = ftp_nb_type(data, ftpc, ftp, (bool)data->state.prefer_ascii,
FTP_STOR_TYPE);
if(result)
return result;
@ -2284,7 +2285,7 @@ static CURLcode ftp_do_more(struct Curl_easy *data, int *completep)
FTP_RETR_LIST_TYPE);
}
else {
result = ftp_nb_type(data, ftpc, ftp, data->state.prefer_ascii,
result = ftp_nb_type(data, ftpc, ftp, (bool)data->state.prefer_ascii,
FTP_RETR_TYPE);
}
if(result)
@ -2417,7 +2418,7 @@ static CURLcode client_write_header(struct Curl_easy *data,
* headers from CONNECT should not automatically be part of the
* output. */
CURLcode result;
bool save = data->set.include_header;
bool save = (bool)data->set.include_header;
data->set.include_header = TRUE;
result = Curl_client_write(data, CLIENTWRITE_HEADER, buf, blen);
data->set.include_header = save;