mirror of
https://github.com/curl/curl.git
synced 2026-04-14 22:31:41 +03:00
build: fully omit verbose strings and code when disabled
When the compiler supports C99.
- map logging functions to macro stubs when verbose logging is disabled
and the compiler is C99. Make sure these stubs silence unused variable
warnings for non-variadic arguments.
Before this patch they mapped to function stubs, the same codepath
used for C89 compiler in this configuration.
- introduce new macros to tell the compiler which code to include
when verbose code is active, or inactive:
- `CURLVERBOSE`: defined when verbose code is active.
To enclose blocks of code only used for verbose logging.
- `VERBOSE(statement);`:
compile statement when verbose code is active.
To mark code lines only used for verbose logging.
- `NOVERBOSE(statement);`:
compile statement when verbose code is inactive.
To suppress warnings for arguments passed to logging functions via
printf masks, e.g. `NOVERBOSE((void)ipaddress);`, yet keeping
the warning in verbose builds.
Note these macros are not the same as `CURL_DISABLE_VERBOSE_STRINGS`.
Verbose code is always active in C89 mode (without variadic macro
support).
- drop existing uses of `CURL_DISABLE_VERBOSE_STRINGS` where redundant,
or replace with the above macros. Ending up reducing the number of
`#ifdef`s, and also the number of lines.
Assisted-by: Daniel Stenberg
Assisted-by: Jay Satiro
Reported-by: Dan Fandrich
Fixes #20341
Refs: #12105 #12167
Closes #20353
This commit is contained in:
parent
e286589c71
commit
61093e2a81
49 changed files with 294 additions and 265 deletions
11
lib/url.c
11
lib/url.c
|
|
@ -1533,7 +1533,7 @@ static void zonefrom_url(CURLU *uh, struct Curl_easy *data,
|
|||
{
|
||||
char *zoneid;
|
||||
CURLUcode uc = curl_url_get(uh, CURLUPART_ZONEID, &zoneid, 0);
|
||||
#if !defined(HAVE_IF_NAMETOINDEX) || defined(CURL_DISABLE_VERBOSE_STRINGS)
|
||||
#if !defined(HAVE_IF_NAMETOINDEX) || !defined(CURLVERBOSE)
|
||||
(void)data;
|
||||
#endif
|
||||
|
||||
|
|
@ -1549,7 +1549,7 @@ static void zonefrom_url(CURLU *uh, struct Curl_easy *data,
|
|||
unsigned int scopeidx = 0;
|
||||
scopeidx = if_nametoindex(zoneid);
|
||||
if(!scopeidx) {
|
||||
#ifndef CURL_DISABLE_VERBOSE_STRINGS
|
||||
#ifdef CURLVERBOSE
|
||||
char buffer[STRERROR_LEN];
|
||||
infof(data, "Invalid zoneid: %s; %s", zoneid,
|
||||
curlx_strerror(errno, buffer, sizeof(buffer)));
|
||||
|
|
@ -1903,7 +1903,8 @@ static char *detect_proxy(struct Curl_easy *data,
|
|||
* checked if the lowercase versions do not exist.
|
||||
*/
|
||||
char proxy_env[20];
|
||||
const char *envp = proxy_env;
|
||||
const char *envp;
|
||||
VERBOSE(envp = proxy_env);
|
||||
|
||||
curl_msnprintf(proxy_env, sizeof(proxy_env), "%s_proxy",
|
||||
conn->scheme->name);
|
||||
|
|
@ -3457,8 +3458,8 @@ static CURLcode create_conn(struct Curl_easy *data,
|
|||
* `existing` and thus we need to cleanup the one we just
|
||||
* allocated before we can move along and use `existing`.
|
||||
*/
|
||||
bool tls_upgraded = (!(conn->given->flags & PROTOPT_SSL) &&
|
||||
Curl_conn_is_ssl(conn, FIRSTSOCKET));
|
||||
VERBOSE(bool tls_upgraded = (!(conn->given->flags & PROTOPT_SSL) &&
|
||||
Curl_conn_is_ssl(conn, FIRSTSOCKET)));
|
||||
|
||||
reuse_conn(data, conn, existing);
|
||||
conn = existing;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue