mirror of
https://github.com/curl/curl.git
synced 2026-08-25 22:23:53 +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
|
|
@ -251,7 +251,7 @@ static LIBSSH2_FREE_FUNC(my_libssh2_free)
|
|||
Curl_cfree(ptr);
|
||||
}
|
||||
|
||||
#ifndef CURL_DISABLE_VERBOSE_STRINGS
|
||||
#ifdef CURLVERBOSE
|
||||
static const char *myssh_statename(sshstate state)
|
||||
{
|
||||
static const char * const names[] = {
|
||||
|
|
@ -322,7 +322,7 @@ static const char *myssh_statename(sshstate state)
|
|||
}
|
||||
#else
|
||||
#define myssh_statename(x) ""
|
||||
#endif /* !CURL_DISABLE_VERBOSE_STRINGS */
|
||||
#endif /* CURLVERBOSE */
|
||||
|
||||
#define myssh_state(x, y, z) myssh_set_state(x, y, z)
|
||||
|
||||
|
|
@ -334,7 +334,7 @@ static void myssh_set_state(struct Curl_easy *data,
|
|||
struct ssh_conn *sshc,
|
||||
sshstate nowstate)
|
||||
{
|
||||
#ifndef CURL_DISABLE_VERBOSE_STRINGS
|
||||
#ifdef CURLVERBOSE
|
||||
if(sshc->state != nowstate) {
|
||||
CURL_TRC_SSH(data, "[%s] -> [%s]",
|
||||
myssh_statename(sshc->state),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue