Skip to content

Commit

Permalink
build: fix compiler warnings with auths disabled
Browse files Browse the repository at this point in the history
```
./curl/lib/http.c:737:12: warning: unused variable 'result' [-Wunused-variable]
  CURLcode result = CURLE_OK;
           ^
./curl/lib/http.c:1143:12: warning: empty expression statement has no effect; remove unnecessary ';' to silence this warning [-Wextra-semi-stmt]
           ;
           ^
./curl/lib/http.c:995:18: warning: variable 'availp' set but not used [-Wunused-but-set-variable]
  unsigned long *availp;
                 ^
./curl/lib/http.c:996:16: warning: variable 'authp' set but not used [-Wunused-but-set-variable]
  struct auth *authp;
               ^
./curl/lib/http.c:979:12: warning: unused function 'is_valid_auth_separator' [-Wunused-function]
static int is_valid_auth_separator(char ch)
           ^
5 warnings generated.
```

Follow-up to 0d3956b curl#11895
Follow-up to e92edfb curl#11490

Closes #xxxxx
  • Loading branch information
vszakats committed Oct 29, 2023
1 parent c868b0e commit 5f3edae
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions lib/http.c
Expand Up @@ -845,7 +845,7 @@ output_auth_headers(struct Curl_easy *data,
else
authstatus->multipass = FALSE;

return CURLE_OK;
return result;
}

/**
Expand Down Expand Up @@ -970,17 +970,21 @@ Curl_http_output_auth(struct Curl_easy *data,
}
#endif

/*
* Curl_http_input_auth() deals with Proxy-Authenticate: and WWW-Authenticate:
* headers. They are dealt with both in the transfer.c main loop and in the
* proxy CONNECT loop.
*/

#if defined(USE_SPNEGO) || defined(USE_NTLM) || \
!defined(CURL_DISABLE_DIGEST_AUTH) || \
!defined(CURL_DISABLE_BASIC_AUTH) || \
!defined(CURL_DISABLE_BEARER_AUTH)
static int is_valid_auth_separator(char ch)
{
return ch == '\0' || ch == ',' || ISSPACE(ch);
}
#endif

/*
* Curl_http_input_auth() deals with Proxy-Authenticate: and WWW-Authenticate:
* headers. They are dealt with both in the transfer.c main loop and in the
* proxy CONNECT loop.
*/
CURLcode Curl_http_input_auth(struct Curl_easy *data, bool proxy,
const char *auth) /* the first non-space */
{
Expand All @@ -995,7 +999,10 @@ CURLcode Curl_http_input_auth(struct Curl_easy *data, bool proxy,
unsigned long *availp;
struct auth *authp;

(void) conn; /* In case conditionals make it unused. */
/* In case conditionals make them unused. */
(void) conn;
(void) availp;
(void) authp;

if(proxy) {
availp = &data->info.proxyauthavail;
Expand Down Expand Up @@ -1046,9 +1053,9 @@ CURLcode Curl_http_input_auth(struct Curl_easy *data, bool proxy,
}
}
}
else
#endif
#ifdef USE_NTLM
else
/* NTLM support requires the SSL crypto libs */
if(checkprefix("NTLM", auth) && is_valid_auth_separator(auth[4])) {
if((authp->avail & CURLAUTH_NTLM) ||
Expand Down Expand Up @@ -1085,9 +1092,9 @@ CURLcode Curl_http_input_auth(struct Curl_easy *data, bool proxy,
}
}
}
else
#endif
#ifndef CURL_DISABLE_DIGEST_AUTH
else
if(checkprefix("Digest", auth) && is_valid_auth_separator(auth[6])) {
if((authp->avail & CURLAUTH_DIGEST) != 0)
infof(data, "Ignoring duplicate digest auth header.");
Expand All @@ -1108,9 +1115,9 @@ CURLcode Curl_http_input_auth(struct Curl_easy *data, bool proxy,
}
}
}
else
#endif
#ifndef CURL_DISABLE_BASIC_AUTH
else
if(checkprefix("Basic", auth) &&
is_valid_auth_separator(auth[5])) {
*availp |= CURLAUTH_BASIC;
Expand All @@ -1124,9 +1131,9 @@ CURLcode Curl_http_input_auth(struct Curl_easy *data, bool proxy,
data->state.authproblem = TRUE;
}
}
else
#endif
#ifndef CURL_DISABLE_BEARER_AUTH
else
if(checkprefix("Bearer", auth) &&
is_valid_auth_separator(auth[6])) {
*availp |= CURLAUTH_BEARER;
Expand All @@ -1139,8 +1146,6 @@ CURLcode Curl_http_input_auth(struct Curl_easy *data, bool proxy,
data->state.authproblem = TRUE;
}
}
#else
;
#endif

/* there may be multiple methods on one line, so keep reading */
Expand Down

0 comments on commit 5f3edae

Please sign in to comment.