Skip to content

Commit 84d689a

Browse files
peffgitster
authored andcommitted
imap-send: use server conf argument in setup_curl()
Our caller passes in an imap_server_conf struct, but we ignore it totally, and instead read the config directly from the global "server" variable. This works OK, since our sole caller will pass in that same global variable. But the intent seems to have been to use the passed-in variable, as otherwise it has no purpose (and many other functions use the same pattern). Let's use the passed-in value, which also silences a -Wunused-parameter warning. It would be nice if "server" was not a global here, as we could avoid making similar mistakes. But changing that would be a larger refactor, as it must be accessed as a global in a few spots (e.g., filling it in with the config callback). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fb7d80e commit 84d689a

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

imap-send.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,42 +1415,42 @@ static CURL *setup_curl(struct imap_server_conf *srvc, struct credential *cred)
14151415
if (!curl)
14161416
die("curl_easy_init failed");
14171417

1418-
server_fill_credential(&server, cred);
1419-
curl_easy_setopt(curl, CURLOPT_USERNAME, server.user);
1420-
curl_easy_setopt(curl, CURLOPT_PASSWORD, server.pass);
1418+
server_fill_credential(srvc, cred);
1419+
curl_easy_setopt(curl, CURLOPT_USERNAME, srvc->user);
1420+
curl_easy_setopt(curl, CURLOPT_PASSWORD, srvc->pass);
14211421

1422-
strbuf_addstr(&path, server.use_ssl ? "imaps://" : "imap://");
1423-
strbuf_addstr(&path, server.host);
1422+
strbuf_addstr(&path, srvc->use_ssl ? "imaps://" : "imap://");
1423+
strbuf_addstr(&path, srvc->host);
14241424
if (!path.len || path.buf[path.len - 1] != '/')
14251425
strbuf_addch(&path, '/');
14261426

1427-
uri_encoded_folder = curl_easy_escape(curl, server.folder, 0);
1427+
uri_encoded_folder = curl_easy_escape(curl, srvc->folder, 0);
14281428
if (!uri_encoded_folder)
14291429
die("failed to encode server folder");
14301430
strbuf_addstr(&path, uri_encoded_folder);
14311431
curl_free(uri_encoded_folder);
14321432

14331433
curl_easy_setopt(curl, CURLOPT_URL, path.buf);
14341434
strbuf_release(&path);
1435-
curl_easy_setopt(curl, CURLOPT_PORT, server.port);
1435+
curl_easy_setopt(curl, CURLOPT_PORT, srvc->port);
14361436

1437-
if (server.auth_method) {
1437+
if (srvc->auth_method) {
14381438
#ifndef GIT_CURL_HAVE_CURLOPT_LOGIN_OPTIONS
14391439
warning("No LOGIN_OPTIONS support in this cURL version");
14401440
#else
14411441
struct strbuf auth = STRBUF_INIT;
14421442
strbuf_addstr(&auth, "AUTH=");
1443-
strbuf_addstr(&auth, server.auth_method);
1443+
strbuf_addstr(&auth, srvc->auth_method);
14441444
curl_easy_setopt(curl, CURLOPT_LOGIN_OPTIONS, auth.buf);
14451445
strbuf_release(&auth);
14461446
#endif
14471447
}
14481448

1449-
if (!server.use_ssl)
1449+
if (!srvc->use_ssl)
14501450
curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_TRY);
14511451

1452-
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, server.ssl_verify);
1453-
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, server.ssl_verify);
1452+
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, srvc->ssl_verify);
1453+
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, srvc->ssl_verify);
14541454

14551455
curl_easy_setopt(curl, CURLOPT_READFUNCTION, fread_buffer);
14561456

0 commit comments

Comments
 (0)