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
This commit is contained in:
Viktor Szakats 2026-01-28 15:24:09 +01:00
parent d60f1006b0
commit f95c79a988
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
7 changed files with 16 additions and 26 deletions

View File

@ -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

View File

@ -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 *

View File

@ -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 *

View File

@ -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 *

View File

@ -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!"

View File

@ -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

View File

@ -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'"