Skip to content

Commit d43e7f1

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). Let's explicitly convert all `int` parameters in `curl_easy_setopt()` calls to `long` parameters. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 0d42fbd commit d43e7f1

File tree

4 files changed

+37
-37
lines changed

4 files changed

+37
-37
lines changed

http-push.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ static char *xml_entities(const char *s)
195195
static void curl_setup_http_get(CURL *curl, const char *url,
196196
const char *custom_req)
197197
{
198-
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
198+
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1l);
199199
curl_easy_setopt(curl, CURLOPT_URL, url);
200200
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req);
201201
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite_null);
@@ -205,17 +205,17 @@ static void curl_setup_http(CURL *curl, const char *url,
205205
const char *custom_req, struct buffer *buffer,
206206
curl_write_callback write_fn)
207207
{
208-
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
208+
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1l);
209209
curl_easy_setopt(curl, CURLOPT_URL, url);
210210
curl_easy_setopt(curl, CURLOPT_INFILE, buffer);
211211
curl_easy_setopt(curl, CURLOPT_INFILESIZE, buffer->buf.len);
212212
curl_easy_setopt(curl, CURLOPT_READFUNCTION, fread_buffer);
213213
curl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, seek_buffer);
214214
curl_easy_setopt(curl, CURLOPT_SEEKDATA, buffer);
215215
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_fn);
216-
curl_easy_setopt(curl, CURLOPT_NOBODY, 0);
216+
curl_easy_setopt(curl, CURLOPT_NOBODY, 0l);
217217
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req);
218-
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
218+
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1l);
219219
}
220220

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

http.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,13 +1019,13 @@ static CURL *get_curl_handle(void)
10191019
die("curl_easy_init failed");
10201020

10211021
if (!curl_ssl_verify) {
1022-
curl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 0);
1023-
curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 0);
1022+
curl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 0l);
1023+
curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 0l);
10241024
} else {
10251025
/* Verify authenticity of the peer's certificate */
1026-
curl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 1);
1026+
curl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 1l);
10271027
/* The name in the cert must match whom we tried to connect */
1028-
curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);
1028+
curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2l);
10291029
}
10301030

10311031
if (curl_http_version) {
@@ -1117,8 +1117,8 @@ static CURL *get_curl_handle(void)
11171117
curl_low_speed_time);
11181118
}
11191119

1120-
curl_easy_setopt(result, CURLOPT_MAXREDIRS, 20);
1121-
curl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);
1120+
curl_easy_setopt(result, CURLOPT_MAXREDIRS, 20l);
1121+
curl_easy_setopt(result, CURLOPT_POSTREDIR, (long)CURL_REDIR_POST_ALL);
11221122

11231123
#ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR
11241124
{
@@ -1151,7 +1151,7 @@ static CURL *get_curl_handle(void)
11511151
user_agent ? user_agent : git_user_agent());
11521152

11531153
if (curl_ftp_no_epsv)
1154-
curl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);
1154+
curl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0l);
11551155

11561156
if (curl_ssl_try)
11571157
curl_easy_setopt(result, CURLOPT_USE_SSL, CURLUSESSL_TRY);
@@ -1193,18 +1193,18 @@ static CURL *get_curl_handle(void)
11931193

11941194
if (starts_with(curl_http_proxy, "socks5h"))
11951195
curl_easy_setopt(result,
1196-
CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME);
1196+
CURLOPT_PROXYTYPE, (long)CURLPROXY_SOCKS5_HOSTNAME);
11971197
else if (starts_with(curl_http_proxy, "socks5"))
11981198
curl_easy_setopt(result,
1199-
CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
1199+
CURLOPT_PROXYTYPE, (long)CURLPROXY_SOCKS5);
12001200
else if (starts_with(curl_http_proxy, "socks4a"))
12011201
curl_easy_setopt(result,
1202-
CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4A);
1202+
CURLOPT_PROXYTYPE, (long)CURLPROXY_SOCKS4A);
12031203
else if (starts_with(curl_http_proxy, "socks"))
12041204
curl_easy_setopt(result,
1205-
CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
1205+
CURLOPT_PROXYTYPE, (long)CURLPROXY_SOCKS4);
12061206
else if (starts_with(curl_http_proxy, "https")) {
1207-
curl_easy_setopt(result, CURLOPT_PROXYTYPE, CURLPROXY_HTTPS);
1207+
curl_easy_setopt(result, CURLOPT_PROXYTYPE, (long)CURLPROXY_HTTPS);
12081208

12091209
if (http_proxy_ssl_cert)
12101210
curl_easy_setopt(result, CURLOPT_PROXY_SSLCERT, http_proxy_ssl_cert);
@@ -1254,7 +1254,7 @@ static CURL *get_curl_handle(void)
12541254
}
12551255
init_curl_proxy_auth(result);
12561256

1257-
curl_easy_setopt(result, CURLOPT_TCP_KEEPALIVE, 1);
1257+
curl_easy_setopt(result, CURLOPT_TCP_KEEPALIVE, 1l);
12581258

12591259
if (curl_tcp_keepidle > -1)
12601260
curl_easy_setopt(result, CURLOPT_TCP_KEEPIDLE,
@@ -1540,9 +1540,9 @@ struct active_request_slot *get_active_slot(void)
15401540
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, NULL);
15411541
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, NULL);
15421542
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);
15461546
curl_easy_setopt(slot->curl, CURLOPT_RANGE, NULL);
15471547

15481548
/*
@@ -1551,9 +1551,9 @@ struct active_request_slot *get_active_slot(void)
15511551
* HTTP_FOLLOW_* cases themselves.
15521552
*/
15531553
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);
15551555
else
1556-
curl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 0);
1556+
curl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 0l);
15571557

15581558
curl_easy_setopt(slot->curl, CURLOPT_IPRESOLVE, git_curl_ipresolve);
15591559
curl_easy_setopt(slot->curl, CURLOPT_HTTPAUTH, http_auth_methods);
@@ -2120,12 +2120,12 @@ static int http_request(const char *url,
21202120
int ret;
21212121

21222122
slot = get_active_slot();
2123-
curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
2123+
curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1l);
21242124

21252125
if (!result) {
2126-
curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1);
2126+
curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1l);
21272127
} else {
2128-
curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);
2128+
curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0l);
21292129
curl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, result);
21302130

21312131
if (target == HTTP_REQUEST_FILE) {
@@ -2151,7 +2151,7 @@ static int http_request(const char *url,
21512151
strbuf_addstr(&buf, " no-cache");
21522152
if (options && options->initial_request &&
21532153
http_follow_config == HTTP_FOLLOW_INITIAL)
2154-
curl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1);
2154+
curl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 1l);
21552155

21562156
headers = curl_slist_append(headers, buf.buf);
21572157

@@ -2170,7 +2170,7 @@ static int http_request(const char *url,
21702170
curl_easy_setopt(slot->curl, CURLOPT_URL, url);
21712171
curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers);
21722172
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);
21742174

21752175
ret = run_one_slot(slot, &results);
21762176

@@ -2750,7 +2750,7 @@ struct http_object_request *new_http_object_request(const char *base_url,
27502750
freq->headers = object_request_headers();
27512751

27522752
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);
27542754
curl_easy_setopt(freq->slot->curl, CURLOPT_WRITEFUNCTION, fwrite_sha1_file);
27552755
curl_easy_setopt(freq->slot->curl, CURLOPT_ERRORBUFFER, freq->errorstr);
27562756
curl_easy_setopt(freq->slot->curl, CURLOPT_URL, freq->url);

imap-send.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,7 @@ static CURL *setup_curl(struct imap_server_conf *srvc, struct credential *cred)
14201420

14211421
curl_easy_setopt(curl, CURLOPT_URL, path.buf);
14221422
strbuf_release(&path);
1423-
curl_easy_setopt(curl, CURLOPT_PORT, srvc->port);
1423+
curl_easy_setopt(curl, CURLOPT_PORT, (long)srvc->port);
14241424

14251425
if (srvc->auth_method) {
14261426
struct strbuf auth = STRBUF_INIT;
@@ -1433,8 +1433,8 @@ static CURL *setup_curl(struct imap_server_conf *srvc, struct credential *cred)
14331433
if (!srvc->use_ssl)
14341434
curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_TRY);
14351435

1436-
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, srvc->ssl_verify);
1437-
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, srvc->ssl_verify);
1436+
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, (long)srvc->ssl_verify);
1437+
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, (long)srvc->ssl_verify);
14381438

14391439
curl_easy_setopt(curl, CURLOPT_READFUNCTION, fread_buffer);
14401440

remote-curl.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -877,12 +877,12 @@ static int probe_rpc(struct rpc_state *rpc, struct slot_results *results)
877877
headers = curl_slist_append(headers, rpc->hdr_content_type);
878878
headers = curl_slist_append(headers, rpc->hdr_accept);
879879

880-
curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);
881-
curl_easy_setopt(slot->curl, CURLOPT_POST, 1);
880+
curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0l);
881+
curl_easy_setopt(slot->curl, CURLOPT_POST, 1l);
882882
curl_easy_setopt(slot->curl, CURLOPT_URL, rpc->service_url);
883883
curl_easy_setopt(slot->curl, CURLOPT_ENCODING, NULL);
884884
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, "0000");
885-
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, 4);
885+
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, 4l);
886886
curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers);
887887
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
888888
curl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, &buf);
@@ -970,8 +970,8 @@ static int post_rpc(struct rpc_state *rpc, int stateless_connect, int flush_rece
970970

971971
slot = get_active_slot();
972972

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);
975975
curl_easy_setopt(slot->curl, CURLOPT_URL, rpc->service_url);
976976
curl_easy_setopt(slot->curl, CURLOPT_ENCODING, "");
977977

@@ -1058,7 +1058,7 @@ static int post_rpc(struct rpc_state *rpc, int stateless_connect, int flush_rece
10581058
rpc_in_data.check_pktline = stateless_connect;
10591059
memset(&rpc_in_data.pktline_state, 0, sizeof(rpc_in_data.pktline_state));
10601060
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);
10621062

10631063

10641064
rpc->any_written = 0;

0 commit comments

Comments
 (0)