mirror of
https://github.com/curl/curl.git
synced 2026-08-26 05:03:33 +03:00
tidy-up: avoid (()), clang-format fixes and more
- drop redundant parentheses from macro definitions. - apply clang-format in some places missed earlier. - wolfssl: fix a macro guard comment. - curl_setup.h: drop empty lines - FAQ: fix C formatting. Closes #19854
This commit is contained in:
parent
4e051ff550
commit
af5def0738
13 changed files with 404 additions and 374 deletions
|
|
@ -48,9 +48,9 @@
|
|||
|
||||
#define CPOOL_IS_LOCKED(c) ((c) && (c)->locked)
|
||||
|
||||
#define CPOOL_LOCK(c,d) \
|
||||
#define CPOOL_LOCK(c, d) \
|
||||
do { \
|
||||
if((c)) { \
|
||||
if(c) { \
|
||||
if(CURL_SHARE_KEEP_CONNECT((c)->share)) \
|
||||
Curl_share_lock((d), CURL_LOCK_DATA_CONNECT, \
|
||||
CURL_LOCK_ACCESS_SINGLE); \
|
||||
|
|
@ -61,7 +61,7 @@
|
|||
|
||||
#define CPOOL_UNLOCK(c,d) \
|
||||
do { \
|
||||
if((c)) { \
|
||||
if(c) { \
|
||||
DEBUGASSERT((c)->locked); \
|
||||
(c)->locked = FALSE; \
|
||||
if(CURL_SHARE_KEEP_CONNECT((c)->share)) \
|
||||
|
|
|
|||
|
|
@ -180,7 +180,6 @@
|
|||
* AIX 4.3 and newer needs _THREAD_SAFE defined to build
|
||||
* proper reentrant code. Others may also need it.
|
||||
*/
|
||||
|
||||
#ifdef NEED_THREAD_SAFE
|
||||
# ifndef _THREAD_SAFE
|
||||
# define _THREAD_SAFE
|
||||
|
|
@ -192,7 +191,6 @@
|
|||
* things to appear in the system header files. Unixware needs it
|
||||
* to build proper reentrant code. Others may also need it.
|
||||
*/
|
||||
|
||||
#ifdef NEED_REENTRANT
|
||||
# ifndef _REENTRANT
|
||||
# define _REENTRANT
|
||||
|
|
@ -219,7 +217,6 @@
|
|||
/*
|
||||
* Disable other protocols when http is the only one desired.
|
||||
*/
|
||||
|
||||
#ifdef HTTP_ONLY
|
||||
# ifndef CURL_DISABLE_DICT
|
||||
# define CURL_DISABLE_DICT
|
||||
|
|
@ -268,7 +265,6 @@
|
|||
/*
|
||||
* When http is disabled rtsp is not supported.
|
||||
*/
|
||||
|
||||
#if defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_RTSP)
|
||||
# define CURL_DISABLE_RTSP
|
||||
#endif
|
||||
|
|
@ -276,7 +272,6 @@
|
|||
/*
|
||||
* When HTTP is disabled, disable HTTP-only features
|
||||
*/
|
||||
|
||||
#ifdef CURL_DISABLE_HTTP
|
||||
# define CURL_DISABLE_ALTSVC 1
|
||||
# define CURL_DISABLE_COOKIES 1
|
||||
|
|
@ -298,7 +293,6 @@
|
|||
/*
|
||||
* OS/400 setup file includes some system headers.
|
||||
*/
|
||||
|
||||
#ifdef __OS400__
|
||||
# include "setup-os400.h"
|
||||
#endif
|
||||
|
|
@ -306,7 +300,6 @@
|
|||
/*
|
||||
* VMS setup file includes some system headers.
|
||||
*/
|
||||
|
||||
#ifdef __VMS
|
||||
# include "setup-vms.h"
|
||||
#endif
|
||||
|
|
@ -314,7 +307,6 @@
|
|||
/*
|
||||
* Windows setup file includes some system headers.
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
# include "setup-win32.h"
|
||||
#endif
|
||||
|
|
@ -340,7 +332,6 @@
|
|||
#endif
|
||||
|
||||
/* based on logic in "curl/mprintf.h" */
|
||||
|
||||
#if (defined(__GNUC__) || defined(__clang__) || \
|
||||
defined(__IAR_SYSTEMS_ICC__)) && \
|
||||
defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
|
||||
|
|
@ -612,10 +603,10 @@
|
|||
#if SIZEOF_LONG > SIZEOF_SIZE_T
|
||||
#error "unexpected: 'long' is larger than 'size_t'"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Arg 2 type for gethostname in case it has not been defined in config file.
|
||||
*/
|
||||
|
||||
#ifndef GETHOSTNAME_TYPE_ARG2
|
||||
# ifdef USE_WINSOCK
|
||||
# define GETHOSTNAME_TYPE_ARG2 int
|
||||
|
|
@ -625,10 +616,9 @@
|
|||
#endif
|
||||
|
||||
/* Below we define some functions. They should
|
||||
|
||||
4. set the SIGALRM signal timeout
|
||||
5. set dir/file naming defines
|
||||
*/
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
|
|
@ -664,7 +654,6 @@
|
|||
/*
|
||||
* Mutually exclusive CURLRES_* definitions.
|
||||
*/
|
||||
|
||||
#if defined(USE_IPV6) && defined(HAVE_GETADDRINFO)
|
||||
# define CURLRES_IPV6
|
||||
#elif defined(USE_IPV6) && (defined(_WIN32) || defined(__CYGWIN__))
|
||||
|
|
@ -792,7 +781,6 @@
|
|||
/*
|
||||
* Include macros and defines that should only be processed once.
|
||||
*/
|
||||
|
||||
#ifndef HEADER_CURL_SETUP_ONCE_H
|
||||
#include "curl_setup_once.h"
|
||||
#endif
|
||||
|
|
@ -800,7 +788,6 @@
|
|||
/*
|
||||
* Definition of our NOP statement Object-like macro
|
||||
*/
|
||||
|
||||
#ifndef Curl_nop_stmt
|
||||
#define Curl_nop_stmt do { } while(0)
|
||||
#endif
|
||||
|
|
@ -808,7 +795,6 @@
|
|||
/*
|
||||
* Ensure that Winsock and lwIP TCP/IP stacks are not mixed.
|
||||
*/
|
||||
|
||||
#if defined(__LWIP_OPT_H__) || defined(LWIP_HDR_OPT_H)
|
||||
# if defined(SOCKET) || defined(USE_WINSOCK)
|
||||
# error "Winsock and lwIP TCP/IP stack definitions shall not coexist!"
|
||||
|
|
@ -818,7 +804,6 @@
|
|||
/*
|
||||
* shutdown() flags for systems that do not define them
|
||||
*/
|
||||
|
||||
#ifndef SHUT_RD
|
||||
#define SHUT_RD 0x00
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -181,15 +181,15 @@ struct timeval {
|
|||
* Function-like macro definition used to close a socket.
|
||||
*/
|
||||
#ifdef HAVE_CLOSESOCKET
|
||||
# define CURL_SCLOSE(x) closesocket((x))
|
||||
# define CURL_SCLOSE(x) closesocket(x)
|
||||
#elif defined(HAVE_CLOSESOCKET_CAMEL)
|
||||
# define CURL_SCLOSE(x) CloseSocket((x))
|
||||
# define CURL_SCLOSE(x) CloseSocket(x)
|
||||
#elif defined(MSDOS) /* Watt-32 */
|
||||
# define CURL_SCLOSE(x) close_s((x))
|
||||
# define CURL_SCLOSE(x) close_s(x)
|
||||
#elif defined(USE_LWIPSOCK)
|
||||
# define CURL_SCLOSE(x) lwip_close((x))
|
||||
# define CURL_SCLOSE(x) lwip_close(x)
|
||||
#else
|
||||
# define CURL_SCLOSE(x) close((x))
|
||||
# define CURL_SCLOSE(x) close(x)
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -39,12 +39,13 @@ const char Curl_base64encdec[] =
|
|||
static const char base64url[] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
||||
|
||||
static const unsigned char decodetable[] =
|
||||
{ 62, 255, 255, 255, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, 255,
|
||||
255, 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
|
||||
17, 18, 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 255, 255, 26, 27, 28,
|
||||
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
|
||||
48, 49, 50, 51 };
|
||||
static const unsigned char decodetable[] = {
|
||||
62, 255, 255, 255, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255,
|
||||
255, 255, 255, 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
||||
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
|
||||
255, 255, 255, 255, 255, 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
|
||||
36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
|
||||
};
|
||||
/*
|
||||
* curlx_base64_decode()
|
||||
*
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@
|
|||
wchar_t *curlx_convert_UTF8_to_wchar(const char *str_utf8);
|
||||
char *curlx_convert_wchar_to_UTF8(const wchar_t *str_w);
|
||||
|
||||
#define curlx_convert_UTF8_to_tchar(ptr) curlx_convert_UTF8_to_wchar((ptr))
|
||||
#define curlx_convert_tchar_to_UTF8(ptr) curlx_convert_wchar_to_UTF8((ptr))
|
||||
#define curlx_convert_UTF8_to_tchar(ptr) curlx_convert_UTF8_to_wchar(ptr)
|
||||
#define curlx_convert_tchar_to_UTF8(ptr) curlx_convert_wchar_to_UTF8(ptr)
|
||||
|
||||
typedef union {
|
||||
unsigned short *tchar_ptr;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ struct Curl_str {
|
|||
void curlx_str_init(struct Curl_str *out);
|
||||
void curlx_str_assign(struct Curl_str *out, const char *str, size_t len);
|
||||
|
||||
#define curlx_str(x) ((x)->str)
|
||||
#define curlx_str(x) ((x)->str)
|
||||
#define curlx_strlen(x) ((x)->len)
|
||||
|
||||
/* Get a word until the first space
|
||||
|
|
|
|||
|
|
@ -1515,7 +1515,7 @@ static CURLcode wssl_connect_step1(struct Curl_cfilter *cf,
|
|||
wolfSSL_BIO_set_data(bio, cf);
|
||||
wolfSSL_set_bio(wssl->ssl, bio, bio);
|
||||
}
|
||||
#else /* USE_BIO_CHAIN */
|
||||
#else /* !USE_BIO_CHAIN */
|
||||
curl_socket_t sockfd = Curl_conn_cf_get_socket(cf, data);
|
||||
if(sockfd > INT_MAX) {
|
||||
failf(data, "SSL: socket value too large");
|
||||
|
|
@ -1526,7 +1526,7 @@ static CURLcode wssl_connect_step1(struct Curl_cfilter *cf,
|
|||
failf(data, "SSL: wolfSSL_set_fd failed");
|
||||
return CURLE_SSL_CONNECT_ERROR;
|
||||
}
|
||||
#endif /* !USE_BIO_CHAIN */
|
||||
#endif /* USE_BIO_CHAIN */
|
||||
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue