{"thread":{"id":"63586","subject":"[PATCH] curl: pass `long` values where expected","startedAt":"2025-06-05T08:31:47Z","lastAt":"2025-06-06T15:52:05Z","messageCount":14,"participants":["Johannes Schindelin via GitGitGadget","Kristoffer Haugsbakk","Johannes Schindelin","Jeff King via GitGitGadget","Jeff King","Junio C Hamano","Martin Ågren"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"519740","messageId":"pull.1931.git.1749112304079.gitgitgadget@gmail.com","threadId":"63586","inReplyTo":null,"subject":"[PATCH] curl: pass `long` values where expected","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-06-05T08:31:43Z","receivedAt":"2025-06-05T08:31:47Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nAs of Homebrew's update to cURL v8.14.0, there are new compile errors to\nbe observed in the `osx-gcc` job of Git's CI builds:\n\n  In file included from http.h:8,\n                   from imap-send.c:36:\n  In function 'setup_curl',\n      inlined from 'curl_append_msgs_to_imap' at imap-send.c:1460:9,\n      inlined from 'cmd_main' at imap-send.c:1581:9:\n  /usr/local/Cellar/curl/8.14.0/include/curl/typecheck-gcc.h:50:15: error: call to '_curl_easy_setopt_err_long' declared with attribute warning: curl_easy_setopt expects a long argument [-Werror=attribute-warning]\n     50 |               _curl_easy_setopt_err_long();                             \\\n        |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~\n  /usr/local/Cellar/curl/8.14.0/include/curl/curl.h:54:7: note: in definition of macro 'CURL_IGNORE_DEPRECATION'\n     54 |       statements \\\n        |       ^~~~~~~~~~\n  imap-send.c:1423:9: note: in expansion of macro 'curl_easy_setopt'\n   1423 |         curl_easy_setopt(curl, CURLOPT_PORT, srvc->port);\n        |         ^~~~~~~~~~~~~~~~\n  [... many more instances of nearly identical warnings...]\n\nSee for example this CI workflow run:\nhttps://github.com/git/git/actions/runs/15454602308/job/43504278284#step:4:307\n\nThe most likely explanation is the entry \"typecheck-gcc.h: fix the\ntypechecks\" in cURL's release notes (https://curl.se/ch/8.14.0.html).\n\nLet's explicitly convert all `int` parameters in `curl_easy_setopt()`\ncalls to `long` parameters.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n    curl: pass long values where expected\n    \n    This came up during the release process of Git for Windows v2.50.0-rc1.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-1931%2Fdscho%2Fcurl-options-want-long-instead-of-int-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1931/dscho/curl-options-want-long-instead-of-int-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/1931\n\n http-push.c   |  8 ++++----\n http.c        | 50 +++++++++++++++++++++++++-------------------------\n imap-send.c   |  6 +++---\n remote-curl.c | 12 ++++++------\n 4 files changed, 38 insertions(+), 38 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex f9e67cabd4b..56db9ce8edf 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -195,7 +195,7 @@ static char *xml_entities(const char *s)\n static void curl_setup_http_get(CURL *curl, const char *url,\n \t\tconst char *custom_req)\n {\n-\tcurl_easy_setopt(curl, CURLOPT_HTTPGET, 1);\n+\tcurl_easy_setopt(curl, CURLOPT_HTTPGET, 1l);\n \tcurl_easy_setopt(curl, CURLOPT_URL, url);\n \tcurl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req);\n \tcurl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n@@ -205,7 +205,7 @@ static void curl_setup_http(CURL *curl, const char *url,\n \t\tconst char *custom_req, struct buffer *buffer,\n \t\tcurl_write_callback write_fn)\n {\n-\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1);\n+\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1l);\n \tcurl_easy_setopt(curl, CURLOPT_URL, url);\n \tcurl_easy_setopt(curl, CURLOPT_INFILE, buffer);\n \tcurl_easy_setopt(curl, CURLOPT_INFILESIZE, buffer->buf.len);\n@@ -213,9 +213,9 @@ static void curl_setup_http(CURL *curl, const char *url,\n \tcurl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, seek_buffer);\n \tcurl_easy_setopt(curl, CURLOPT_SEEKDATA, buffer);\n \tcurl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_fn);\n-\tcurl_easy_setopt(curl, CURLOPT_NOBODY, 0);\n+\tcurl_easy_setopt(curl, CURLOPT_NOBODY, 0l);\n \tcurl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req);\n-\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1);\n+\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1l);\n }\n \n static struct curl_slist *get_dav_token_headers(struct remote_lock *lock, enum dav_header_flag options)\ndiff --git a/http.c b/http.c\nindex 3c029cf8947..91ac7a74f26 100644\n--- a/http.c\n+++ b/http.c\n@@ -1019,13 +1019,13 @@ static CURL *get_curl_handle(void)\n \t\tdie(\"curl_easy_init failed\");\n \n \tif (!curl_ssl_verify) {\n-\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 0);\n-\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 0);\n+\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 0l);\n+\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 0l);\n \t} else {\n \t\t/* Verify authenticity of the peer's certificate */\n-\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 1);\n+\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 1l);\n \t\t/* The name in the cert must match whom we tried to connect */\n-\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);\n+\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2l);\n \t}\n \n     if (curl_http_version) {\n@@ -1057,7 +1057,7 @@ static CURL *get_curl_handle(void)\n \n \tif (http_ssl_backend && !strcmp(\"schannel\", http_ssl_backend) &&\n \t    !http_schannel_check_revoke) {\n-\t\tcurl_easy_setopt(result, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NO_REVOKE);\n+\t\tcurl_easy_setopt(result, CURLOPT_SSL_OPTIONS, (long)CURLSSLOPT_NO_REVOKE);\n \t}\n \n \tif (http_proactive_auth != PROACTIVE_AUTH_NONE)\n@@ -1117,8 +1117,8 @@ static CURL *get_curl_handle(void)\n \t\t\t\t curl_low_speed_time);\n \t}\n \n-\tcurl_easy_setopt(result, CURLOPT_MAXREDIRS, 20);\n-\tcurl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);\n+\tcurl_easy_setopt(result, CURLOPT_MAXREDIRS, 20l);\n+\tcurl_easy_setopt(result, CURLOPT_POSTREDIR, (long)CURL_REDIR_POST_ALL);\n \n #ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n \t{\n@@ -1151,7 +1151,7 @@ static CURL *get_curl_handle(void)\n \t\tuser_agent ? user_agent : git_user_agent());\n \n \tif (curl_ftp_no_epsv)\n-\t\tcurl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);\n+\t\tcurl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0l);\n \n \tif (curl_ssl_try)\n \t\tcurl_easy_setopt(result, CURLOPT_USE_SSL, CURLUSESSL_TRY);\n@@ -1193,18 +1193,18 @@ static CURL *get_curl_handle(void)\n \n \t\tif (starts_with(curl_http_proxy, \"socks5h\"))\n \t\t\tcurl_easy_setopt(result,\n-\t\t\t\tCURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME);\n+\t\t\t\tCURLOPT_PROXYTYPE, (long)CURLPROXY_SOCKS5_HOSTNAME);\n \t\telse if (starts_with(curl_http_proxy, \"socks5\"))\n \t\t\tcurl_easy_setopt(result,\n-\t\t\t\tCURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);\n+\t\t\t\tCURLOPT_PROXYTYPE, (long)CURLPROXY_SOCKS5);\n \t\telse if (starts_with(curl_http_proxy, \"socks4a\"))\n \t\t\tcurl_easy_setopt(result,\n-\t\t\t\tCURLOPT_PROXYTYPE, CURLPROXY_SOCKS4A);\n+\t\t\t\tCURLOPT_PROXYTYPE, (long)CURLPROXY_SOCKS4A);\n \t\telse if (starts_with(curl_http_proxy, \"socks\"))\n \t\t\tcurl_easy_setopt(result,\n-\t\t\t\tCURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);\n+\t\t\t\tCURLOPT_PROXYTYPE, (long)CURLPROXY_SOCKS4);\n \t\telse if (starts_with(curl_http_proxy, \"https\")) {\n-\t\t\tcurl_easy_setopt(result, CURLOPT_PROXYTYPE, CURLPROXY_HTTPS);\n+\t\t\tcurl_easy_setopt(result, CURLOPT_PROXYTYPE, (long)CURLPROXY_HTTPS);\n \n \t\t\tif (http_proxy_ssl_cert)\n \t\t\t\tcurl_easy_setopt(result, CURLOPT_PROXY_SSLCERT, http_proxy_ssl_cert);\n@@ -1254,7 +1254,7 @@ static CURL *get_curl_handle(void)\n \t}\n \tinit_curl_proxy_auth(result);\n \n-\tcurl_easy_setopt(result, CURLOPT_TCP_KEEPALIVE, 1);\n+\tcurl_easy_setopt(result, CURLOPT_TCP_KEEPALIVE, 1l);\n \n \tif (curl_tcp_keepidle > -1)\n \t\tcurl_easy_setopt(result, CURLOPT_TCP_KEEPIDLE,\n@@ -1540,9 +1540,9 @@ struct active_request_slot *get_active_slot(void)\n \tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, NULL);\n \tcurl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, NULL);\n \tcurl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, -1L);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 1);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0l);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1l);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 1l);\n \tcurl_easy_setopt(slot->curl, CURLOPT_RANGE, NULL);\n \n \t/*\n@@ -1551,9 +1551,9 @@ struct active_request_slot *get_active_slot(void)\n \t * HTTP_FOLLOW_* cases themselves.\n \t */\n \tif (http_follow_config == HTTP_FOLLOW_ALWAYS)\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1);\n+\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1l);\n \telse\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 0);\n+\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 0l);\n \n \tcurl_easy_setopt(slot->curl, CURLOPT_IPRESOLVE, git_curl_ipresolve);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPAUTH, http_auth_methods);\n@@ -2120,12 +2120,12 @@ static int http_request(const char *url,\n \tint ret;\n \n \tslot = get_active_slot();\n-\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1l);\n \n \tif (!result) {\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1);\n+\t\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1l);\n \t} else {\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);\n+\t\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0l);\n \t\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, result);\n \n \t\tif (target == HTTP_REQUEST_FILE) {\n@@ -2151,7 +2151,7 @@ static int http_request(const char *url,\n \t\tstrbuf_addstr(&buf, \" no-cache\");\n \tif (options && options->initial_request &&\n \t    http_follow_config == HTTP_FOLLOW_INITIAL)\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1);\n+\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1l);\n \n \theaders = curl_slist_append(headers, buf.buf);\n \n@@ -2170,7 +2170,7 @@ static int http_request(const char *url,\n \tcurl_easy_setopt(slot->curl, CURLOPT_URL, url);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers);\n \tcurl_easy_setopt(slot->curl, CURLOPT_ENCODING, \"\");\n-\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0l);\n \n \tret = run_one_slot(slot, &results);\n \n@@ -2750,7 +2750,7 @@ struct http_object_request *new_http_object_request(const char *base_url,\n \tfreq->headers = object_request_headers();\n \n \tcurl_easy_setopt(freq->slot->curl, CURLOPT_WRITEDATA, freq);\n-\tcurl_easy_setopt(freq->slot->curl, CURLOPT_FAILONERROR, 0);\n+\tcurl_easy_setopt(freq->slot->curl, CURLOPT_FAILONERROR, 0l);\n \tcurl_easy_setopt(freq->slot->curl, CURLOPT_WRITEFUNCTION, fwrite_sha1_file);\n \tcurl_easy_setopt(freq->slot->curl, CURLOPT_ERRORBUFFER, freq->errorstr);\n \tcurl_easy_setopt(freq->slot->curl, CURLOPT_URL, freq->url);\ndiff --git a/imap-send.c b/imap-send.c\nindex 27dc033c7f8..2e812f5a6e9 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -1420,7 +1420,7 @@ static CURL *setup_curl(struct imap_server_conf *srvc, struct credential *cred)\n \n \tcurl_easy_setopt(curl, CURLOPT_URL, path.buf);\n \tstrbuf_release(&path);\n-\tcurl_easy_setopt(curl, CURLOPT_PORT, srvc->port);\n+\tcurl_easy_setopt(curl, CURLOPT_PORT, (long)srvc->port);\n \n \tif (srvc->auth_method) {\n \t\tstruct strbuf auth = STRBUF_INIT;\n@@ -1433,8 +1433,8 @@ static CURL *setup_curl(struct imap_server_conf *srvc, struct credential *cred)\n \tif (!srvc->use_ssl)\n \t\tcurl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_TRY);\n \n-\tcurl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, srvc->ssl_verify);\n-\tcurl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, srvc->ssl_verify);\n+\tcurl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, (long)srvc->ssl_verify);\n+\tcurl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, (long)srvc->ssl_verify);\n \n \tcurl_easy_setopt(curl, CURLOPT_READFUNCTION, fread_buffer);\n \ndiff --git a/remote-curl.c b/remote-curl.c\nindex 590b228f67f..0c229e39ae1 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -877,12 +877,12 @@ static int probe_rpc(struct rpc_state *rpc, struct slot_results *results)\n \theaders = curl_slist_append(headers, rpc->hdr_content_type);\n \theaders = curl_slist_append(headers, rpc->hdr_accept);\n \n-\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_POST, 1);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0l);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_POST, 1l);\n \tcurl_easy_setopt(slot->curl, CURLOPT_URL, rpc->service_url);\n \tcurl_easy_setopt(slot->curl, CURLOPT_ENCODING, NULL);\n \tcurl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, \"0000\");\n-\tcurl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, 4);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, 4l);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers);\n \tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);\n \tcurl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, &buf);\n@@ -970,8 +970,8 @@ retry:\n \n \tslot = get_active_slot();\n \n-\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_POST, 1);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0l);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_POST, 1l);\n \tcurl_easy_setopt(slot->curl, CURLOPT_URL, rpc->service_url);\n \tcurl_easy_setopt(slot->curl, CURLOPT_ENCODING, \"\");\n \n@@ -1058,7 +1058,7 @@ retry:\n \trpc_in_data.check_pktline = stateless_connect;\n \tmemset(&rpc_in_data.pktline_state, 0, sizeof(rpc_in_data.pktline_state));\n \tcurl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, &rpc_in_data);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0l);\n \n \n \trpc->any_written = 0;\n\nbase-commit: 0d42fbd9a1f30c63cf0359a1c5aaa77020972f72\n-- \ngitgitgadget\n"},{"id":"519742","messageId":"b6e10e5d-45e4-45dd-83f9-d889eacd3034@app.fastmail.com","threadId":"63586","inReplyTo":"pull.1931.git.1749112304079.gitgitgadget@gmail.com","subject":"Re: [PATCH] curl: pass `long` values where expected","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2025-06-05T08:41:24Z","receivedAt":"2025-06-05T08:42:01Z","isPatch":true,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Thu, Jun 5, 2025, at 10:31, Johannes Schindelin via GitGitGadget wrote:\n> From: Johannes Schindelin <johannes.schindelin@gmx.de>\n>\n> As of Homebrew's update to cURL v8.14.0, there are new compile errors to\n> be observed in the `osx-gcc` job of Git's CI builds:\n\nThis overlaps with King’s https://lore.kernel.org/git/20250604205505.GA1510724@coredump.intra.peff.net/\n"},{"id":"519761","messageId":"e7475f63-35a4-16b2-71c3-45c9ff58fbd5@gmx.de","threadId":"63586","inReplyTo":"b6e10e5d-45e4-45dd-83f9-d889eacd3034@app.fastmail.com","subject":"Re: [PATCH] curl: pass `long` values where expected","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2025-06-05T10:48:12Z","receivedAt":"2025-06-05T10:48:19Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Kristoffer,\n\nOn Thu, 5 Jun 2025, Kristoffer Haugsbakk wrote:\n\n> On Thu, Jun 5, 2025, at 10:31, Johannes Schindelin via GitGitGadget wrote:\n> > From: Johannes Schindelin <johannes.schindelin@gmx.de>\n> >\n> > As of Homebrew's update to cURL v8.14.0, there are new compile errors to\n> > be observed in the `osx-gcc` job of Git's CI builds:\n> \n> This overlaps with King’s https://lore.kernel.org/git/20250604205505.GA1510724@coredump.intra.peff.net/\n\nThank you for the heads-up! When I had to start fixing those builds, I had\na quick look but did not find any report on the Git mailing list. But I\nsee gaps, and I will comment on Jeff's patch.\n\nThanks!\nJohannes\n"},{"id":"519833","messageId":"pull.1931.v2.git.1749202164.gitgitgadget@gmail.com","threadId":"63586","inReplyTo":"pull.1931.git.1749112304079.gitgitgadget@gmail.com","subject":"[PATCH v2 0/4] curl: pass long values where expected","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-06-06T09:29:20Z","receivedAt":"2025-06-06T09:29:28Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"This came up during the release process of Git for Windows v2.50.0-rc1.\n\nChanges since v1:\n\n * Rebased on top of jk/curl-easy-setopt-typefix.\n\nJeff King (3):\n  curl: fix integer constant typechecks with curl_easy_setopt()\n  curl: fix integer variable typechecks with curl_easy_setopt()\n  curl: fix symbolic constant typechecks with curl_easy_setopt()\n\nJohannes Schindelin (1):\n  curl: pass `long` values where expected\n\n http-push.c   |  8 ++++----\n http.c        | 50 +++++++++++++++++++++++++-------------------------\n imap-send.c   |  6 +++---\n remote-curl.c | 12 ++++++------\n 4 files changed, 38 insertions(+), 38 deletions(-)\n\n\nbase-commit: 0bd2d791cc9f745ebaedafc0e1cbebdebe41343e\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-1931%2Fdscho%2Fcurl-options-want-long-instead-of-int-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1931/dscho/curl-options-want-long-instead-of-int-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/1931\n\nRange-diff vs v1:\n\n -:  ----------- > 1:  6f11c42e8ed curl: fix integer constant typechecks with curl_easy_setopt()\n -:  ----------- > 2:  30325e23ba0 curl: fix integer variable typechecks with curl_easy_setopt()\n -:  ----------- > 3:  4558c8f84b2 curl: fix symbolic constant typechecks with curl_easy_setopt()\n 1:  803e235837e ! 4:  80de7491d24 curl: pass `long` values where expected\n     @@ Commit message\n          The most likely explanation is the entry \"typecheck-gcc.h: fix the\n          typechecks\" in cURL's release notes (https://curl.se/ch/8.14.0.html).\n      \n     -    Let's explicitly convert all `int` parameters in `curl_easy_setopt()`\n     -    calls to `long` parameters.\n     +    Nearly identical compile errors afflicted recently-updated Debian\n     +    setups, which have been addressed by `jk/curl-easy-setopt-typefix`.\n     +\n     +    However, on macOS Git is built with different build options, which\n     +    uncovered more instances of `int` values that need to be cast to\n     +    constants, which were not covered by 6f11c42e8edc (curl: fix integer\n     +    constant typechecks with curl_easy_setopt(), 2025-06-04). Let's\n     +    explicitly convert even those remaining `int` constants in\n     +    `curl_easy_setopt()` calls to `long` parameters.\n     +\n     +    In addition to looking at the compile errors of the `osx-gcc` job, I\n     +    verified that there are no other instances of the same issue that need\n     +    to be handled in this manner (and that might not be caught by our CI\n     +    builds because of yet other build options that might skip those code\n     +    parts), I ran the following command and inspected all 23 results\n     +    manually to ensure that the fix is now actually complete:\n     +\n     +      git grep -n curl_easy_setopt |\n     +      grep -ve ',.*, *[A-Za-z_\"&]' \\\n     +        -e ',.*, *[-0-9]*L)' \\\n     +        -e ',.*,.* (long)'\n      \n          Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n      \n       ## http-push.c ##\n     -@@ http-push.c: static char *xml_entities(const char *s)\n     - static void curl_setup_http_get(CURL *curl, const char *url,\n     - \t\tconst char *custom_req)\n     - {\n     --\tcurl_easy_setopt(curl, CURLOPT_HTTPGET, 1);\n     -+\tcurl_easy_setopt(curl, CURLOPT_HTTPGET, 1l);\n     - \tcurl_easy_setopt(curl, CURLOPT_URL, url);\n     - \tcurl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req);\n     - \tcurl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n      @@ http-push.c: static void curl_setup_http(CURL *curl, const char *url,\n       \t\tconst char *custom_req, struct buffer *buffer,\n       \t\tcurl_write_callback write_fn)\n       {\n      -\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1);\n     -+\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1l);\n     ++\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);\n       \tcurl_easy_setopt(curl, CURLOPT_URL, url);\n       \tcurl_easy_setopt(curl, CURLOPT_INFILE, buffer);\n       \tcurl_easy_setopt(curl, CURLOPT_INFILESIZE, buffer->buf.len);\n     @@ http-push.c: static void curl_setup_http(CURL *curl, const char *url,\n       \tcurl_easy_setopt(curl, CURLOPT_SEEKDATA, buffer);\n       \tcurl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_fn);\n      -\tcurl_easy_setopt(curl, CURLOPT_NOBODY, 0);\n     -+\tcurl_easy_setopt(curl, CURLOPT_NOBODY, 0l);\n     ++\tcurl_easy_setopt(curl, CURLOPT_NOBODY, 0L);\n       \tcurl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req);\n      -\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1);\n     -+\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1l);\n     ++\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);\n       }\n       \n       static struct curl_slist *get_dav_token_headers(struct remote_lock *lock, enum dav_header_flag options)\n      \n       ## http.c ##\n     -@@ http.c: static CURL *get_curl_handle(void)\n     - \t\tdie(\"curl_easy_init failed\");\n     - \n     - \tif (!curl_ssl_verify) {\n     --\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 0);\n     --\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 0);\n     -+\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 0l);\n     -+\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 0l);\n     - \t} else {\n     - \t\t/* Verify authenticity of the peer's certificate */\n     --\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 1);\n     -+\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 1l);\n     - \t\t/* The name in the cert must match whom we tried to connect */\n     --\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);\n     -+\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2l);\n     - \t}\n     - \n     -     if (curl_http_version) {\n     -@@ http.c: static CURL *get_curl_handle(void)\n     - \n     - \tif (http_ssl_backend && !strcmp(\"schannel\", http_ssl_backend) &&\n     - \t    !http_schannel_check_revoke) {\n     --\t\tcurl_easy_setopt(result, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NO_REVOKE);\n     -+\t\tcurl_easy_setopt(result, CURLOPT_SSL_OPTIONS, (long)CURLSSLOPT_NO_REVOKE);\n     - \t}\n     - \n     - \tif (http_proactive_auth != PROACTIVE_AUTH_NONE)\n     -@@ http.c: static CURL *get_curl_handle(void)\n     - \t\t\t\t curl_low_speed_time);\n     - \t}\n     - \n     --\tcurl_easy_setopt(result, CURLOPT_MAXREDIRS, 20);\n     --\tcurl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);\n     -+\tcurl_easy_setopt(result, CURLOPT_MAXREDIRS, 20l);\n     -+\tcurl_easy_setopt(result, CURLOPT_POSTREDIR, (long)CURL_REDIR_POST_ALL);\n     - \n     - #ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n     - \t{\n     -@@ http.c: static CURL *get_curl_handle(void)\n     - \t\tuser_agent ? user_agent : git_user_agent());\n     - \n     - \tif (curl_ftp_no_epsv)\n     --\t\tcurl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);\n     -+\t\tcurl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0l);\n     - \n     - \tif (curl_ssl_try)\n     - \t\tcurl_easy_setopt(result, CURLOPT_USE_SSL, CURLUSESSL_TRY);\n     -@@ http.c: static CURL *get_curl_handle(void)\n     - \n     - \t\tif (starts_with(curl_http_proxy, \"socks5h\"))\n     - \t\t\tcurl_easy_setopt(result,\n     --\t\t\t\tCURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME);\n     -+\t\t\t\tCURLOPT_PROXYTYPE, (long)CURLPROXY_SOCKS5_HOSTNAME);\n     - \t\telse if (starts_with(curl_http_proxy, \"socks5\"))\n     - \t\t\tcurl_easy_setopt(result,\n     --\t\t\t\tCURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);\n     -+\t\t\t\tCURLOPT_PROXYTYPE, (long)CURLPROXY_SOCKS5);\n     - \t\telse if (starts_with(curl_http_proxy, \"socks4a\"))\n     - \t\t\tcurl_easy_setopt(result,\n     --\t\t\t\tCURLOPT_PROXYTYPE, CURLPROXY_SOCKS4A);\n     -+\t\t\t\tCURLOPT_PROXYTYPE, (long)CURLPROXY_SOCKS4A);\n     - \t\telse if (starts_with(curl_http_proxy, \"socks\"))\n     - \t\t\tcurl_easy_setopt(result,\n     --\t\t\t\tCURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);\n     -+\t\t\t\tCURLOPT_PROXYTYPE, (long)CURLPROXY_SOCKS4);\n     - \t\telse if (starts_with(curl_http_proxy, \"https\")) {\n     --\t\t\tcurl_easy_setopt(result, CURLOPT_PROXYTYPE, CURLPROXY_HTTPS);\n     -+\t\t\tcurl_easy_setopt(result, CURLOPT_PROXYTYPE, (long)CURLPROXY_HTTPS);\n     - \n     - \t\t\tif (http_proxy_ssl_cert)\n     - \t\t\t\tcurl_easy_setopt(result, CURLOPT_PROXY_SSLCERT, http_proxy_ssl_cert);\n     -@@ http.c: static CURL *get_curl_handle(void)\n     - \t}\n     - \tinit_curl_proxy_auth(result);\n     - \n     --\tcurl_easy_setopt(result, CURLOPT_TCP_KEEPALIVE, 1);\n     -+\tcurl_easy_setopt(result, CURLOPT_TCP_KEEPALIVE, 1l);\n     - \n     - \tif (curl_tcp_keepidle > -1)\n     - \t\tcurl_easy_setopt(result, CURLOPT_TCP_KEEPIDLE,\n      @@ http.c: struct active_request_slot *get_active_slot(void)\n       \tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, NULL);\n       \tcurl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, NULL);\n     @@ http.c: struct active_request_slot *get_active_slot(void)\n      -\tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0);\n      -\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);\n      -\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 1);\n     -+\tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0l);\n     -+\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1l);\n     -+\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 1l);\n     ++\tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0L);\n     ++\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1L);\n     ++\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 1L);\n       \tcurl_easy_setopt(slot->curl, CURLOPT_RANGE, NULL);\n       \n       \t/*\n     @@ http.c: struct active_request_slot *get_active_slot(void)\n       \t */\n       \tif (http_follow_config == HTTP_FOLLOW_ALWAYS)\n      -\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1);\n     -+\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1l);\n     ++\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1L);\n       \telse\n      -\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 0);\n     -+\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 0l);\n     ++\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 0L);\n       \n       \tcurl_easy_setopt(slot->curl, CURLOPT_IPRESOLVE, git_curl_ipresolve);\n       \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPAUTH, http_auth_methods);\n     @@ http.c: static int http_request(const char *url,\n       \n       \tslot = get_active_slot();\n      -\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);\n     -+\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1l);\n     ++\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1L);\n       \n       \tif (!result) {\n      -\t\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1);\n     -+\t\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1l);\n     ++\t\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1L);\n       \t} else {\n      -\t\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);\n     -+\t\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0l);\n     ++\t\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0L);\n       \t\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, result);\n       \n       \t\tif (target == HTTP_REQUEST_FILE) {\n     @@ http.c: static int http_request(const char *url,\n       \tif (options && options->initial_request &&\n       \t    http_follow_config == HTTP_FOLLOW_INITIAL)\n      -\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1);\n     -+\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1l);\n     ++\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1L);\n       \n       \theaders = curl_slist_append(headers, buf.buf);\n       \n     @@ http.c: static int http_request(const char *url,\n       \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers);\n       \tcurl_easy_setopt(slot->curl, CURLOPT_ENCODING, \"\");\n      -\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0);\n     -+\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0l);\n     ++\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0L);\n       \n       \tret = run_one_slot(slot, &results);\n       \n     @@ http.c: struct http_object_request *new_http_object_request(const char *base_url\n       \n       \tcurl_easy_setopt(freq->slot->curl, CURLOPT_WRITEDATA, freq);\n      -\tcurl_easy_setopt(freq->slot->curl, CURLOPT_FAILONERROR, 0);\n     -+\tcurl_easy_setopt(freq->slot->curl, CURLOPT_FAILONERROR, 0l);\n     ++\tcurl_easy_setopt(freq->slot->curl, CURLOPT_FAILONERROR, 0L);\n       \tcurl_easy_setopt(freq->slot->curl, CURLOPT_WRITEFUNCTION, fwrite_sha1_file);\n       \tcurl_easy_setopt(freq->slot->curl, CURLOPT_ERRORBUFFER, freq->errorstr);\n       \tcurl_easy_setopt(freq->slot->curl, CURLOPT_URL, freq->url);\n      \n     - ## imap-send.c ##\n     -@@ imap-send.c: static CURL *setup_curl(struct imap_server_conf *srvc, struct credential *cred)\n     - \n     - \tcurl_easy_setopt(curl, CURLOPT_URL, path.buf);\n     - \tstrbuf_release(&path);\n     --\tcurl_easy_setopt(curl, CURLOPT_PORT, srvc->port);\n     -+\tcurl_easy_setopt(curl, CURLOPT_PORT, (long)srvc->port);\n     - \n     - \tif (srvc->auth_method) {\n     - \t\tstruct strbuf auth = STRBUF_INIT;\n     -@@ imap-send.c: static CURL *setup_curl(struct imap_server_conf *srvc, struct credential *cred)\n     - \tif (!srvc->use_ssl)\n     - \t\tcurl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_TRY);\n     - \n     --\tcurl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, srvc->ssl_verify);\n     --\tcurl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, srvc->ssl_verify);\n     -+\tcurl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, (long)srvc->ssl_verify);\n     -+\tcurl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, (long)srvc->ssl_verify);\n     - \n     - \tcurl_easy_setopt(curl, CURLOPT_READFUNCTION, fread_buffer);\n     - \n     -\n       ## remote-curl.c ##\n     -@@ remote-curl.c: static int probe_rpc(struct rpc_state *rpc, struct slot_results *results)\n     - \theaders = curl_slist_append(headers, rpc->hdr_content_type);\n     - \theaders = curl_slist_append(headers, rpc->hdr_accept);\n     - \n     --\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);\n     --\tcurl_easy_setopt(slot->curl, CURLOPT_POST, 1);\n     -+\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0l);\n     -+\tcurl_easy_setopt(slot->curl, CURLOPT_POST, 1l);\n     - \tcurl_easy_setopt(slot->curl, CURLOPT_URL, rpc->service_url);\n     - \tcurl_easy_setopt(slot->curl, CURLOPT_ENCODING, NULL);\n     - \tcurl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, \"0000\");\n     --\tcurl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, 4);\n     -+\tcurl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, 4l);\n     - \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers);\n     - \tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);\n     - \tcurl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, &buf);\n      @@ remote-curl.c: retry:\n       \n       \tslot = get_active_slot();\n       \n      -\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);\n      -\tcurl_easy_setopt(slot->curl, CURLOPT_POST, 1);\n     -+\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0l);\n     -+\tcurl_easy_setopt(slot->curl, CURLOPT_POST, 1l);\n     ++\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0L);\n     ++\tcurl_easy_setopt(slot->curl, CURLOPT_POST, 1L);\n       \tcurl_easy_setopt(slot->curl, CURLOPT_URL, rpc->service_url);\n       \tcurl_easy_setopt(slot->curl, CURLOPT_ENCODING, \"\");\n       \n     @@ remote-curl.c: retry:\n       \tmemset(&rpc_in_data.pktline_state, 0, sizeof(rpc_in_data.pktline_state));\n       \tcurl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, &rpc_in_data);\n      -\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0);\n     -+\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0l);\n     ++\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0L);\n       \n       \n       \trpc->any_written = 0;\n\n-- \ngitgitgadget\n"},{"id":"519834","messageId":"6f11c42e8edc5cf7d65156c9dd68e720f1b92229.1749202164.git.gitgitgadget@gmail.com","threadId":"63586","inReplyTo":"pull.1931.v2.git.1749202164.gitgitgadget@gmail.com","subject":"[PATCH v2 1/4] curl: fix integer constant typechecks with curl_easy_setopt()","fromName":"Jeff King via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-06-06T09:29:21Z","receivedAt":"2025-06-06T09:29:29Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"From: Jeff King <peff@peff.net>\n\nThe curl documentation specifies that curl_easy_setopt() takes either:\n\n  ...a long, a function pointer, an object pointer or a curl_off_t,\n  depending on what the specific option expects.\n\nBut when we pass an integer constant like \"0\", it will by default be a\nregular non-long int. This has always been wrong, but seemed to work in\npractice (I didn't dig into curl's implementation to see whether this\nmight actually be triggering undefined behavior, but it seems likely and\nregardless we should do what the docs say).\n\nThis is especially important since curl has a type-checking macro that\ncauses building against curl 8.14 to produce many warnings. The specific\ncommit is due to their 79b4e56b3 (typecheck-gcc.h: fix the typechecks,\n2025-04-22). Curiously, it does only seem to trigger when compiled with\n-O2 for me.\n\nWe can fix it by just marking the constants with a long \"L\".\n\nSigned-off-by: Jeff King <peff@peff.net>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n http-push.c   |  2 +-\n http.c        | 14 +++++++-------\n remote-curl.c |  6 +++---\n 3 files changed, 11 insertions(+), 11 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex f9e67cabd4be..591e46ab260d 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -195,7 +195,7 @@ static char *xml_entities(const char *s)\n static void curl_setup_http_get(CURL *curl, const char *url,\n \t\tconst char *custom_req)\n {\n-\tcurl_easy_setopt(curl, CURLOPT_HTTPGET, 1);\n+\tcurl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);\n \tcurl_easy_setopt(curl, CURLOPT_URL, url);\n \tcurl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req);\n \tcurl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite_null);\ndiff --git a/http.c b/http.c\nindex 3c029cf8947d..cce2ea728736 100644\n--- a/http.c\n+++ b/http.c\n@@ -1019,13 +1019,13 @@ static CURL *get_curl_handle(void)\n \t\tdie(\"curl_easy_init failed\");\n \n \tif (!curl_ssl_verify) {\n-\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 0);\n-\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 0);\n+\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 0L);\n+\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 0L);\n \t} else {\n \t\t/* Verify authenticity of the peer's certificate */\n-\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 1);\n+\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 1L);\n \t\t/* The name in the cert must match whom we tried to connect */\n-\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);\n+\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2L);\n \t}\n \n     if (curl_http_version) {\n@@ -1117,7 +1117,7 @@ static CURL *get_curl_handle(void)\n \t\t\t\t curl_low_speed_time);\n \t}\n \n-\tcurl_easy_setopt(result, CURLOPT_MAXREDIRS, 20);\n+\tcurl_easy_setopt(result, CURLOPT_MAXREDIRS, 20L);\n \tcurl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);\n \n #ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n@@ -1151,7 +1151,7 @@ static CURL *get_curl_handle(void)\n \t\tuser_agent ? user_agent : git_user_agent());\n \n \tif (curl_ftp_no_epsv)\n-\t\tcurl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);\n+\t\tcurl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0L);\n \n \tif (curl_ssl_try)\n \t\tcurl_easy_setopt(result, CURLOPT_USE_SSL, CURLUSESSL_TRY);\n@@ -1254,7 +1254,7 @@ static CURL *get_curl_handle(void)\n \t}\n \tinit_curl_proxy_auth(result);\n \n-\tcurl_easy_setopt(result, CURLOPT_TCP_KEEPALIVE, 1);\n+\tcurl_easy_setopt(result, CURLOPT_TCP_KEEPALIVE, 1L);\n \n \tif (curl_tcp_keepidle > -1)\n \t\tcurl_easy_setopt(result, CURLOPT_TCP_KEEPIDLE,\ndiff --git a/remote-curl.c b/remote-curl.c\nindex 590b228f67fc..6183772191f2 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -877,12 +877,12 @@ static int probe_rpc(struct rpc_state *rpc, struct slot_results *results)\n \theaders = curl_slist_append(headers, rpc->hdr_content_type);\n \theaders = curl_slist_append(headers, rpc->hdr_accept);\n \n-\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_POST, 1);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0L);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_POST, 1L);\n \tcurl_easy_setopt(slot->curl, CURLOPT_URL, rpc->service_url);\n \tcurl_easy_setopt(slot->curl, CURLOPT_ENCODING, NULL);\n \tcurl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, \"0000\");\n-\tcurl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, 4);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, 4L);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers);\n \tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);\n \tcurl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, &buf);\n-- \ngitgitgadget\n\n"},{"id":"519835","messageId":"30325e23ba0d40567cc4ef78e4ba0c3776ef0c06.1749202164.git.gitgitgadget@gmail.com","threadId":"63586","inReplyTo":"pull.1931.v2.git.1749202164.gitgitgadget@gmail.com","subject":"[PATCH v2 2/4] curl: fix integer variable typechecks with curl_easy_setopt()","fromName":"Jeff King via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-06-06T09:29:22Z","receivedAt":"2025-06-06T09:29:29Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"From: Jeff King <peff@peff.net>\n\nAs discussed in the previous commit, we should be passing long integers,\nnot regular ones, to curl_easy_setopt(), and compiling against curl 8.14\nloudly complains if we don't.\n\nThat patch fixed integer constants by adding an \"L\". This one deals with\nactual variables.\n\nArguably these variables could just be declared as \"long\" in the first\nplace. But it's actually kind of awkward due to other code which uses\nthem:\n\n  - port is conceptually a short, and we even call htons() on it (though\n    weirdly it is defined as a regular int).\n\n  - ssl_verify is conceptually a bool, and we assign to it from\n    git_config_bool().\n\nSo I think we could probably switch these out for longs without hurting\nanything, but it just feels a bit weird. Doubly so because if you don't\nset USE_CURL_FOR_IMAP_SEND set, then the current types are fine!\n\nSo let's just cast these to longs in the curl calls, which makes what's\ngoing on obvious. There aren't that many spots to modify (and as you can\nsee from the context, we already have some similar casts).\n\nSigned-off-by: Jeff King <peff@peff.net>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n imap-send.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/imap-send.c b/imap-send.c\nindex 27dc033c7f8e..2e812f5a6e9e 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -1420,7 +1420,7 @@ static CURL *setup_curl(struct imap_server_conf *srvc, struct credential *cred)\n \n \tcurl_easy_setopt(curl, CURLOPT_URL, path.buf);\n \tstrbuf_release(&path);\n-\tcurl_easy_setopt(curl, CURLOPT_PORT, srvc->port);\n+\tcurl_easy_setopt(curl, CURLOPT_PORT, (long)srvc->port);\n \n \tif (srvc->auth_method) {\n \t\tstruct strbuf auth = STRBUF_INIT;\n@@ -1433,8 +1433,8 @@ static CURL *setup_curl(struct imap_server_conf *srvc, struct credential *cred)\n \tif (!srvc->use_ssl)\n \t\tcurl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_TRY);\n \n-\tcurl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, srvc->ssl_verify);\n-\tcurl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, srvc->ssl_verify);\n+\tcurl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, (long)srvc->ssl_verify);\n+\tcurl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, (long)srvc->ssl_verify);\n \n \tcurl_easy_setopt(curl, CURLOPT_READFUNCTION, fread_buffer);\n \n-- \ngitgitgadget\n\n"},{"id":"519836","messageId":"4558c8f84b2f8d3ba1483727bcb49935ae8ff595.1749202164.git.gitgitgadget@gmail.com","threadId":"63586","inReplyTo":"pull.1931.v2.git.1749202164.gitgitgadget@gmail.com","subject":"[PATCH v2 3/4] curl: fix symbolic constant typechecks with curl_easy_setopt()","fromName":"Jeff King via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-06-06T09:29:23Z","receivedAt":"2025-06-06T09:29:30Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"From: Jeff King <peff@peff.net>\n\nAs with the previous two commits, we should be passing long integers,\nnot regular ones, to curl_easy_setopt(), and compiling against curl 8.14\nloudly complains if we don't.\n\nThis patch catches the remaining cases, which are ones where we pass\ncurl's own symbolic constants. We'll cast them to long manually in each\ncall.\n\nIt seems kind of weird to me that curl doesn't define these constants as\nlongs, since the point of them is to pass to curl_easy_setopt(). But in\nthe curl documentation and examples, they clearly show casting them as\npart of the setopt calls. It may be that there is some reason not to\npush the type into the macro, like backwards compatibility. I didn't\ndig, as it doesn't really matter: we have to follow what existing curl\nversions ask for anyway.\n\nSigned-off-by: Jeff King <peff@peff.net>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n http.c | 14 +++++++-------\n 1 file changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex cce2ea728736..ecbc47ea4b3f 100644\n--- a/http.c\n+++ b/http.c\n@@ -1057,7 +1057,7 @@ static CURL *get_curl_handle(void)\n \n \tif (http_ssl_backend && !strcmp(\"schannel\", http_ssl_backend) &&\n \t    !http_schannel_check_revoke) {\n-\t\tcurl_easy_setopt(result, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NO_REVOKE);\n+\t\tcurl_easy_setopt(result, CURLOPT_SSL_OPTIONS, (long)CURLSSLOPT_NO_REVOKE);\n \t}\n \n \tif (http_proactive_auth != PROACTIVE_AUTH_NONE)\n@@ -1118,7 +1118,7 @@ static CURL *get_curl_handle(void)\n \t}\n \n \tcurl_easy_setopt(result, CURLOPT_MAXREDIRS, 20L);\n-\tcurl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);\n+\tcurl_easy_setopt(result, CURLOPT_POSTREDIR, (long)CURL_REDIR_POST_ALL);\n \n #ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR\n \t{\n@@ -1193,18 +1193,18 @@ static CURL *get_curl_handle(void)\n \n \t\tif (starts_with(curl_http_proxy, \"socks5h\"))\n \t\t\tcurl_easy_setopt(result,\n-\t\t\t\tCURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME);\n+\t\t\t\tCURLOPT_PROXYTYPE, (long)CURLPROXY_SOCKS5_HOSTNAME);\n \t\telse if (starts_with(curl_http_proxy, \"socks5\"))\n \t\t\tcurl_easy_setopt(result,\n-\t\t\t\tCURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);\n+\t\t\t\tCURLOPT_PROXYTYPE, (long)CURLPROXY_SOCKS5);\n \t\telse if (starts_with(curl_http_proxy, \"socks4a\"))\n \t\t\tcurl_easy_setopt(result,\n-\t\t\t\tCURLOPT_PROXYTYPE, CURLPROXY_SOCKS4A);\n+\t\t\t\tCURLOPT_PROXYTYPE, (long)CURLPROXY_SOCKS4A);\n \t\telse if (starts_with(curl_http_proxy, \"socks\"))\n \t\t\tcurl_easy_setopt(result,\n-\t\t\t\tCURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);\n+\t\t\t\tCURLOPT_PROXYTYPE, (long)CURLPROXY_SOCKS4);\n \t\telse if (starts_with(curl_http_proxy, \"https\")) {\n-\t\t\tcurl_easy_setopt(result, CURLOPT_PROXYTYPE, CURLPROXY_HTTPS);\n+\t\t\tcurl_easy_setopt(result, CURLOPT_PROXYTYPE, (long)CURLPROXY_HTTPS);\n \n \t\t\tif (http_proxy_ssl_cert)\n \t\t\t\tcurl_easy_setopt(result, CURLOPT_PROXY_SSLCERT, http_proxy_ssl_cert);\n-- \ngitgitgadget\n\n"},{"id":"519837","messageId":"80de7491d24fb51c6b2c3b2fc1728db30e2477f7.1749202164.git.gitgitgadget@gmail.com","threadId":"63586","inReplyTo":"pull.1931.v2.git.1749202164.gitgitgadget@gmail.com","subject":"[PATCH v2 4/4] curl: pass `long` values where expected","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-06-06T09:29:24Z","receivedAt":"2025-06-06T09:29:31Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nAs of Homebrew's update to cURL v8.14.0, there are new compile errors to\nbe observed in the `osx-gcc` job of Git's CI builds:\n\n  In file included from http.h:8,\n                   from imap-send.c:36:\n  In function 'setup_curl',\n      inlined from 'curl_append_msgs_to_imap' at imap-send.c:1460:9,\n      inlined from 'cmd_main' at imap-send.c:1581:9:\n  /usr/local/Cellar/curl/8.14.0/include/curl/typecheck-gcc.h:50:15: error: call to '_curl_easy_setopt_err_long' declared with attribute warning: curl_easy_setopt expects a long argument [-Werror=attribute-warning]\n     50 |               _curl_easy_setopt_err_long();                             \\\n        |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~\n  /usr/local/Cellar/curl/8.14.0/include/curl/curl.h:54:7: note: in definition of macro 'CURL_IGNORE_DEPRECATION'\n     54 |       statements \\\n        |       ^~~~~~~~~~\n  imap-send.c:1423:9: note: in expansion of macro 'curl_easy_setopt'\n   1423 |         curl_easy_setopt(curl, CURLOPT_PORT, srvc->port);\n        |         ^~~~~~~~~~~~~~~~\n  [... many more instances of nearly identical warnings...]\n\nSee for example this CI workflow run:\nhttps://github.com/git/git/actions/runs/15454602308/job/43504278284#step:4:307\n\nThe most likely explanation is the entry \"typecheck-gcc.h: fix the\ntypechecks\" in cURL's release notes (https://curl.se/ch/8.14.0.html).\n\nNearly identical compile errors afflicted recently-updated Debian\nsetups, which have been addressed by `jk/curl-easy-setopt-typefix`.\n\nHowever, on macOS Git is built with different build options, which\nuncovered more instances of `int` values that need to be cast to\nconstants, which were not covered by 6f11c42e8edc (curl: fix integer\nconstant typechecks with curl_easy_setopt(), 2025-06-04). Let's\nexplicitly convert even those remaining `int` constants in\n`curl_easy_setopt()` calls to `long` parameters.\n\nIn addition to looking at the compile errors of the `osx-gcc` job, I\nverified that there are no other instances of the same issue that need\nto be handled in this manner (and that might not be caught by our CI\nbuilds because of yet other build options that might skip those code\nparts), I ran the following command and inspected all 23 results\nmanually to ensure that the fix is now actually complete:\n\n  git grep -n curl_easy_setopt |\n  grep -ve ',.*, *[A-Za-z_\"&]' \\\n    -e ',.*, *[-0-9]*L)' \\\n    -e ',.*,.* (long)'\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n http-push.c   |  6 +++---\n http.c        | 22 +++++++++++-----------\n remote-curl.c |  6 +++---\n 3 files changed, 17 insertions(+), 17 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex 591e46ab260d..f5a92529a840 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -205,7 +205,7 @@ static void curl_setup_http(CURL *curl, const char *url,\n \t\tconst char *custom_req, struct buffer *buffer,\n \t\tcurl_write_callback write_fn)\n {\n-\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1);\n+\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);\n \tcurl_easy_setopt(curl, CURLOPT_URL, url);\n \tcurl_easy_setopt(curl, CURLOPT_INFILE, buffer);\n \tcurl_easy_setopt(curl, CURLOPT_INFILESIZE, buffer->buf.len);\n@@ -213,9 +213,9 @@ static void curl_setup_http(CURL *curl, const char *url,\n \tcurl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, seek_buffer);\n \tcurl_easy_setopt(curl, CURLOPT_SEEKDATA, buffer);\n \tcurl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_fn);\n-\tcurl_easy_setopt(curl, CURLOPT_NOBODY, 0);\n+\tcurl_easy_setopt(curl, CURLOPT_NOBODY, 0L);\n \tcurl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req);\n-\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1);\n+\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);\n }\n \n static struct curl_slist *get_dav_token_headers(struct remote_lock *lock, enum dav_header_flag options)\ndiff --git a/http.c b/http.c\nindex ecbc47ea4b3f..d88e79fbde9c 100644\n--- a/http.c\n+++ b/http.c\n@@ -1540,9 +1540,9 @@ struct active_request_slot *get_active_slot(void)\n \tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, NULL);\n \tcurl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, NULL);\n \tcurl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, -1L);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 1);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0L);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1L);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 1L);\n \tcurl_easy_setopt(slot->curl, CURLOPT_RANGE, NULL);\n \n \t/*\n@@ -1551,9 +1551,9 @@ struct active_request_slot *get_active_slot(void)\n \t * HTTP_FOLLOW_* cases themselves.\n \t */\n \tif (http_follow_config == HTTP_FOLLOW_ALWAYS)\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1);\n+\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1L);\n \telse\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 0);\n+\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 0L);\n \n \tcurl_easy_setopt(slot->curl, CURLOPT_IPRESOLVE, git_curl_ipresolve);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPAUTH, http_auth_methods);\n@@ -2120,12 +2120,12 @@ static int http_request(const char *url,\n \tint ret;\n \n \tslot = get_active_slot();\n-\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1L);\n \n \tif (!result) {\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1);\n+\t\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1L);\n \t} else {\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);\n+\t\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0L);\n \t\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, result);\n \n \t\tif (target == HTTP_REQUEST_FILE) {\n@@ -2151,7 +2151,7 @@ static int http_request(const char *url,\n \t\tstrbuf_addstr(&buf, \" no-cache\");\n \tif (options && options->initial_request &&\n \t    http_follow_config == HTTP_FOLLOW_INITIAL)\n-\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1);\n+\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1L);\n \n \theaders = curl_slist_append(headers, buf.buf);\n \n@@ -2170,7 +2170,7 @@ static int http_request(const char *url,\n \tcurl_easy_setopt(slot->curl, CURLOPT_URL, url);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers);\n \tcurl_easy_setopt(slot->curl, CURLOPT_ENCODING, \"\");\n-\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0L);\n \n \tret = run_one_slot(slot, &results);\n \n@@ -2750,7 +2750,7 @@ struct http_object_request *new_http_object_request(const char *base_url,\n \tfreq->headers = object_request_headers();\n \n \tcurl_easy_setopt(freq->slot->curl, CURLOPT_WRITEDATA, freq);\n-\tcurl_easy_setopt(freq->slot->curl, CURLOPT_FAILONERROR, 0);\n+\tcurl_easy_setopt(freq->slot->curl, CURLOPT_FAILONERROR, 0L);\n \tcurl_easy_setopt(freq->slot->curl, CURLOPT_WRITEFUNCTION, fwrite_sha1_file);\n \tcurl_easy_setopt(freq->slot->curl, CURLOPT_ERRORBUFFER, freq->errorstr);\n \tcurl_easy_setopt(freq->slot->curl, CURLOPT_URL, freq->url);\ndiff --git a/remote-curl.c b/remote-curl.c\nindex 6183772191f2..b8bc3a80cf41 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -970,8 +970,8 @@ retry:\n \n \tslot = get_active_slot();\n \n-\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_POST, 1);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0L);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_POST, 1L);\n \tcurl_easy_setopt(slot->curl, CURLOPT_URL, rpc->service_url);\n \tcurl_easy_setopt(slot->curl, CURLOPT_ENCODING, \"\");\n \n@@ -1058,7 +1058,7 @@ retry:\n \trpc_in_data.check_pktline = stateless_connect;\n \tmemset(&rpc_in_data.pktline_state, 0, sizeof(rpc_in_data.pktline_state));\n \tcurl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, &rpc_in_data);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0L);\n \n \n \trpc->any_written = 0;\n-- \ngitgitgadget\n"},{"id":"519838","messageId":"20250606100558.GA3591871@coredump.intra.peff.net","threadId":"63586","inReplyTo":"80de7491d24fb51c6b2c3b2fc1728db30e2477f7.1749202164.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 4/4] curl: pass `long` values where expected","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2025-06-06T10:05:58Z","receivedAt":"2025-06-06T10:06:01Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Jun 06, 2025 at 09:29:24AM +0000, Johannes Schindelin via GitGitGadget wrote:\n\n> Nearly identical compile errors afflicted recently-updated Debian\n> setups, which have been addressed by `jk/curl-easy-setopt-typefix`.\n> \n> However, on macOS Git is built with different build options, which\n> uncovered more instances of `int` values that need to be cast to\n> constants, which were not covered by 6f11c42e8edc (curl: fix integer\n> constant typechecks with curl_easy_setopt(), 2025-06-04). Let's\n> explicitly convert even those remaining `int` constants in\n> `curl_easy_setopt()` calls to `long` parameters.\n\nWhat different build options? The extra fixes are in code that is\ncompiled on all platforms. E.g.:\n\n> --- a/remote-curl.c\n> +++ b/remote-curl.c\n> @@ -970,8 +970,8 @@ retry:\n>  \n>  \tslot = get_active_slot();\n>  \n> -\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);\n> -\tcurl_easy_setopt(slot->curl, CURLOPT_POST, 1);\n> +\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0L);\n> +\tcurl_easy_setopt(slot->curl, CURLOPT_POST, 1L);\n>  \tcurl_easy_setopt(slot->curl, CURLOPT_URL, rpc->service_url);\n>  \tcurl_easy_setopt(slot->curl, CURLOPT_ENCODING, \"\");\n\nSo I think the root cause of the difference remains a mystery.\n\nCuriously, if I build libcurl from source and link against it on my\nDebian system, I get all of the errors (including the ones you're fixing\nhere). But with the exact same compile options (modulo pointing\nCURL_CONFIG at the right spot), building against the Debian-packaged\nlibcurl is OK. Weird.\n\n> In addition to looking at the compile errors of the `osx-gcc` job, I\n> verified that there are no other instances of the same issue that need\n> to be handled in this manner (and that might not be caught by our CI\n> builds because of yet other build options that might skip those code\n> parts), I ran the following command and inspected all 23 results\n> manually to ensure that the fix is now actually complete:\n> \n>   git grep -n curl_easy_setopt |\n>   grep -ve ',.*, *[A-Za-z_\"&]' \\\n>     -e ',.*, *[-0-9]*L)' \\\n>     -e ',.*,.* (long)'\n\nI don't think that's sufficient for a full audit, because the first\n\"grep -v\" regex is removing variable names and symbolic constants, which\nmight also need to be cast to long (i.e., my patches 2 and 3).\n\nBut as your patch fixes the exact set that I also needed when building\nagainst my custom-built libcurl, I'm content to say we have spent enough\ntime digging. If there is some platform or makefile knob combination\nthat triggers one we missed, then curl's type-checker will catch it and\nwe can fix it then.\n\n-Peff\n"},{"id":"519850","messageId":"bf919293-562f-4572-bc0a-aad7f22d1013@app.fastmail.com","threadId":"63586","inReplyTo":"pull.1931.v2.git.1749202164.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 0/4] curl: pass long values where expected","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2025-06-06T14:27:34Z","receivedAt":"2025-06-06T14:27:55Z","isPatch":true,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Fri, Jun 6, 2025, at 11:29, Johannes Schindelin via GitGitGadget wrote:\n>        ## http.c ##\n>      -@@ http.c: static CURL *get_curl_handle(void)\n>      - \t\tdie(\"curl_easy_init failed\");\n>      -\n>      - \tif (!curl_ssl_verify) {\n>      --\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 0);\n>      --\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 0);\n>      -+\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 0l);\n>      -+\t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 0l);\n\nMaybe I don’t understand range-diffs enough but it looked like this was\nusing `0l` instead of `0L`.[1]  However the patches do use `<num>L` instead\nof `<num>l` throughout.  Which I like\n\n† 1: Or rather I don’t understand that this is showing `0l`\n"},{"id":"519853","messageId":"xmqqy0u451dd.fsf@gitster.g","threadId":"63586","inReplyTo":"80de7491d24fb51c6b2c3b2fc1728db30e2477f7.1749202164.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 4/4] curl: pass `long` values where expected","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-06-06T15:35:42Z","receivedAt":"2025-06-06T15:35:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> From: Johannes Schindelin <johannes.schindelin@gmx.de>\n>\n> As of Homebrew's update to cURL v8.14.0, there are new compile errors to\n> be observed in the `osx-gcc` job of Git's CI builds:\n>\n>   In file included from http.h:8,\n>                    from imap-send.c:36:\n>   In function 'setup_curl',\n>       inlined from 'curl_append_msgs_to_imap' at imap-send.c:1460:9,\n>       inlined from 'cmd_main' at imap-send.c:1581:9:\n>   /usr/local/Cellar/curl/8.14.0/include/curl/typecheck-gcc.h:50:15: error: call to '_curl_easy_setopt_err_long' declared with attribute warning: curl_easy_setopt expects a long argument [-Werror=attribute-warning]\n>      50 |               _curl_easy_setopt_err_long();                             \\\n>         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~\n>   /usr/local/Cellar/curl/8.14.0/include/curl/curl.h:54:7: note: in definition of macro 'CURL_IGNORE_DEPRECATION'\n>      54 |       statements \\\n>         |       ^~~~~~~~~~\n>   imap-send.c:1423:9: note: in expansion of macro 'curl_easy_setopt'\n>    1423 |         curl_easy_setopt(curl, CURLOPT_PORT, srvc->port);\n>         |         ^~~~~~~~~~~~~~~~\n>   [... many more instances of nearly identical warnings...]\n>\n> See for example this CI workflow run:\n> https://github.com/git/git/actions/runs/15454602308/job/43504278284#step:4:307\n>\n> The most likely explanation is the entry \"typecheck-gcc.h: fix the\n> typechecks\" in cURL's release notes (https://curl.se/ch/8.14.0.html).\n\nAll of the above were good descriptions in a standalone patch.\n\nHowever.\n\nThe first two lines that mention that osx-gcc job was broken are\nvaluable introduction to flow into \"Nearly identical ... Debian\",\nbut except that, but as part of a series it is probably a tad too\nverbose.\n\n> Nearly identical compile errors afflicted recently-updated Debian\n> setups, which have been addressed by `jk/curl-easy-setopt-typefix`.\n>\n> However, on macOS Git is built with different build options, which\n> uncovered more instances of `int` values that need to be cast to\n> constants, which were not covered by 6f11c42e8edc (curl: fix integer\n> constant typechecks with curl_easy_setopt(), 2025-06-04). Let's\n> explicitly convert even those remaining `int` constants in\n> `curl_easy_setopt()` calls to `long` parameters.\n\nIt is a but curious what build option differences caused it, as I do\nnot think any \"#ifdef DARWIN\" is involved.\n\nBy the way, I notice that we refer to 6f11c42e (curl: fix integer\nconstant typechecks with curl_easy_setopt(), 2025-06-04), so I won't\nbe requeueing Peff's patches.  I locally applied these four patches\nand the result of applying the first three on the same base was\nidentical to what I already had in jk/curl-easy-setopt-typefix topic\n(you didn't have to resend them---which was unnecessary confusing).\n\n> In addition to looking at the compile errors of the `osx-gcc` job, I\n> verified that there are no other instances of the same issue that need\n> to be handled in this manner (and that might not be caught by our CI\n> builds because of yet other build options that might skip those code\n> parts), I ran the following command and inspected all 23 results\n> manually to ensure that the fix is now actually complete:\n>\n>   git grep -n curl_easy_setopt |\n>   grep -ve ',.*, *[A-Za-z_\"&]' \\\n>     -e ',.*, *[-0-9]*L)' \\\n>     -e ',.*,.* (long)'\n\nThanks for being careful.  But I think it is probably counter\nproductive to exclud the first pattern (presumably to catch CURL*\nand other symbols), as the symbols defined by the library headers\nstill require to be cast to long; see:\n\n  https://lore.kernel.org/git/r1197994-o3so-6453-q16n-6n3on33n4nrp@unkk.fr/\n\nAnyway, the change this patch makes matches what you sent as a\n\"these still remain\" yesterday, so I understand that your inspecting\nthe 23 results manually did not find any \"ah, this too needs updated\nbut was missing from the one we saw yesterday\", which is a wonderful\nnews.\n\nWith this patch replaced (but not 3 from Peff), I'll redo the 'next'\n(thank me, whatever your deity is, and your good luck that I haven't\npushed it out, even though I did it with yesterday's material late\nlast night) and push the result out, but it won't be a while (even\nthough we already know the tree objects should be the same), as I\nwant to see if there are other urgent changes that have to go to\n'next' before doing so.\n\nThanks.\n\n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> ---\n>  http-push.c   |  6 +++---\n>  http.c        | 22 +++++++++++-----------\n>  remote-curl.c |  6 +++---\n>  3 files changed, 17 insertions(+), 17 deletions(-)\n>\n> diff --git a/http-push.c b/http-push.c\n> index 591e46ab260d..f5a92529a840 100644\n> --- a/http-push.c\n> +++ b/http-push.c\n> @@ -205,7 +205,7 @@ static void curl_setup_http(CURL *curl, const char *url,\n>  \t\tconst char *custom_req, struct buffer *buffer,\n>  \t\tcurl_write_callback write_fn)\n>  {\n> -\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1);\n> +\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);\n>  \tcurl_easy_setopt(curl, CURLOPT_URL, url);\n>  \tcurl_easy_setopt(curl, CURLOPT_INFILE, buffer);\n>  \tcurl_easy_setopt(curl, CURLOPT_INFILESIZE, buffer->buf.len);\n> @@ -213,9 +213,9 @@ static void curl_setup_http(CURL *curl, const char *url,\n>  \tcurl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, seek_buffer);\n>  \tcurl_easy_setopt(curl, CURLOPT_SEEKDATA, buffer);\n>  \tcurl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_fn);\n> -\tcurl_easy_setopt(curl, CURLOPT_NOBODY, 0);\n> +\tcurl_easy_setopt(curl, CURLOPT_NOBODY, 0L);\n>  \tcurl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req);\n> -\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1);\n> +\tcurl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);\n>  }\n>  \n>  static struct curl_slist *get_dav_token_headers(struct remote_lock *lock, enum dav_header_flag options)\n> diff --git a/http.c b/http.c\n> index ecbc47ea4b3f..d88e79fbde9c 100644\n> --- a/http.c\n> +++ b/http.c\n> @@ -1540,9 +1540,9 @@ struct active_request_slot *get_active_slot(void)\n>  \tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, NULL);\n>  \tcurl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, NULL);\n>  \tcurl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, -1L);\n> -\tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0);\n> -\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);\n> -\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 1);\n> +\tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0L);\n> +\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1L);\n> +\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 1L);\n>  \tcurl_easy_setopt(slot->curl, CURLOPT_RANGE, NULL);\n>  \n>  \t/*\n> @@ -1551,9 +1551,9 @@ struct active_request_slot *get_active_slot(void)\n>  \t * HTTP_FOLLOW_* cases themselves.\n>  \t */\n>  \tif (http_follow_config == HTTP_FOLLOW_ALWAYS)\n> -\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1);\n> +\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1L);\n>  \telse\n> -\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 0);\n> +\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 0L);\n>  \n>  \tcurl_easy_setopt(slot->curl, CURLOPT_IPRESOLVE, git_curl_ipresolve);\n>  \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPAUTH, http_auth_methods);\n> @@ -2120,12 +2120,12 @@ static int http_request(const char *url,\n>  \tint ret;\n>  \n>  \tslot = get_active_slot();\n> -\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);\n> +\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1L);\n>  \n>  \tif (!result) {\n> -\t\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1);\n> +\t\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1L);\n>  \t} else {\n> -\t\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);\n> +\t\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0L);\n>  \t\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, result);\n>  \n>  \t\tif (target == HTTP_REQUEST_FILE) {\n> @@ -2151,7 +2151,7 @@ static int http_request(const char *url,\n>  \t\tstrbuf_addstr(&buf, \" no-cache\");\n>  \tif (options && options->initial_request &&\n>  \t    http_follow_config == HTTP_FOLLOW_INITIAL)\n> -\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1);\n> +\t\tcurl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1L);\n>  \n>  \theaders = curl_slist_append(headers, buf.buf);\n>  \n> @@ -2170,7 +2170,7 @@ static int http_request(const char *url,\n>  \tcurl_easy_setopt(slot->curl, CURLOPT_URL, url);\n>  \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers);\n>  \tcurl_easy_setopt(slot->curl, CURLOPT_ENCODING, \"\");\n> -\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0);\n> +\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0L);\n>  \n>  \tret = run_one_slot(slot, &results);\n>  \n> @@ -2750,7 +2750,7 @@ struct http_object_request *new_http_object_request(const char *base_url,\n>  \tfreq->headers = object_request_headers();\n>  \n>  \tcurl_easy_setopt(freq->slot->curl, CURLOPT_WRITEDATA, freq);\n> -\tcurl_easy_setopt(freq->slot->curl, CURLOPT_FAILONERROR, 0);\n> +\tcurl_easy_setopt(freq->slot->curl, CURLOPT_FAILONERROR, 0L);\n>  \tcurl_easy_setopt(freq->slot->curl, CURLOPT_WRITEFUNCTION, fwrite_sha1_file);\n>  \tcurl_easy_setopt(freq->slot->curl, CURLOPT_ERRORBUFFER, freq->errorstr);\n>  \tcurl_easy_setopt(freq->slot->curl, CURLOPT_URL, freq->url);\n> diff --git a/remote-curl.c b/remote-curl.c\n> index 6183772191f2..b8bc3a80cf41 100644\n> --- a/remote-curl.c\n> +++ b/remote-curl.c\n> @@ -970,8 +970,8 @@ retry:\n>  \n>  \tslot = get_active_slot();\n>  \n> -\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);\n> -\tcurl_easy_setopt(slot->curl, CURLOPT_POST, 1);\n> +\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0L);\n> +\tcurl_easy_setopt(slot->curl, CURLOPT_POST, 1L);\n>  \tcurl_easy_setopt(slot->curl, CURLOPT_URL, rpc->service_url);\n>  \tcurl_easy_setopt(slot->curl, CURLOPT_ENCODING, \"\");\n>  \n> @@ -1058,7 +1058,7 @@ retry:\n>  \trpc_in_data.check_pktline = stateless_connect;\n>  \tmemset(&rpc_in_data.pktline_state, 0, sizeof(rpc_in_data.pktline_state));\n>  \tcurl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, &rpc_in_data);\n> -\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0);\n> +\tcurl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0L);\n>  \n>  \n>  \trpc->any_written = 0;\n"},{"id":"519854","messageId":"xmqqqzzw518z.fsf@gitster.g","threadId":"63586","inReplyTo":"20250606100558.GA3591871@coredump.intra.peff.net","subject":"Re: [PATCH v2 4/4] curl: pass `long` values where expected","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-06-06T15:38:20Z","receivedAt":"2025-06-06T15:38:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> But as your patch fixes the exact set that I also needed when building\n> against my custom-built libcurl, I'm content to say we have spent enough\n> time digging. If there is some platform or makefile knob combination\n> that triggers one we missed, then curl's type-checker will catch it and\n> we can fix it then.\n\nYeah, thanks, both.\n\n"},{"id":"519855","messageId":"CAN0heSqJfrLYbVmKh9-mS0fHkBSDR2dxphSaF7Q_qfyzONs2Eg@mail.gmail.com","threadId":"63586","inReplyTo":"bf919293-562f-4572-bc0a-aad7f22d1013@app.fastmail.com","subject":"Re: [PATCH v2 0/4] curl: pass long values where expected","fromName":"Martin Ågren","fromEmail":"martin.agren@gmail.com","sentAt":"2025-06-06T15:43:27Z","receivedAt":"2025-06-06T15:43:42Z","isPatch":true,"sender":{"key":"martin.agren@gmail.com","avatar":null},"body":"On Fri, 6 Jun 2025 at 16:28, Kristoffer Haugsbakk\n<kristofferhaugsbakk@fastmail.com> wrote:\n>\n> On Fri, Jun 6, 2025, at 11:29, Johannes Schindelin via GitGitGadget wrote:\n> >        ## http.c ##\n> >      -@@ http.c: static CURL *get_curl_handle(void)\n> >      -                die(\"curl_easy_init failed\");\n> >      -\n> >      -        if (!curl_ssl_verify) {\n> >      --               curl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 0);\n> >      --               curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 0);\n> >      -+               curl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 0l);\n> >      -+               curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 0l);\n>\n> Maybe I don’t understand range-diffs enough but it looked like this was\n> using `0l` instead of `0L`.[1]  However the patches do use `<num>L` instead\n> of `<num>l` throughout.  Which I like\n>\n> † 1: Or rather I don’t understand that this is showing `0l`\n\nYou can read \"--\" as \"we no longer remove this\" and \"-+\" as \"we no\nlonger add this\". In fact, this whole section begins with \"-\" (in the\nouter diff) and we can read this as \"we no longer touch this at all.\"\n\nWhere, crucially, it's \"we no longer touch this *in this patch*\". Patch\n1/4 in this v2 does change this from \"0\" to \"0L\" and this updated patch\n4/4 then leaves this spot as is. Unlike in v1, when this was a much bigger\npatch that touched this spot and many others.\n\nMartin\n"},{"id":"519857","messageId":"ad3fccf5-be36-417c-b2a2-f2289444ac40@app.fastmail.com","threadId":"63586","inReplyTo":"CAN0heSqJfrLYbVmKh9-mS0fHkBSDR2dxphSaF7Q_qfyzONs2Eg@mail.gmail.com","subject":"Re: [PATCH v2 0/4] curl: pass long values where expected","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2025-06-06T15:51:44Z","receivedAt":"2025-06-06T15:52:05Z","isPatch":true,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Fri, Jun 6, 2025, at 17:43, Martin Ågren wrote:\n>> Maybe I don’t understand range-diffs enough but it looked like this was\n>> using `0l` instead of `0L`.[1]  However the patches do use `<num>L` instead\n>> of `<num>l` throughout.  Which I like\n>>\n>> † 1: Or rather I don’t understand that this is showing `0l`\n>\n> You can read \"--\" as \"we no longer remove this\" and \"-+\" as \"we no\n> longer add this\". In fact, this whole section begins with \"-\" (in the\n> outer diff) and we can read this as \"we no longer touch this at all.\"\n>\n> Where, crucially, it's \"we no longer touch this *in this patch*\". Patch\n> 1/4 in this v2 does change this from \"0\" to \"0L\" and this updated patch\n> 4/4 then leaves this spot as is. Unlike in v1, when this was a much bigger\n> patch that touched this spot and many others.\n\nAha, thanks!\n\n-- \nKristoffer Haugsbakk\n\n"}]}