mirror of
https://github.com/curl/curl.git
synced 2026-08-26 11:43:32 +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
|
|
@ -394,7 +394,7 @@ static CURLcode http_perhapsrewind(struct Curl_easy *data,
|
|||
* amount remains. This may be overridden by authentications further
|
||||
* below! */
|
||||
bool abort_upload = (!data->req.upload_done && !little_upload_remains);
|
||||
const char *ongoing_auth = NULL;
|
||||
VERBOSE(const char *ongoing_auth = NULL);
|
||||
|
||||
/* We need a rewind before uploading client read data again. The
|
||||
* checks below just influence of the upload is to be continued
|
||||
|
|
@ -416,7 +416,7 @@ static CURLcode http_perhapsrewind(struct Curl_easy *data,
|
|||
#ifdef USE_NTLM
|
||||
if((data->state.authproxy.picked == CURLAUTH_NTLM) ||
|
||||
(data->state.authhost.picked == CURLAUTH_NTLM)) {
|
||||
ongoing_auth = "NTLM";
|
||||
VERBOSE(ongoing_auth = "NTLM");
|
||||
if((conn->http_ntlm_state != NTLMSTATE_NONE) ||
|
||||
(conn->proxy_ntlm_state != NTLMSTATE_NONE)) {
|
||||
/* The NTLM-negotiation has started, keep on sending.
|
||||
|
|
@ -429,7 +429,7 @@ static CURLcode http_perhapsrewind(struct Curl_easy *data,
|
|||
/* There is still data left to send */
|
||||
if((data->state.authproxy.picked == CURLAUTH_NEGOTIATE) ||
|
||||
(data->state.authhost.picked == CURLAUTH_NEGOTIATE)) {
|
||||
ongoing_auth = "NEGOTIATE";
|
||||
VERBOSE(ongoing_auth = "NEGOTIATE");
|
||||
if((conn->http_negotiate_state != GSS_AUTHNONE) ||
|
||||
(conn->proxy_negotiate_state != GSS_AUTHNONE)) {
|
||||
/* The NEGOTIATE-negotiation has started, keep on sending.
|
||||
|
|
@ -1101,8 +1101,10 @@ CURLcode Curl_http_input_auth(struct Curl_easy *data, bool proxy,
|
|||
static void http_switch_to_get(struct Curl_easy *data, int code)
|
||||
{
|
||||
const char *req = data->set.str[STRING_CUSTOMREQUEST];
|
||||
|
||||
if((req || data->state.httpreq != HTTPREQ_GET) &&
|
||||
(data->set.http_follow_mode == CURLFOLLOW_OBEYCODE)) {
|
||||
NOVERBOSE((void)code);
|
||||
infof(data, "Switch to GET because of %d response", code);
|
||||
data->state.http_ignorecustom = TRUE;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue