tests: make individual test sources compile cleanly

Tidy up headers and includes to ensure all individual test source
compile cleanly (but not link). To allow running clang-tidy (and
possibly other static analyzers) on them. It also improves readability
and allows to verify them locally, without the bundle logic.

clang-tidy ignores #included C files, so it's blind to bundle C files
the include these tests. The current workaround of embedding has
a couple of downsides:. meaningless filenames and line numbers,
missing issues, messing up self header paths. Thus, running it on
individual sources would be beneficial.

Also:
- de-duplicate includes.
- untangle some includes.
- formatting/indentation fixes.
- merge `getpart.h` into `first.h`.

Ref: https://github.com/curl/curl/pull/17680#issuecomment-2991730158

Closes #17703
This commit is contained in:
Viktor Szakats 2025-06-22 01:10:59 +02:00
parent 4d4d09eb7f
commit 6a0cd4feb7
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
259 changed files with 440 additions and 570 deletions

View file

@ -21,7 +21,8 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
#include "curl_setup.h"
#include "first.h"
#include <stdlib.h>
/* Function
@ -57,24 +58,6 @@
/* based on sockfilt.c */
#ifndef UNDER_CE
#include <signal.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_NETINET_IN6_H
#include <netinet/in6.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
#include <curlx.h> /* from the private lib dir */
static const char *backendaddr = "127.0.0.1";
static unsigned short backendport = 0; /* default is use client's */
@ -824,7 +807,7 @@ static curl_socket_t socksd_sockdaemon(curl_socket_t sock,
#endif /* USE_IPV6 */
#ifdef USE_UNIX_SOCKETS
case AF_UNIX:
rc = bind_unix_socket(sock, unix_socket, &listener.sau);
rc = bind_unix_socket(sock, unix_socket, &listener.sau);
#endif
}