From: Viktor Szakats Date: Wed, 28 Jan 2026 14:24:09 +0000 (+0100) Subject: send: drop `CURL_UNCONST()` from buffer argument on most platforms X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f95c79a98827e7aa565ce748a7dee3e2752547cd;p=thirdparty%2Fcurl.git send: drop `CURL_UNCONST()` from buffer argument on most platforms Keep it on platforms requiring a non-const buffer. These are AmigaOS and OS400. Also: - replace `SEND_QUAL_ARG2` with boolean macro `SEND_NONCONST_ARG2`. Closes #20463 --- diff --git a/lib/config-mac.h b/lib/config-mac.h index 6c8acad722..8f32a51a3f 100644 --- a/lib/config-mac.h +++ b/lib/config-mac.h @@ -77,7 +77,6 @@ #define HAVE_SEND 1 #define SEND_TYPE_ARG1 int -#define SEND_QUAL_ARG2 const #define SEND_TYPE_ARG2 void * #define SEND_TYPE_ARG3 size_t #define SEND_TYPE_ARG4 int diff --git a/lib/config-os400.h b/lib/config-os400.h index 610b9cd36f..294d512a9f 100644 --- a/lib/config-os400.h +++ b/lib/config-os400.h @@ -256,8 +256,8 @@ /* Define to the type of arg 1 for send. */ #define SEND_TYPE_ARG1 int -/* Define to the type qualifier of arg 2 for send. */ -#define SEND_QUAL_ARG2 +/* Define if the type qualifier of arg 2 for send is not const. */ +#define SEND_NONCONST_ARG2 /* Define to the type of arg 2 for send. */ #define SEND_TYPE_ARG2 char * diff --git a/lib/config-riscos.h b/lib/config-riscos.h index ca8cd532b4..43f33e5086 100644 --- a/lib/config-riscos.h +++ b/lib/config-riscos.h @@ -213,9 +213,6 @@ /* Define to the type of arg 1 for send. */ #define SEND_TYPE_ARG1 int -/* Define to the type qualifier of arg 2 for send. */ -#define SEND_QUAL_ARG2 const - /* Define to the type of arg 2 for send. */ #define SEND_TYPE_ARG2 void * diff --git a/lib/config-win32.h b/lib/config-win32.h index 2609d57436..4d509573cf 100644 --- a/lib/config-win32.h +++ b/lib/config-win32.h @@ -156,9 +156,6 @@ /* Define to the type of arg 1 for send. */ #define SEND_TYPE_ARG1 SOCKET -/* Define to the type qualifier of arg 2 for send. */ -#define SEND_QUAL_ARG2 const - /* Define to the type of arg 2 for send. */ #define SEND_TYPE_ARG2 char * diff --git a/lib/curl_setup_once.h b/lib/curl_setup_once.h index 48ca36b560..8cd21f1110 100644 --- a/lib/curl_setup_once.h +++ b/lib/curl_setup_once.h @@ -144,9 +144,10 @@ struct timeval { * which is used to write outgoing data on a connected socket. * If yours has another name then do not define HAVE_SEND. * - * If HAVE_SEND is defined then SEND_TYPE_ARG1, SEND_QUAL_ARG2, - * SEND_TYPE_ARG2, SEND_TYPE_ARG3, SEND_TYPE_ARG4 and - * SEND_TYPE_RETV must also be defined. + * If HAVE_SEND is defined then SEND_TYPE_ARG1, SEND_TYPE_ARG2, + * SEND_TYPE_ARG3, SEND_TYPE_ARG4 and SEND_TYPE_RETV must also + * be defined. SEND_NONCONST_ARG2 must also be defined if ARG2 + * does not accept const. */ #define sread(x, y, z) (ssize_t)recv((RECV_TYPE_ARG1)(x), \ @@ -165,10 +166,17 @@ struct timeval { (SEND_TYPE_ARG2)CURL_UNCONST(y), \ (SEND_TYPE_ARG3)(z)) #elif defined(HAVE_SEND) +#ifdef SEND_NONCONST_ARG2 #define swrite(x, y, z) (ssize_t)send((SEND_TYPE_ARG1)(x), \ - (SEND_QUAL_ARG2 SEND_TYPE_ARG2)CURL_UNCONST(y), \ + (SEND_TYPE_ARG2)CURL_UNCONST(y), \ (SEND_TYPE_ARG3)(z), \ (SEND_TYPE_ARG4)(SEND_4TH_ARG)) +#else +#define swrite(x, y, z) (ssize_t)send((SEND_TYPE_ARG1)(x), \ + (const SEND_TYPE_ARG2)(y), \ + (SEND_TYPE_ARG3)(z), \ + (SEND_TYPE_ARG4)(SEND_4TH_ARG)) +#endif /* SEND_NONCONST_ARG2 */ #else /* HAVE_SEND */ #ifndef swrite #error "Missing definition of macro swrite!" diff --git a/lib/functypes.h b/lib/functypes.h index 12dfe17906..df3cfd44c8 100644 --- a/lib/functypes.h +++ b/lib/functypes.h @@ -59,9 +59,9 @@ #define RECV_TYPE_ARG4 long #define RECV_TYPE_RETV long -/* int send(int, const char *, int, int); */ +/* int send(int, char *, int, int); */ #define SEND_TYPE_ARG1 int -#define SEND_QUAL_ARG2 +#define SEND_NONCONST_ARG2 #define SEND_TYPE_ARG2 char * #define SEND_TYPE_ARG3 int #define SEND_TYPE_RETV int @@ -87,10 +87,6 @@ #define RECV_TYPE_RETV ssize_t #endif -#ifndef SEND_QUAL_ARG2 -#define SEND_QUAL_ARG2 const -#endif - #ifndef SEND_TYPE_ARG1 #define SEND_TYPE_ARG1 int #endif diff --git a/projects/vms/config_h.com b/projects/vms/config_h.com index ba66434ba0..e42ecd9d78 100644 --- a/projects/vms/config_h.com +++ b/projects/vms/config_h.com @@ -1582,13 +1582,6 @@ $! Process SEND directives $!------------------------------------- $ if key2a .eqs. "SEND" $ then -$ if key2 .eqs. "SEND_QUAL_ARG2" -$ then -$ write tf "#ifndef ''key2'" -$ write tf "#define ''key2' const" -$ write tf "#endif" -$ goto cfgh_in_loop1 -$ endif $ if key2 .eqs. "SEND_TYPE_ARG1" $ then $ write tf "#ifndef ''key2'"