cookie: address PVS nits

- avoid assigning the same value again
- remove superfluous check of co->domain
- reduce variable scope for namep/valuep

Ref: #10929
Closes #10954
This commit is contained in:
Daniel Stenberg 2023-04-13 12:59:24 +02:00
parent 4bc597d27c
commit c79356d852
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -515,8 +515,6 @@ Curl_cookie_add(struct Curl_easy *data,
if(httpheader) {
/* This line was read off an HTTP-header */
const char *namep;
const char *valuep;
const char *ptr;
size_t linelength = strlen(lineptr);
@ -539,8 +537,9 @@ Curl_cookie_add(struct Curl_easy *data,
if(nlen) {
bool done = FALSE;
bool sep = FALSE;
const char *namep = ptr;
const char *valuep;
namep = ptr;
ptr += nlen;
/* trim trailing spaces and tabs after name */
@ -1120,17 +1119,11 @@ Curl_cookie_add(struct Curl_easy *data,
if(replace_old) {
/* the domains were identical */
if(clist->spath && co->spath) {
if(strcasecompare(clist->spath, co->spath))
replace_old = TRUE;
else
if(clist->spath && co->spath &&
!strcasecompare(clist->spath, co->spath))
replace_old = FALSE;
}
else if(!clist->spath && !co->spath)
replace_old = TRUE;
else
else if(!clist->spath != !co->spath)
replace_old = FALSE;
}
if(replace_old && !co->livecookie && clist->livecookie) {
@ -1438,7 +1431,7 @@ struct Cookie *Curl_cookie_getlist(struct Curl_easy *data,
/* now check if the domain is correct */
if(!co->domain ||
(co->tailmatch && !is_ip &&
tailmatch(co->domain, co->domain? strlen(co->domain):0, host)) ||
tailmatch(co->domain, strlen(co->domain), host)) ||
((!co->tailmatch || is_ip) && strcasecompare(host, co->domain)) ) {
/*
* the right part of the host matches the domain stuff in the