Skip to content

Commit 1618ae6

Browse files
committed
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 6f11c42 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6306f76 commit 1618ae6

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

http-push.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,17 +204,17 @@ static void curl_setup_http(CURL *curl, const char *url,
204204
const char *custom_req, struct buffer *buffer,
205205
curl_write_callback write_fn)
206206
{
207-
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
207+
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
208208
curl_easy_setopt(curl, CURLOPT_URL, url);
209209
curl_easy_setopt(curl, CURLOPT_INFILE, buffer);
210210
curl_easy_setopt(curl, CURLOPT_INFILESIZE, buffer->buf.len);
211211
curl_easy_setopt(curl, CURLOPT_READFUNCTION, fread_buffer);
212212
curl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, seek_buffer);
213213
curl_easy_setopt(curl, CURLOPT_SEEKDATA, buffer);
214214
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_fn);
215-
curl_easy_setopt(curl, CURLOPT_NOBODY, 0);
215+
curl_easy_setopt(curl, CURLOPT_NOBODY, 0L);
216216
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req);
217-
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
217+
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
218218
}
219219

220220
static struct curl_slist *get_dav_token_headers(struct remote_lock *lock, enum dav_header_flag options)

http.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,9 +1588,9 @@ struct active_request_slot *get_active_slot(void)
15881588
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, NULL);
15891589
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, NULL);
15901590
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, -1L);
1591-
curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0);
1592-
curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
1593-
curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 1);
1591+
curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0L);
1592+
curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1L);
1593+
curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 1L);
15941594
curl_easy_setopt(slot->curl, CURLOPT_RANGE, NULL);
15951595

15961596
/*
@@ -1599,9 +1599,9 @@ struct active_request_slot *get_active_slot(void)
15991599
* HTTP_FOLLOW_* cases themselves.
16001600
*/
16011601
if (http_follow_config == HTTP_FOLLOW_ALWAYS)
1602-
curl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1);
1602+
curl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1L);
16031603
else
1604-
curl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 0);
1604+
curl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 0L);
16051605

16061606
curl_easy_setopt(slot->curl, CURLOPT_IPRESOLVE, git_curl_ipresolve);
16071607
curl_easy_setopt(slot->curl, CURLOPT_HTTPAUTH, http_auth_methods);
@@ -2170,12 +2170,12 @@ static int http_request(const char *url,
21702170
int ret;
21712171

21722172
slot = get_active_slot();
2173-
curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
2173+
curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1L);
21742174

21752175
if (!result) {
2176-
curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1);
2176+
curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1L);
21772177
} else {
2178-
curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);
2178+
curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0L);
21792179
curl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, result);
21802180

21812181
if (target == HTTP_REQUEST_FILE) {
@@ -2201,7 +2201,7 @@ static int http_request(const char *url,
22012201
strbuf_addstr(&buf, " no-cache");
22022202
if (options && options->initial_request &&
22032203
http_follow_config == HTTP_FOLLOW_INITIAL)
2204-
curl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1);
2204+
curl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1L);
22052205

22062206
headers = curl_slist_append(headers, buf.buf);
22072207

@@ -2220,7 +2220,7 @@ static int http_request(const char *url,
22202220
curl_easy_setopt(slot->curl, CURLOPT_URL, url);
22212221
curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers);
22222222
curl_easy_setopt(slot->curl, CURLOPT_ENCODING, "");
2223-
curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0);
2223+
curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0L);
22242224

22252225
ret = run_one_slot(slot, &results);
22262226

@@ -2782,7 +2782,7 @@ struct http_object_request *new_http_object_request(const char *base_url,
27822782
freq->headers = object_request_headers();
27832783

27842784
curl_easy_setopt(freq->slot->curl, CURLOPT_WRITEDATA, freq);
2785-
curl_easy_setopt(freq->slot->curl, CURLOPT_FAILONERROR, 0);
2785+
curl_easy_setopt(freq->slot->curl, CURLOPT_FAILONERROR, 0L);
27862786
curl_easy_setopt(freq->slot->curl, CURLOPT_WRITEFUNCTION, fwrite_sha1_file);
27872787
curl_easy_setopt(freq->slot->curl, CURLOPT_ERRORBUFFER, freq->errorstr);
27882788
curl_easy_setopt(freq->slot->curl, CURLOPT_URL, freq->url);

remote-curl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -969,8 +969,8 @@ static int post_rpc(struct rpc_state *rpc, int stateless_connect, int flush_rece
969969

970970
slot = get_active_slot();
971971

972-
curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);
973-
curl_easy_setopt(slot->curl, CURLOPT_POST, 1);
972+
curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0L);
973+
curl_easy_setopt(slot->curl, CURLOPT_POST, 1L);
974974
curl_easy_setopt(slot->curl, CURLOPT_URL, rpc->service_url);
975975
curl_easy_setopt(slot->curl, CURLOPT_ENCODING, "");
976976

@@ -1057,7 +1057,7 @@ static int post_rpc(struct rpc_state *rpc, int stateless_connect, int flush_rece
10571057
rpc_in_data.check_pktline = stateless_connect;
10581058
memset(&rpc_in_data.pktline_state, 0, sizeof(rpc_in_data.pktline_state));
10591059
curl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, &rpc_in_data);
1060-
curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0);
1060+
curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0L);
10611061

10621062

10631063
rpc->any_written = 0;

0 commit comments

Comments
 (0)