]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
msvc: drop exception, make `BIT()` a bitfield with Visual Studio
authorViktor Szakats <commit@vsz.me>
Thu, 1 Jan 2026 15:38:56 +0000 (16:38 +0100)
committerViktor Szakats <commit@vsz.me>
Sat, 17 Jan 2026 10:46:31 +0000 (11:46 +0100)
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

32 files changed:
lib/asyn-thrdd.c
lib/cf-ip-happy.c
lib/cf-socket.c
lib/cfilters.c
lib/connect.c
lib/cookie.c
lib/cshutdn.c
lib/curl_sasl.c
lib/curl_setup_once.h
lib/cw-out.c
lib/ftp.c
lib/http.c
lib/http2.c
lib/http_chunks.c
lib/http_proxy.c
lib/imap.c
lib/mime.c
lib/multi.c
lib/pop3.c
lib/ratelimit.c
lib/sendf.c
lib/smtp.c
lib/socks.c
lib/url.c
lib/urldata.h
lib/vquic/curl_ngtcp2.c
lib/vtls/openssl.c
lib/vtls/rustls.c
lib/vtls/vtls.c
lib/ws.c
src/tool_cb_wrt.c
src/tool_operate.c

index 55f65cd5aea02c849f250714eb7825146bcbdf0d..3bafaf04a8a2a003e961c7200bb384f0636a7ad6 100644 (file)
@@ -199,7 +199,7 @@ err_exit:
 static CURL_THREAD_RETURN_T CURL_STDCALL getaddrinfo_thread(void *arg)
 {
   struct async_thrdd_addr_ctx *addr_ctx = arg;
-  bool do_abort;
+  curl_bit do_abort;
 
   Curl_mutex_acquire(&addr_ctx->mutx);
   do_abort = addr_ctx->do_abort;
@@ -301,7 +301,7 @@ static void async_thrdd_destroy(struct Curl_easy *data)
 #endif
 
   if(thrdd->addr && (thrdd->addr->thread_hnd != curl_thread_t_null)) {
-    bool done;
+    curl_bit done;
 
     Curl_mutex_acquire(&addr->mutx);
 #ifndef CURL_DISABLE_SOCKETPAIR
@@ -462,7 +462,7 @@ static void async_thrdd_shutdown(struct Curl_easy *data)
 {
   struct async_thrdd_ctx *thrdd = &data->state.async.thrdd;
   struct async_thrdd_addr_ctx *addr_ctx = thrdd->addr;
-  bool done;
+  curl_bit done;
 
   if(!addr_ctx)
     return;
@@ -569,7 +569,7 @@ CURLcode Curl_async_is_resolved(struct Curl_easy *data,
                                 struct Curl_dns_entry **dns)
 {
   struct async_thrdd_ctx *thrdd = &data->state.async.thrdd;
-  bool done = FALSE;
+  curl_bit done = FALSE;
 
   DEBUGASSERT(dns);
   *dns = NULL;
@@ -666,7 +666,7 @@ CURLcode Curl_async_pollset(struct Curl_easy *data, struct easy_pollset *ps)
 {
   struct async_thrdd_ctx *thrdd = &data->state.async.thrdd;
   CURLcode result = CURLE_OK;
-  bool thrd_done;
+  curl_bit thrd_done;
 
 #if !defined(USE_HTTPSRR_ARES) && defined(CURL_DISABLE_SOCKETPAIR)
   (void)ps;
index 0644c13cf8b7f89b4f919c3756a89cbdbc48bbc6..a802ddacb42b0bcb878c2c20321a74a3a5f2d0c6 100644 (file)
@@ -228,7 +228,7 @@ static CURLcode cf_ip_attempt_connect(struct cf_ip_attempt *a,
                                       struct Curl_easy *data,
                                       bool *connected)
 {
-  *connected = a->connected;
+  *connected = (bool)a->connected;
   if(!a->result && !*connected) {
     /* evaluate again */
     a->result = Curl_conn_cf_connect(a->cf, data, connected);
index 251a603db22c7164efc74ba50a7f66b8058c33c3..837f72e9af59a84a36a43fc79e1e109c2a8489aa 100644 (file)
@@ -1263,7 +1263,7 @@ static CURLcode cf_tcp_connect(struct Curl_cfilter *cf,
     }
 
     /* Connect TCP socket */
-    rc = do_connect(cf, data, cf->conn->bits.tcp_fastopen);
+    rc = do_connect(cf, data, (bool)cf->conn->bits.tcp_fastopen);
     error = SOCKERRNO;
     set_local_ip(cf, data);
     CURL_TRC_CF(data, cf, "local address %s port %d...",
index 76c24e7a68bafaff89c12a73377187d58e06ec49..c6aa06a3b87e750b6583f4344fe47a94e77005e9 100644 (file)
@@ -513,7 +513,7 @@ CURLcode Curl_conn_connect(struct Curl_easy *data,
     return CURLE_FAILED_INIT;
   }
 
-  *done = cf->connected;
+  *done = (bool)cf->connected;
   if(*done)
     return CURLE_OK;
 
@@ -610,7 +610,7 @@ bool Curl_conn_is_connected(struct connectdata *conn, int sockindex)
     return FALSE;
   cf = conn->cfilter[sockindex];
   if(cf)
-    return cf->connected;
+    return (bool)cf->connected;
   else if(conn->handler->flags & PROTOPT_NONETWORK)
     return TRUE;
   return FALSE;
index 681ead7227e01144dd79eec908fa95c05d95b36b..c832f86086096ca5ec7e02fff6a390d304b22c87 100644 (file)
@@ -317,7 +317,7 @@ void Curl_conncontrol(struct connectdata *conn,
             ((ctrl == CONNCTRL_STREAM) && !is_multiplex);
   if((ctrl == CONNCTRL_STREAM) && is_multiplex)
     ;  /* stream signal on multiplex conn never affects close state */
-  else if((bit)closeit != conn->bits.close) {
+  else if((curl_bit)closeit != conn->bits.close) {
     conn->bits.close = closeit; /* the only place in the source code that
                                    should assign this bit */
   }
index c8072228b94ee34172d5eb04c82bf57adbc722fc..e385f6e9e9932f5ea5d0eb9614968d8a80e751f3 100644 (file)
@@ -1169,7 +1169,7 @@ CURLcode Curl_cookie_loadfiles(struct Curl_easy *data)
       data->state.cookie_engine = TRUE;
       while(list) {
         result = cookie_load(data, list->data, data->cookies,
-                             data->set.cookiesession);
+                             (bool)data->set.cookiesession);
         if(result)
           break;
         list = list->next;
index b2c62e1309472169c9c23568c7167be13a2a42da..84db4e717ca68a5e9150749613ef1f459b2baabd 100644 (file)
@@ -59,7 +59,7 @@ static void cshutdn_run_conn_handler(struct Curl_easy *data,
                    conn->connection_id, conn->bits.aborted));
       /* There are protocol handlers that block on retrieving
        * server responses here (FTP). Set a short timeout. */
-      conn->handler->disconnect(data, conn, conn->bits.aborted);
+      conn->handler->disconnect(data, conn, (bool)conn->bits.aborted);
     }
 
     conn->bits.shutdown_handler = TRUE;
index abcb3315b12a8e894fc3b89cf75e2b43a5499714..6197ea007f6b2cf76b5d5ad446b774baaf8d5419 100644 (file)
@@ -332,8 +332,8 @@ static bool sasl_choose_krb5(struct Curl_easy *data, struct sasl_ctx *sctx)
         Curl_auth_create_gssapi_user_message(data, sctx->conn->user,
                                              sctx->conn->passwd,
                                              service, sctx->conn->host.name,
-                                             sctx->sasl->mutual_auth, NULL,
-                                             krb5, &sctx->resp);
+                                             (bool)sctx->sasl->mutual_auth,
+                                             NULL, krb5, &sctx->resp);
     }
     return TRUE;
   }
@@ -712,7 +712,7 @@ CURLcode Curl_sasl_continue(struct SASL *sasl, struct Curl_easy *data,
     result = !krb5 ? CURLE_OUT_OF_MEMORY :
       Curl_auth_create_gssapi_user_message(data, conn->user, conn->passwd,
                                            service, conn->host.name,
-                                           sasl->mutual_auth, NULL,
+                                           (bool)sasl->mutual_auth, NULL,
                                            krb5, &resp);
     newstate = SASL_GSSAPI_TOKEN;
     break;
@@ -728,7 +728,7 @@ CURLcode Curl_sasl_continue(struct SASL *sasl, struct Curl_easy *data,
            message */
         result = Curl_auth_create_gssapi_user_message(data, NULL, NULL,
                                                       NULL, NULL,
-                                                      sasl->mutual_auth,
+                                                      (bool)sasl->mutual_auth,
                                                       &serverdata,
                                                       krb5, &resp);
         newstate = SASL_GSSAPI_NO_DATA;
@@ -801,7 +801,7 @@ CURLcode Curl_sasl_continue(struct SASL *sasl, struct Curl_easy *data,
     sasl->curmech = NULL;
 
     /* Start an alternative SASL authentication */
-    return Curl_sasl_start(sasl, data, sasl->force_ir, progress);
+    return Curl_sasl_start(sasl, data, (bool)sasl->force_ir, progress);
   default:
     failf(data, "Unsupported SASL authentication mechanism");
     result = CURLE_UNSUPPORTED_PROTOCOL;  /* Should not happen */
index 06ccc98639fdd0bb2d08c7e3f0f968a9375799f4..df20b729375d85beab8fd6cc8b0e8027904c7e7f 100644 (file)
@@ -233,13 +233,8 @@ struct timeval {
 #endif
 
 /* the type we use for storing a single boolean bit */
-#ifdef _MSC_VER
-typedef bool bit;
-#define BIT(x) bool x
-#else
-typedef unsigned int bit;
-#define BIT(x) bit x:1
-#endif
+typedef unsigned int curl_bit;
+#define BIT(x) curl_bit x:1
 
 /*
  * Redefine TRUE and FALSE too, to catch current use. With this
index 786d7509cd89e47134da6e9070809969fc5a1041..3936cf0276b32f5d964c769b9f4a7f05b4d77bda 100644 (file)
@@ -458,7 +458,7 @@ bool Curl_cw_out_is_paused(struct Curl_easy *data)
     return FALSE;
 
   ctx = (struct cw_out_ctx *)cw_out;
-  return ctx->paused;
+  return (bool)ctx->paused;
 }
 
 static CURLcode cw_out_flush(struct Curl_easy *data,
index 858fb7539cac47b8b66b352e822722d78495db13..42ac5f5c74b4811d41dfcc78b2165655fabdf397 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -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;
index 76d904c05ad3f1e3aee3bb772a34624c5b72c141..4334428bec12af352f99a6e50bf01d769d8a8de7 100644 (file)
@@ -527,7 +527,7 @@ static bool http_should_fail(struct Curl_easy *data, int httpcode)
     return TRUE;
 #endif
 
-  return data->state.authproblem;
+  return (bool)data->state.authproblem;
 }
 
 /*
@@ -806,7 +806,7 @@ Curl_http_output_auth(struct Curl_easy *data,
 #ifndef CURL_DISABLE_PROXY
   /* Send proxy authentication header if needed */
   if(conn->bits.httpproxy &&
-     (conn->bits.tunnel_proxy == (bit)proxytunnel)) {
+     (conn->bits.tunnel_proxy == (curl_bit)proxytunnel)) {
     result = output_auth_headers(data, conn, authproxy, request, path, TRUE);
     if(result)
       return result;
index 302f2feff71fd0ab3e3d3953ff9eb0834b37051e..c4c9825538cc52c276cf78804a2d014e7405894e 100644 (file)
@@ -986,7 +986,8 @@ static CURLcode on_stream_frame(struct Curl_cfilter *cf,
     else
       stream->status_code = -1;
 
-    h2_xfer_write_resp_hd(cf, data, stream, STRCONST("\r\n"), stream->closed);
+    h2_xfer_write_resp_hd(cf, data, stream, STRCONST("\r\n"),
+                          (bool)stream->closed);
 
     if(stream->status_code / 100 != 1) {
       stream->resp_hds_complete = TRUE;
index f78a89e54f5b32340d504527b6a76a0e990fa426..c950346b2d3ac5ad20e18a16608f18592f1514a2 100644 (file)
@@ -228,7 +228,7 @@ static CURLcode httpchunk_readwrite(struct Curl_easy *data,
     case CHUNK_POSTLF:
       if(*buf == 0x0a) {
         /* The last one before we go back to hex state and start all over. */
-        Curl_httpchunk_reset(data, ch, ch->ignore_body);
+        Curl_httpchunk_reset(data, ch, (bool)ch->ignore_body);
       }
       else if(*buf != 0x0d) {
         ch->state = CHUNK_FAILED;
@@ -602,7 +602,7 @@ static CURLcode cr_chunked_read(struct Curl_easy *data,
   CURLcode result = CURLE_READ_ERROR;
 
   *pnread = 0;
-  *peos = ctx->eos;
+  *peos = (bool)ctx->eos;
 
   if(!ctx->eos) {
     if(!ctx->read_eos && Curl_bufq_is_empty(&ctx->chunkbuf)) {
index 1e30d21d9615326480405f796f0038356dcb9089..e9dfb8dbb3bd7a583b8744f4ec1d51589ec58971 100644 (file)
@@ -187,7 +187,7 @@ void Curl_http_proxy_get_destination(struct Curl_cfilter *cf,
   if(*phostname != cf->conn->host.name)
     *pipv6_ip = (strchr(*phostname, ':') != NULL);
   else
-    *pipv6_ip = cf->conn->bits.ipv6_ip;
+    *pipv6_ip = (bool)cf->conn->bits.ipv6_ip;
 }
 
 struct cf_proxy_ctx {
index c28395634c4be3e164a713bc8b4203f8cb6306ae..7eb688074098b2d57e04ca875ba75ddfe3ff8107 100644 (file)
@@ -710,7 +710,8 @@ static CURLcode imap_perform_authentication(struct Curl_easy *data,
   }
 
   /* Calculate the SASL login details */
-  result = Curl_sasl_start(&imapc->sasl, data, imapc->ir_supported, &progress);
+  result = Curl_sasl_start(&imapc->sasl, data, (bool)imapc->ir_supported,
+                           &progress);
 
   if(!result) {
     if(progress == SASL_INPROGRESS)
index de811eddb13b13ae080ff386d81ce9b65ccf6073..4d8177c0667cd66130699527fe65d9682df777d6 100644 (file)
@@ -2037,7 +2037,7 @@ static CURLcode cr_mime_read(struct Curl_easy *data,
     if(ctx->total_len >= 0)
       ctx->seen_eos = (ctx->read_len >= ctx->total_len);
     *pnread = nread;
-    *peos = ctx->seen_eos;
+    *peos = (bool)ctx->seen_eos;
     break;
   }
 
index e0e37f8edd543ea4b2983de6f3dad3b5c5d849bf..594c39aff846e901a84101c6efb10ebe238c6b6a 100644 (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;
index 0ba601d6af704735967db6f9b4357c7847cb38d4..6faad63c97a6c1bbcc67075ee1889b0f285fa380 100644 (file)
@@ -271,9 +271,9 @@ static bool pop3_is_multiline(const char *cmdline)
   for(i = 0; i < CURL_ARRAYSIZE(pop3cmds); ++i) {
     if(curl_strnequal(pop3cmds[i].name, cmdline, pop3cmds[i].nlen)) {
       if(!cmdline[pop3cmds[i].nlen])
-        return pop3cmds[i].multiline;
+        return (bool)pop3cmds[i].multiline;
       else if(cmdline[pop3cmds[i].nlen] == ' ')
-        return pop3cmds[i].multiline_with_args;
+        return (bool)pop3cmds[i].multiline_with_args;
     }
   }
   /* Unknown command, assume multi-line for backward compatibility with
index 7abbde87cc113e7f30dd2c0a61d598224d641b67..1b1fb6ccedc3e04fa5ad3445bdac113830ef71b4 100644 (file)
@@ -189,7 +189,7 @@ bool Curl_rlimit_active(struct Curl_rlimit *r)
 
 bool Curl_rlimit_is_blocked(struct Curl_rlimit *r)
 {
-  return r->blocked;
+  return (bool)r->blocked;
 }
 
 int64_t Curl_rlimit_avail(struct Curl_rlimit *r,
index 2cd62efb4879117fb044df5d89eaa0702ab61457..674b0a4573d9c048fa3c91e27c6f6127032265bf 100644 (file)
@@ -117,7 +117,7 @@ CURLcode Curl_client_start(struct Curl_easy *data)
 
 bool Curl_creader_will_rewind(struct Curl_easy *data)
 {
-  return data->req.rewind_read;
+  return (bool)data->req.rewind_read;
 }
 
 void Curl_creader_set_rewind(struct Curl_easy *data, bool enable)
@@ -727,7 +727,7 @@ static CURLcode cr_in_read(struct Curl_easy *data,
     if(ctx->total_len >= 0)
       ctx->seen_eos = (ctx->read_len >= ctx->total_len);
     *pnread = nread;
-    *peos = ctx->seen_eos;
+    *peos = (bool)ctx->seen_eos;
     break;
   }
   CURL_TRC_READ(data, "cr_in_read(len=%zu, total=%"FMT_OFF_T
@@ -742,7 +742,7 @@ static bool cr_in_needs_rewind(struct Curl_easy *data,
 {
   struct cr_in_ctx *ctx = reader->ctx;
   (void)data;
-  return ctx->has_used_cb;
+  return (bool)ctx->has_used_cb;
 }
 
 static curl_off_t cr_in_total_length(struct Curl_easy *data,
@@ -903,7 +903,7 @@ static bool cr_in_is_paused(struct Curl_easy *data,
 {
   struct cr_in_ctx *ctx = reader->ctx;
   (void)data;
-  return ctx->is_paused;
+  return (bool)ctx->is_paused;
 }
 
 static const struct Curl_crtype cr_in = {
@@ -1013,7 +1013,7 @@ static CURLcode cr_lc_read(struct Curl_easy *data,
       if(ctx->read_eos)
         ctx->eos = TRUE;
       *pnread = nread;
-      *peos = ctx->eos;
+      *peos = (bool)ctx->eos;
       goto out;
     }
 
index 5c376dfce991724a054cd2c5794305ccb19bfc94..70fdba8cc6a00f6300a74761cc07aea4065ab30b 100644 (file)
@@ -431,7 +431,7 @@ static CURLcode cr_eob_read(struct Curl_easy *data,
     CURL_TRC_SMTP(data, "mail body complete, returning EOS");
     ctx->eos = TRUE;
   }
-  *peos = ctx->eos;
+  *peos = (bool)ctx->eos;
   DEBUGF(infof(data, "cr_eob_read(%zu) -> %d, %zd, %d",
          blen, result, *pnread, *peos));
   return result;
index 5ad7d990159e185dafd70808f3736be6e166a20f..35765d7abaa2ccc888b1c3042fabe03e54466a42 100644 (file)
@@ -1308,7 +1308,7 @@ static CURLcode socks_proxy_cf_connect(struct Curl_cfilter *cf,
   cf->connected = TRUE;
 
 out:
-  *done = cf->connected;
+  *done = (bool)cf->connected;
   return result;
 }
 
index 05b0b714d87288369f2e8e64dd655b24a7669342..c8f36450a65fd995ddcea82de6a0b536834bab24 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -1309,8 +1309,8 @@ static bool ConnectionExists(struct Curl_easy *data,
   /* wait_pipe is TRUE if we encounter a bundle that is undecided. There
    * is no matching connection then, yet. */
   *usethis = match.found;
-  *force_reuse = match.force_reuse;
-  *waitpipe = match.wait_pipe;
+  *force_reuse = (bool)match.force_reuse;
+  *waitpipe = (bool)match.wait_pipe;
   return result;
 }
 
@@ -1367,7 +1367,7 @@ static struct connectdata *allocate_conn(struct Curl_easy *data)
   conn->bits.ftp_use_eprt = data->set.ftp_use_eprt;
 #endif
   conn->ip_version = data->set.ipver;
-  conn->connect_only = data->set.connect_only;
+  conn->connect_only = (bool)data->set.connect_only;
   conn->transport_wanted = TRNSPRT_TCP; /* most of them are TCP streams */
 
   /* Store the local bind parameters that will be used for this connection */
@@ -3157,7 +3157,7 @@ static CURLcode resolve_unix(struct Curl_easy *data,
     return CURLE_OUT_OF_MEMORY;
 
   hostaddr->addr = Curl_unix2addr(unix_path, &longpath,
-                                  conn->bits.abstract_unix_socket);
+                                  (bool)conn->bits.abstract_unix_socket);
   if(!hostaddr->addr) {
     if(longpath)
       /* Long paths are not supported for now */
index a7261c7aca929ebebb8fd27a5722dec16b470b7e..04a7385e036b171f0c0499efcb5bbd352d27497d 100644 (file)
@@ -724,8 +724,8 @@ struct connectdata {
   /* HTTP version last responded with by the server or negotiated via ALPN.
    * 0 at start, then one of 09, 10, 11, etc. */
   uint8_t httpversion_seen;
-  uint8_t connect_only;
   uint8_t gssapi_delegation; /* inherited from set.gssapi_delegation */
+  BIT(connect_only);
 };
 
 #ifndef CURL_DISABLE_PROXY
index 1d17d4a832c94c89c641b1597f769a938aa86ee3..57a1543be3504ec48bfa79fe2f913a085b12d395 100644 (file)
@@ -1158,7 +1158,8 @@ static int cb_h3_end_headers(nghttp3_conn *conn, int64_t stream_id,
   if(!stream)
     return 0;
   /* add a CRLF only if we have received some headers */
-  h3_xfer_write_resp_hd(cf, data, stream, STRCONST("\r\n"), stream->closed);
+  h3_xfer_write_resp_hd(cf, data, stream, STRCONST("\r\n"),
+                        (bool)stream->closed);
 
   CURL_TRC_CF(data, cf, "[%" PRId64 "] end_headers, status=%d",
               stream_id, stream->status_code);
index 5e7d6a50fee59e98cf096f33dd8e660c2775dc3b..c88e2b81d956810eb83b4488d3baca81a0f80c54 100644 (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,
index 0751a2db7a82e88fdb59c15add191462b242a4f0..b7793ebdb7a72dfd2386117fc95916d0f5d06312 100644 (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 {
index f11b11f8b984e8e09845960f2a3cbb9bc1e99079..6e336b0b8d812ab16ba0e4bef27a84859b9a35d5 100644 (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;
index dd3c996ceb18cb75859020866c7d620fc59fd62d..d3e004fcf079ac4eac153cca1ed51e30cafd7982 100644 (file)
--- a/lib/ws.c
+++ b/lib/ws.c
@@ -836,14 +836,15 @@ static CURLcode ws_enc_add_frame(struct Curl_easy *data,
     return CURLE_SEND_ERROR;
   }
 
-  result = ws_frame_flags2firstbyte(data, flags, enc->contfragment, &firstb);
+  result = ws_frame_flags2firstbyte(data, flags, (bool)enc->contfragment,
+                                    &firstb);
   if(result)
     return result;
 
   /* fragmentation only applies to data frames (text/binary);
    * control frames (close/ping/pong) do not affect the CONT status */
   if(flags & (CURLWS_TEXT | CURLWS_BINARY)) {
-    enc->contfragment = (flags & CURLWS_CONT) ? (bit)TRUE : (bit)FALSE;
+    enc->contfragment = (curl_bit)((flags & CURLWS_CONT) ? TRUE : FALSE);
   }
 
   if(flags & CURLWS_PING && payload_len > WS_MAX_CNTRL_LEN) {
@@ -1177,7 +1178,7 @@ static CURLcode cr_ws_read(struct Curl_easy *data,
       if(ctx->read_eos)
         ctx->eos = TRUE;
       *pnread = nread;
-      *peos = ctx->eos;
+      *peos = (bool)ctx->eos;
       goto out;
     }
 
index 8d686b6d5875ad34bc99600bc88280bf6c9e61a3..17c7d80b0f3d99b5b53ae949f23edf6f366abcd1 100644 (file)
@@ -244,7 +244,7 @@ size_t tool_write_cb(char *buffer, size_t sz, size_t nmemb, void *userdata)
   struct OutStruct *outs = &per->outs;
   struct OperationConfig *config = per->config;
   size_t bytes = sz * nmemb;
-  bool is_tty = global->isatty;
+  bool is_tty = (bool)global->isatty;
 #ifdef _WIN32
   CONSOLE_SCREEN_BUFFER_INFO console_info;
   intptr_t fhnd;
index 554027734c44917bd1eb261478f1df0734a33969..13ebe83feea79bce9af4f1560815ec96d396e604 100644 (file)
@@ -1166,8 +1166,8 @@ static CURLcode create_single(struct OperationConfig *config,
                               CURLSH *share, struct State *state,
                               bool *added, bool *skipped)
 {
-  const bool orig_isatty = global->isatty;
-  const bool orig_noprogress = global->noprogress;
+  const bool orig_isatty = (bool)global->isatty;
+  const bool orig_noprogress = (bool)global->noprogress;
   CURLcode result = CURLE_OK;
   while(state->urlnode) {
     struct per_transfer *per = NULL;
@@ -2174,8 +2174,8 @@ static CURLcode run_all_transfers(CURLSH *share,
                                   CURLcode result)
 {
   /* Save the values of noprogress and isatty to restore them later on */
-  bool orig_noprogress = global->noprogress;
-  bool orig_isatty = global->isatty;
+  bool orig_noprogress = (bool)global->noprogress;
+  bool orig_isatty = (bool)global->isatty;
   struct per_transfer *per;
 
   /* Time to actually do the transfers */