warnless: drop parts of the read/write preprocessor hack (Windows)

The `#undef` hack is no longer necessary after changing the redifitions
to not map back to the original symbols.

This makes it unnecessary to repeat the redefinitions after compiling
`warnless.c` itself (in unity mode).

Which in turns makes it unnecessary to include `warnless.h` again, to
trigger such redefinition.

This also means that `read`/`write` are now redefined on Windows from
the first inclusion of `warnless.h`.

Also:
- tests/server: drop a repeat `warnless.h` include, that is unnecessary
  after this patch.
- tests/unit: drop repeat `warnless.h` include.
- tests/libtest: drop repeat `warnless.h` includes.
- tests/libtest: formatting.

Follow-up to 2f312a14da #17619
Follow-up to 84338c4de2 #12331
Follow-up to 6239146e93

Closes #17673
This commit is contained in:
Viktor Szakats 2025-06-19 14:41:34 +02:00
parent 6c1a7541fb
commit 0042770157
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
97 changed files with 20 additions and 96 deletions

View file

@ -35,11 +35,6 @@
#endif /* __INTEL_COMPILER && __unix__ */
#ifdef _WIN32
#undef read
#undef write
#endif
#include <limits.h>
#define CURL_MASK_UCHAR ((unsigned char)~0)
@ -295,7 +290,3 @@ size_t curlx_sitouz(int sinum)
# pragma warning(pop)
#endif
}
/* Ensure that warnless.h redefinitions continue to have an effect
in "unity" builds. */
#undef HEADER_CURL_WARNLESS_H_REDEFS

View file

@ -57,11 +57,6 @@ unsigned short curlx_uitous(unsigned int uinum);
size_t curlx_sitouz(int sinum);
#endif /* HEADER_CURL_WARNLESS_H */
#ifndef HEADER_CURL_WARNLESS_H_REDEFS
#define HEADER_CURL_WARNLESS_H_REDEFS
#ifdef _WIN32
#undef read
#define read(fd, buf, count) (ssize_t)_read(fd, buf, curlx_uztoui(count))
@ -69,4 +64,4 @@ size_t curlx_sitouz(int sinum);
#define write(fd, buf, count) (ssize_t)_write(fd, buf, curlx_uztoui(count))
#endif
#endif /* HEADER_CURL_WARNLESS_H_REDEFS */
#endif /* HEADER_CURL_WARNLESS_H */

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
struct t1485_transfer_status {

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib1500(char *URL)

View file

@ -26,7 +26,6 @@
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#undef TEST_HANG_TIMEOUT

View file

@ -34,7 +34,6 @@
#include <limits.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib1502(char *URL)

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib1506(char *URL)

View file

@ -25,7 +25,6 @@
#include "testutil.h"
#include "timediff.h"
#include "warnless.h"
#include "memdebug.h"
/*

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib1508(char *URL)

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
size_t WriteOutput(char *ptr, size_t size, size_t nmemb, void *stream);

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib1510(char *URL)

View file

@ -29,9 +29,9 @@
*/
#include "test.h"
#include "testtrace.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define DNS_TIMEOUT 1L

View file

@ -27,7 +27,6 @@
#include "testtrace.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static int sockopt_callback(void *clientp, curl_socket_t curlfd,

View file

@ -26,7 +26,6 @@
/* test case and code based on https://github.com/curl/curl/issues/3927 */
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static int dload_progress_cb(void *a, curl_off_t b, curl_off_t c,

View file

@ -25,7 +25,6 @@
#include "testutil.h"
#include "timediff.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib1531(char *URL)

View file

@ -25,7 +25,6 @@
#include "testtrace.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
struct t1540_transfer_status {

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
struct t1541_transfer_status {

View file

@ -31,9 +31,9 @@
*/
#include "test.h"
#include "testutil.h"
#include "testtrace.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib1542(char *URL)

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib1552(char *URL)

View file

@ -25,7 +25,6 @@
#include "testutil.h"
#include "testtrace.h"
#include "warnless.h"
#include "memdebug.h"
static int t1553_xferinfo(void *p,

View file

@ -22,6 +22,7 @@
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
static const char *ldata_names[] = {

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
struct headerinfo {

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib1557(char *URL)

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib1558(char *URL)

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib1559(char *URL)

View file

@ -36,7 +36,6 @@
#endif
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h" /* LAST include file */
static int checkparts(CURLU *u, const char *in, const char *wanted,

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define WAKEUP_NUM 10

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#ifdef HAVE_PTHREAD_H

View file

@ -28,7 +28,9 @@
*/
#include "test.h"
#include <stdio.h>
#include "memdebug.h"
static size_t consumed = 0;

View file

@ -37,6 +37,7 @@
CI machines. */
#include "test.h"
#include "testutil.h"
#include <sys/stat.h>

View file

@ -28,7 +28,9 @@
*/
#include "test.h"
#include <stdio.h>
#include "memdebug.h"
/*

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib1900(char *URL)

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static size_t t1901_read_cb(char *ptr, size_t size, size_t nmemb, void *stream)

View file

@ -25,7 +25,6 @@
#include "testutil.h"
#include "timediff.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib1903(char *URL)

View file

@ -25,7 +25,6 @@
#include "testutil.h"
#include "timediff.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib1905(char *URL)

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib1906(char *URL)

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib1907(char *URL)

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib1908(char *URL)

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib1910(char *URL)

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
/* The maximum string length limit (CURL_MAX_INPUT_LENGTH) is an internal

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define print_err(name, exp) \

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib1913(char *URL)

View file

@ -25,7 +25,6 @@
#include "testtrace.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
struct state {

View file

@ -23,7 +23,6 @@
***************************************************************************/
#include "test.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib1916(char *URL)

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib1918(char *URL)

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib1919(char *URL)

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib1977(char *URL)

View file

@ -27,6 +27,7 @@
*/
#include "test.h"
#include "memdebug.h"
static CURLcode send_request(CURL *curl, const char *url, int seq,

View file

@ -27,7 +27,6 @@
#include <assert.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define MAX_EASY_HANDLES 3

View file

@ -22,6 +22,7 @@
*
***************************************************************************/
#include "test.h"
#include "testtrace.h"
static CURLcode test_lib2306(char *URL)

View file

@ -22,6 +22,7 @@
*
***************************************************************************/
#include "test.h"
#include "testtrace.h"
static size_t cb_curl(char *buffer, size_t size, size_t nmemb, void *userp)

View file

@ -22,6 +22,7 @@
*
***************************************************************************/
#include "test.h"
#include "testtrace.h"
static size_t cb_ignore(char *buffer, size_t size, size_t nmemb, void *userp)

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib2402(char *URL)

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib2404(char *URL)

View file

@ -40,7 +40,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
/* ---------------------------------------------------------------- */

View file

@ -25,7 +25,6 @@
#include "testtrace.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib2502(char *URL)

View file

@ -22,6 +22,7 @@
*
***************************************************************************/
#include "test.h"
#include "testtrace.h"
#include "memdebug.h"

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#define NUM_THREADS 100

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib3027(char *URL)

View file

@ -22,6 +22,7 @@
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
static CURLcode test_lib3100(char *URL)

View file

@ -22,6 +22,7 @@
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
static CURLcode test_lib3101(char *URL)

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib3105(char *URL)

View file

@ -22,6 +22,7 @@
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "memdebug.h"

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib3208(char *URL)

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
/*

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
/*

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
/*

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib507(char *URL)

View file

@ -28,7 +28,6 @@
#endif
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#ifndef FD_SETSIZE

View file

@ -26,7 +26,6 @@
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib525(char *URL)

View file

@ -45,7 +45,6 @@
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib526(char *URL)

View file

@ -33,7 +33,6 @@
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
struct t530_Sockets {

View file

@ -28,7 +28,6 @@
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib533(char *URL)

View file

@ -28,7 +28,6 @@
#endif
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#if !defined(HAVE_POLL) && !defined(USE_WINSOCK) && !defined(FD_SETSIZE)

View file

@ -35,7 +35,6 @@
#include <limits.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define PROXY libtest_arg2

View file

@ -27,7 +27,6 @@
#include "test.h"
#include "warnless.h"
#include "memdebug.h"
struct t552_testdata {

View file

@ -31,8 +31,8 @@
*/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static const char uploadthis[] = "this is the blurb we want to upload\n";

View file

@ -23,7 +23,6 @@
***************************************************************************/
#include "test.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib556(char *URL)

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
/*

View file

@ -26,7 +26,6 @@
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib564(char *URL)

View file

@ -40,7 +40,6 @@
#endif
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define RTP_PKT_CHANNEL(p) ((int)((unsigned char)((p)[1])))

View file

@ -25,7 +25,6 @@
#include "testtrace.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
/*

View file

@ -26,7 +26,6 @@
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
/* 3x download!

View file

@ -26,7 +26,6 @@
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
struct t582_Sockets {

View file

@ -22,6 +22,7 @@
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
#define THREADS 2

View file

@ -30,7 +30,6 @@
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib591(char *URL)

View file

@ -26,7 +26,6 @@
#include <limits.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
/*

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
/*

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
/*

View file

@ -22,6 +22,7 @@
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
static CURLcode test_lib661(char *URL)

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
/*

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static CURLcode test_lib677(char *URL)

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static int loadfile(const char *filename, void **filedata, size_t *filesize)

View file

@ -24,7 +24,6 @@
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
/*

View file

@ -25,7 +25,6 @@
#include "testutil.h"
#include "testtrace.h"
#include "warnless.h"
#include "memdebug.h"
struct t753_transfer_status {

View file

@ -102,7 +102,6 @@
#endif
#include <curlx.h> /* from the private lib dir */
#include "warnless.h" /* for read() */
/* include memdebug.h last */
#include <memdebug.h>

View file

@ -24,7 +24,6 @@
#include "curlcheck.h"
#include "splay.h"
#include "warnless.h"
static void splayprint(struct Curl_tree *t, int d, char output)
{