curl: pass `long` values where expected

As of Homebrew's update to cURL v8.14.0, there are new compile errors to be observed in the `osx-gcc` job of Git's CI builds: In file included from http.h:8, from imap-send.c:36: In function 'setup_curl', inlined from 'curl_append_msgs_to_imap' at imap-send.c:1460:9, inlined from 'cmd_main' at imap-send.c:1581:9: /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] 50 | _curl_easy_setopt_err_long(); \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/Cellar/curl/8.14.0/include/curl/curl.h:54:7: note: in definition of macro 'CURL_IGNORE_DEPRECATION' 54 | statements \ | ^~~~~~~~~~ imap-send.c:1423:9: note: in expansion of macro 'curl_easy_setopt' 1423 | curl_easy_setopt(curl, CURLOPT_PORT, srvc->port); | ^~~~~~~~~~~~~~~~ [... many more instances of nearly identical warnings...] See for example this CI workflow run: https://github.com/git/git/actions/runs/15454602308/job/43504278284#step:4:307 The most likely explanation is the entry "typecheck-gcc.h: fix the typechecks" in cURL's release notes (https://curl.se/ch/8.14.0.html). Nearly identical compile errors afflicted recently-updated Debian setups, which have been addressed by `jk/curl-easy-setopt-typefix`. However, on macOS Git is built with different build options, which uncovered more instances of `int` values that need to be cast to constants, which were not covered by 6f11c42e8edc (curl: fix integer constant typechecks with curl_easy_setopt(), 2025-06-04). Let's explicitly convert even those remaining `int` constants in `curl_easy_setopt()` calls to `long` parameters. In addition to looking at the compile errors of the `osx-gcc` job, I verified that there are no other instances of the same issue that need to be handled in this manner (and that might not be caught by our CI builds because of yet other build options that might skip those code parts), I ran the following command and inspected all 23 results manually to ensure that the fix is now actually complete: git grep -n curl_easy_setopt | grep -ve ',.*, *[A-Za-z_"&]' \ -e ',.*, *[-0-9]*L)' \ -e ',.*,.* (long)' Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Jun 6, 2025 at 09:29 UTC 229d12665edb555df26653cf4a4731ae71c71a6d
3 files changed +17 -17
http-push.c
+3 -3
@@ -205,7 +205,7 @@ static void curl_setup_http(CURL *curl, const char *url,
205 const char *custom_req, struct buffer *buffer,
206 curl_write_callback write_fn)
207 {
208 - curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
208 + curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
209 curl_easy_setopt(curl, CURLOPT_URL, url);
210 curl_easy_setopt(curl, CURLOPT_INFILE, buffer);
211 curl_easy_setopt(curl, CURLOPT_INFILESIZE, buffer->buf.len);
@@ -213,9 +213,9 @@ static void curl_setup_http(CURL *curl, const char *url,
213 curl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, seek_buffer);
214 curl_easy_setopt(curl, CURLOPT_SEEKDATA, buffer);
215 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_fn);
216 - curl_easy_setopt(curl, CURLOPT_NOBODY, 0);
216 + curl_easy_setopt(curl, CURLOPT_NOBODY, 0L);
217 curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req);
218 - curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
218 + curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
219 }
220
221 static struct curl_slist *get_dav_token_headers(struct remote_lock *lock, enum dav_header_flag options)
http.c
+11 -11
@@ -1540,9 +1540,9 @@ struct active_request_slot *get_active_slot(void)
1540 curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, NULL);
1541 curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, NULL);
1542 curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, -1L);
1543 - curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0);
1544 - curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
1545 - curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 1);
1543 + curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0L);
1544 + curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1L);
1545 + curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 1L);
1546 curl_easy_setopt(slot->curl, CURLOPT_RANGE, NULL);
1547
1548 /*
@@ -1551,9 +1551,9 @@ struct active_request_slot *get_active_slot(void)
1551 * HTTP_FOLLOW_* cases themselves.
1552 */
1553 if (http_follow_config == HTTP_FOLLOW_ALWAYS)
1554 - curl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1);
1554 + curl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1L);
1555 else
1556 - curl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 0);
1556 + curl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 0L);
1557
1558 curl_easy_setopt(slot->curl, CURLOPT_IPRESOLVE, git_curl_ipresolve);
1559 curl_easy_setopt(slot->curl, CURLOPT_HTTPAUTH, http_auth_methods);
@@ -2120,12 +2120,12 @@ static int http_request(const char *url,
2120 int ret;
2121
2122 slot = get_active_slot();
2123 - curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
2123 + curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1L);
2124
2125 if (!result) {
2126 - curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1);
2126 + curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1L);
2127 } else {
2128 - curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);
2128 + curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0L);
2129 curl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, result);
2130
2131 if (target == HTTP_REQUEST_FILE) {
@@ -2151,7 +2151,7 @@ static int http_request(const char *url,
2151 strbuf_addstr(&buf, " no-cache");
2152 if (options && options->initial_request &&
2153 http_follow_config == HTTP_FOLLOW_INITIAL)
2154 - curl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1);
2154 + curl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1L);
2155
2156 headers = curl_slist_append(headers, buf.buf);
2157
@@ -2170,7 +2170,7 @@ static int http_request(const char *url,
2170 curl_easy_setopt(slot->curl, CURLOPT_URL, url);
2171 curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers);
2172 curl_easy_setopt(slot->curl, CURLOPT_ENCODING, "");
2173 - curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0);
2173 + curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0L);
2174
2175 ret = run_one_slot(slot, &results);
2176
@@ -2750,7 +2750,7 @@ struct http_object_request *new_http_object_request(const char *base_url,
2750 freq->headers = object_request_headers();
2751
2752 curl_easy_setopt(freq->slot->curl, CURLOPT_WRITEDATA, freq);
2753 - curl_easy_setopt(freq->slot->curl, CURLOPT_FAILONERROR, 0);
2753 + curl_easy_setopt(freq->slot->curl, CURLOPT_FAILONERROR, 0L);
2754 curl_easy_setopt(freq->slot->curl, CURLOPT_WRITEFUNCTION, fwrite_sha1_file);
2755 curl_easy_setopt(freq->slot->curl, CURLOPT_ERRORBUFFER, freq->errorstr);
2756 curl_easy_setopt(freq->slot->curl, CURLOPT_URL, freq->url);
remote-curl.c
+3 -3
@@ -970,8 +970,8 @@ retry:
970
971 slot = get_active_slot();
972
973 - curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);
974 - curl_easy_setopt(slot->curl, CURLOPT_POST, 1);
973 + curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0L);
974 + curl_easy_setopt(slot->curl, CURLOPT_POST, 1L);
975 curl_easy_setopt(slot->curl, CURLOPT_URL, rpc->service_url);
976 curl_easy_setopt(slot->curl, CURLOPT_ENCODING, "");
977
@@ -1058,7 +1058,7 @@ retry:
1058 rpc_in_data.check_pktline = stateless_connect;
1059 memset(&rpc_in_data.pktline_state, 0, sizeof(rpc_in_data.pktline_state));
1060 curl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, &rpc_in_data);
1061 - curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0);
1061 + curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0L);
1062
1063
1064 rpc->any_written = 0;