diff options
author | Frantisek Sumsal <frantisek@sumsal.cz> | 2023-01-09 12:44:28 +0100 |
---|---|---|
committer | Frantisek Sumsal <frantisek@sumsal.cz> | 2023-01-09 13:36:42 +0100 |
commit | e61a4c0b7c79eabbe4eb50ff2e663734fde769f0 (patch) | |
tree | c2130499981d0a0c72e92129bf86107a09070144 /src/import | |
parent | 2285c462ebb0b5d9a7043719a4f0d684a5dc37c2 (diff) | |
download | systemd-e61a4c0b7c79eabbe4eb50ff2e663734fde769f0.tar.gz |
import: use CURLOPT_PROTOCOLS_STR with libcurl >= 7.85.0
CURLOPT_PROTOCOLS [0] was deprecated in libcurl 7.85.0 with
CURLOPT_PROTOCOLS_STR [1] as a replacement, causing build warnings/errors:
../build/src/import/curl-util.c: In function ‘curl_glue_make’:
../build/src/import/curl-util.c:255:9: error: ‘CURLOPT_PROTOCOLS’ is deprecated: since 7.85.0. Use CURLOPT_PROTOCOLS_STR [-Werror=deprecated-declarations]
255 | if (curl_easy_setopt(c, CURLOPT_PROTOCOLS, CURLPROTO_HTTP|CURLPROTO_HTTPS|CURLPROTO_FILE) != CURLE_OK)
| ^~
In file included from ../build/src/import/curl-util.h:4,
from ../build/src/import/curl-util.c:6:
/usr/include/curl/curl.h:1749:3: note: declared here
1749 | CURLOPTDEPRECATED(CURLOPT_PROTOCOLS, CURLOPTTYPE_LONG, 181,
| ^~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Since there's no grace period between the two symbols, let's resort
to a light if-def-ery to resolve this.
[0] https://curl.se/libcurl/c/CURLOPT_PROTOCOLS.html
[1] https://curl.se/libcurl/c/CURLOPT_PROTOCOLS_STR.html
Diffstat (limited to 'src/import')
-rw-r--r-- | src/import/curl-util.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/import/curl-util.c b/src/import/curl-util.c index c124c985b9..94f718de17 100644 --- a/src/import/curl-util.c +++ b/src/import/curl-util.c @@ -252,7 +252,11 @@ int curl_glue_make(CURL **ret, const char *url, void *userdata) { if (curl_easy_setopt(c, CURLOPT_LOW_SPEED_LIMIT, 30L) != CURLE_OK) return -EIO; +#if LIBCURL_VERSION_NUM >= 0x075500 /* libcurl 7.85.0 */ + if (curl_easy_setopt(c, CURLOPT_PROTOCOLS_STR, "HTTP,HTTPS,FILE") != CURLE_OK) +#else if (curl_easy_setopt(c, CURLOPT_PROTOCOLS, CURLPROTO_HTTP|CURLPROTO_HTTPS|CURLPROTO_FILE) != CURLE_OK) +#endif return -EIO; *ret = TAKE_PTR(c); |