From: Viktor Szakats Date: Fri, 1 Aug 2025 14:47:41 +0000 (+0200) Subject: CURLOPT: bump `CURLPROTO_*` macros to `long` X-Git-Tag: curl-8_16_0~285 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b131db54106ea009835eb4c01968a9e7181f0fd4;p=thirdparty%2Fcurl.git CURLOPT: bump `CURLPROTO_*` macros to `long` This patch bumps the size of these macros from `int` to `long`, while keeping their actual values the same. It may cause incompatibilities in user code, requiring the bump of holder variables and/or adding casts: - CURLPROTO_HTTP - CURLPROTO_HTTPS - CURLPROTO_FTP - CURLPROTO_FTPS - CURLPROTO_SCP - CURLPROTO_SFTP - CURLPROTO_TELNET - CURLPROTO_LDAP - CURLPROTO_LDAPS - CURLPROTO_DICT - CURLPROTO_FILE - CURLPROTO_TFTP - CURLPROTO_IMAP - CURLPROTO_IMAPS - CURLPROTO_POP3 - CURLPROTO_POP3S - CURLPROTO_SMTP - CURLPROTO_SMTPS - CURLPROTO_RTSP - CURLPROTO_RTMP - CURLPROTO_RTMPT - CURLPROTO_RTMPE - CURLPROTO_RTMPTE - CURLPROTO_RTMPS - CURLPROTO_RTMPTS - CURLPROTO_GOPHER - CURLPROTO_SMB - CURLPROTO_SMBS - CURLPROTO_MQTT - CURLPROTO_GOPHERS - CURLPROTO_ALL Also: - keep existing cast within the documentation to make sure it applies to older curl versions as well. Closes #18136 --- diff --git a/include/curl/curl.h b/include/curl/curl.h index a34598d352..e603f8ca20 100644 --- a/include/curl/curl.h +++ b/include/curl/curl.h @@ -1072,37 +1072,37 @@ typedef CURLSTScode (*curl_hstswrite_callback)(CURL *easy, /* The CURLPROTO_ defines below are for the **deprecated** CURLOPT_*PROTOCOLS options. Do not use. */ -#define CURLPROTO_HTTP (1<<0) -#define CURLPROTO_HTTPS (1<<1) -#define CURLPROTO_FTP (1<<2) -#define CURLPROTO_FTPS (1<<3) -#define CURLPROTO_SCP (1<<4) -#define CURLPROTO_SFTP (1<<5) -#define CURLPROTO_TELNET (1<<6) -#define CURLPROTO_LDAP (1<<7) -#define CURLPROTO_LDAPS (1<<8) -#define CURLPROTO_DICT (1<<9) -#define CURLPROTO_FILE (1<<10) -#define CURLPROTO_TFTP (1<<11) -#define CURLPROTO_IMAP (1<<12) -#define CURLPROTO_IMAPS (1<<13) -#define CURLPROTO_POP3 (1<<14) -#define CURLPROTO_POP3S (1<<15) -#define CURLPROTO_SMTP (1<<16) -#define CURLPROTO_SMTPS (1<<17) -#define CURLPROTO_RTSP (1<<18) -#define CURLPROTO_RTMP (1<<19) -#define CURLPROTO_RTMPT (1<<20) -#define CURLPROTO_RTMPE (1<<21) -#define CURLPROTO_RTMPTE (1<<22) -#define CURLPROTO_RTMPS (1<<23) -#define CURLPROTO_RTMPTS (1<<24) -#define CURLPROTO_GOPHER (1<<25) -#define CURLPROTO_SMB (1<<26) -#define CURLPROTO_SMBS (1<<27) -#define CURLPROTO_MQTT (1<<28) -#define CURLPROTO_GOPHERS (1<<29) -#define CURLPROTO_ALL (~0) /* enable everything */ +#define CURLPROTO_HTTP (1L<<0) +#define CURLPROTO_HTTPS (1L<<1) +#define CURLPROTO_FTP (1L<<2) +#define CURLPROTO_FTPS (1L<<3) +#define CURLPROTO_SCP (1L<<4) +#define CURLPROTO_SFTP (1L<<5) +#define CURLPROTO_TELNET (1L<<6) +#define CURLPROTO_LDAP (1L<<7) +#define CURLPROTO_LDAPS (1L<<8) +#define CURLPROTO_DICT (1L<<9) +#define CURLPROTO_FILE (1L<<10) +#define CURLPROTO_TFTP (1L<<11) +#define CURLPROTO_IMAP (1L<<12) +#define CURLPROTO_IMAPS (1L<<13) +#define CURLPROTO_POP3 (1L<<14) +#define CURLPROTO_POP3S (1L<<15) +#define CURLPROTO_SMTP (1L<<16) +#define CURLPROTO_SMTPS (1L<<17) +#define CURLPROTO_RTSP (1L<<18) +#define CURLPROTO_RTMP (1L<<19) +#define CURLPROTO_RTMPT (1L<<20) +#define CURLPROTO_RTMPE (1L<<21) +#define CURLPROTO_RTMPTE (1L<<22) +#define CURLPROTO_RTMPS (1L<<23) +#define CURLPROTO_RTMPTS (1L<<24) +#define CURLPROTO_GOPHER (1L<<25) +#define CURLPROTO_SMB (1L<<26) +#define CURLPROTO_SMBS (1L<<27) +#define CURLPROTO_MQTT (1L<<28) +#define CURLPROTO_GOPHERS (1L<<29) +#define CURLPROTO_ALL (~0L) /* enable everything */ /* long may be 32 or 64 bits, but we should never depend on anything else but 32 */ diff --git a/lib/doh.c b/lib/doh.c index cdc3d087e2..ac9743b0a9 100644 --- a/lib/doh.c +++ b/lib/doh.c @@ -348,10 +348,10 @@ static CURLcode doh_probe_run(struct Curl_easy *data, #endif #ifndef DEBUGBUILD /* enforce HTTPS if not debug */ - ERROR_CHECK_SETOPT(CURLOPT_PROTOCOLS, (long)CURLPROTO_HTTPS); + ERROR_CHECK_SETOPT(CURLOPT_PROTOCOLS, CURLPROTO_HTTPS); #else /* in debug mode, also allow http */ - ERROR_CHECK_SETOPT(CURLOPT_PROTOCOLS, (long)CURLPROTO_HTTP|CURLPROTO_HTTPS); + ERROR_CHECK_SETOPT(CURLOPT_PROTOCOLS, CURLPROTO_HTTP|CURLPROTO_HTTPS); #endif ERROR_CHECK_SETOPT(CURLOPT_TIMEOUT_MS, (long)timeout_ms); ERROR_CHECK_SETOPT(CURLOPT_SHARE, (CURLSH *)data->share); diff --git a/lib/urldata.h b/lib/urldata.h index ec39e58dca..2ae52840f5 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -70,11 +70,11 @@ struct curl_trc_featt; * platforms that have a >= 64-bit type and then we use such a type for the * protocol fields in the protocol handler. */ -#define CURLPROTO_WS (1<<30) +#define CURLPROTO_WS (1L<<30) #define CURLPROTO_WSS ((curl_prot_t)1<<31) #else -#define CURLPROTO_WS 0 -#define CURLPROTO_WSS 0 +#define CURLPROTO_WS 0L +#define CURLPROTO_WSS 0L #endif /* the default protocols accepting a redirect to */ diff --git a/tests/libtest/lib1535.c b/tests/libtest/lib1535.c index 07a97dde0b..c0e0689d98 100644 --- a/tests/libtest/lib1535.c +++ b/tests/libtest/lib1535.c @@ -80,7 +80,7 @@ static CURLcode test_lib1535(const char *URL) if(protocol != CURLPROTO_HTTP) { curl_mfprintf(stderr, "%s:%d protocol of http resource is incorrect; " - "expected %d but is %ld\n", + "expected %ld but is %ld\n", __FILE__, __LINE__, CURLPROTO_HTTP, protocol); res = CURLE_HTTP_RETURNED_ERROR; goto test_cleanup;