public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: "Jeff King via GitGitGadget" <gitgitgadget@gmail•com>
To: git@vger•kernel.org
Cc: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail•com>,
	Jeff King <peff@peff•net>,
	Johannes Schindelin <johannes.schindelin@gmx•de>,
	Jeff King <peff@peff•net>
Subject: [PATCH v2 2/4] curl: fix integer variable typechecks with curl_easy_setopt()
Date: Fri, 06 Jun 2025 09:29:22 +0000	[thread overview]
Message-ID: <30325e23ba0d40567cc4ef78e4ba0c3776ef0c06.1749202164.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1931.v2.git.1749202164.gitgitgadget@gmail.com>

From: Jeff King <peff@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>
Signed-off-by: Junio C Hamano <gitster@pobox•com>
---
 imap-send.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/imap-send.c b/imap-send.c
index 27dc033c7f8e..2e812f5a6e9e 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);
 
-- 
gitgitgadget


  parent reply	other threads:[~2025-06-06  9:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-05  8:31 [PATCH] curl: pass `long` values where expected Johannes Schindelin via GitGitGadget
2025-06-05  8:41 ` Kristoffer Haugsbakk
2025-06-05 10:48   ` Johannes Schindelin
2025-06-06  9:29 ` [PATCH v2 0/4] curl: pass long " Johannes Schindelin via GitGitGadget
2025-06-06  9:29   ` [PATCH v2 1/4] curl: fix integer constant typechecks with curl_easy_setopt() Jeff King via GitGitGadget
2025-06-06  9:29   ` Jeff King via GitGitGadget [this message]
2025-06-06  9:29   ` [PATCH v2 3/4] curl: fix symbolic " Jeff King via GitGitGadget
2025-06-06  9:29   ` [PATCH v2 4/4] curl: pass `long` values where expected Johannes Schindelin via GitGitGadget
2025-06-06 10:05     ` Jeff King
2025-06-06 15:38       ` Junio C Hamano
2025-06-06 15:35     ` Junio C Hamano
2025-06-06 14:27   ` [PATCH v2 0/4] curl: pass long " Kristoffer Haugsbakk
2025-06-06 15:43     ` Martin Ågren
2025-06-06 15:51       ` Kristoffer Haugsbakk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=30325e23ba0d40567cc4ef78e4ba0c3776ef0c06.1749202164.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=johannes.schindelin@gmx$(echo .)de \
    --cc=kristofferhaugsbakk@fastmail$(echo .)com \
    --cc=peff@peff$(echo .)net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox