git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] curl: fix integer variable typechecks with curl_easy_setopt()

From
Jeff King <peff@peff.net>
Date
Jun 4, 2025, 20:55 UTC
Message-ID
<20250604205552.GB1510819@coredump.intra.peff.net>
In-Reply-To
<20250604205505.GA1510724@coredump.intra.peff.net>

As discussed in the previous commit, we should be passing long integers, not regular ones, to curl_easy_setopt(), and compiling against curl 8.14 loudly complains if we don't.

That patch fixed integer constants by adding an "L". This one deals with actual variables.

Arguably these variables could just be declared as "long" in the first place. But it's actually kind of awkward due to other code which uses them:

  - port is conceptually a short, and we even call htons() on it (though
    weirdly it is defined as a regular int).
  - ssl_verify is conceptually a bool, and we assign to it from
    git_config_bool().

So I think we could probably switch these out for longs without hurting anything, but it just feels a bit weird. Doubly so because if you don't set USE_CURL_FOR_IMAP_SEND set, then the current types are fine!

So let's just cast these to longs in the curl calls, which makes what's going on obvious. There aren't that many spots to modify (and as you can see from the context, we already have some similar casts).

Signed-off-by: Jeff King <peff@peff.net>
---
 imap-send.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/imap-send.c b/imap-send.c
index 27dc033c7f..2e812f5a6e 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -1420,7 +1420,7 @@ static CURL *setup_curl(struct imap_server_conf *srvc, struct credential *cred)
 
 	curl_easy_setopt(curl, CURLOPT_URL, path.buf);
 	strbuf_release(&path);
-	curl_easy_setopt(curl, CURLOPT_PORT, srvc->port);
+	curl_easy_setopt(curl, CURLOPT_PORT, (long)srvc->port);
 
 	if (srvc->auth_method) {
 		struct strbuf auth = STRBUF_INIT;
@@ -1433,8 +1433,8 @@ static CURL *setup_curl(struct imap_server_conf *srvc, struct credential *cred)
 	if (!srvc->use_ssl)
 		curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_TRY);
 
-	curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, srvc->ssl_verify);
-	curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, srvc->ssl_verify);
+	curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, (long)srvc->ssl_verify);
+	curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, (long)srvc->ssl_verify);
 
 	curl_easy_setopt(curl, CURLOPT_READFUNCTION, fread_buffer);
 
-- 
2.50.0.rc1.276.g7db1193dde
Previous: Jeff KingNext: Jeff King
Message 9 of 16 in “silencing warnings with curl 8.14”
  1. 0/3 silencing warnings with curl 8.14Jeff King, Jun 4, 2025
  2. 1/3 curl: fix integer constant typechecks with curl_easy_setopt()Jeff King, Jun 4, 2025
  3. Johannes SchindelinJun 5, 2025
  4. Junio C HamanoJun 5, 2025
  5. Jeff KingJun 5, 2025
  6. Jeff KingJun 5, 2025
  7. Junio C HamanoJun 5, 2025
  8. Jeff KingJun 5, 2025
  9. 2/3 curl: fix integer variable typechecks with curl_easy_setopt()Jeff King, Jun 4, 2025
  10. 3/3 curl: fix symbolic constant typechecks with curl_easy_setopt()Jeff King, Jun 4, 2025
  11. Junio C HamanoJun 4, 2025
  12. Daniel StenbergJun 5, 2025
  13. Jeff KingJun 5, 2025
  14. Collin FunkJun 4, 2025
  15. Ramsay JonesJun 4, 2025
  16. Patrick SteinhardtJun 5, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.