From: Daniel Stenberg Date: Thu, 13 Apr 2023 10:59:24 +0000 (+0200) Subject: cookie: address PVS nits X-Git-Tag: curl-8_1_0~146 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c79356d85235cdbd393c73f62ac36520f30db2fa;p=thirdparty%2Fcurl.git 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 --- diff --git a/lib/cookie.c b/lib/cookie.c index c974a54dbb..8c0b2b19b4 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -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 - replace_old = FALSE; - } - else if(!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 = 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