mirror of
https://github.com/curl/curl.git
synced 2026-07-28 21:23:06 +03:00
tidy-up: drop stray comparisons with literal zero
Drop from: - strcmp, strcmpi, strncmp, memcmp, lstat, getrlimit, setrlimit, fseek, fstat - autotools detection snippets. - smooth-gtk-thread: simplify `!var != 0` expression. Closes #21947
This commit is contained in:
parent
2f3fa479dd
commit
97aed9c960
43 changed files with 142 additions and 143 deletions
|
|
@ -576,7 +576,7 @@ static int proxy_h2_on_header(nghttp2_session *session,
|
|||
}
|
||||
|
||||
if(namelen == sizeof(HTTP_PSEUDO_STATUS) - 1 &&
|
||||
memcmp(HTTP_PSEUDO_STATUS, name, namelen) == 0) {
|
||||
!memcmp(HTTP_PSEUDO_STATUS, name, namelen)) {
|
||||
int http_status;
|
||||
struct http_resp *resp;
|
||||
|
||||
|
|
|
|||
|
|
@ -687,7 +687,7 @@ static CURLcode parse_netscape(struct Cookie *co,
|
|||
* Firefox's cookie files, they are prefixed #HttpOnly_ and the rest
|
||||
* remains as usual, so we skip 10 characters of the line.
|
||||
*/
|
||||
if(strncmp(lineptr, "#HttpOnly_", 10) == 0) {
|
||||
if(!strncmp(lineptr, "#HttpOnly_", 10)) {
|
||||
lineptr += 10;
|
||||
co->httponly = TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,25 +96,25 @@ static int parsekeyword(const unsigned char **pattern, unsigned char *charset)
|
|||
#undef KEYLEN
|
||||
|
||||
*pattern = p; /* move caller's pattern pointer */
|
||||
if(strcmp(keyword, "digit") == 0)
|
||||
if(!strcmp(keyword, "digit"))
|
||||
charset[CURLFNM_DIGIT] = 1;
|
||||
else if(strcmp(keyword, "alnum") == 0)
|
||||
else if(!strcmp(keyword, "alnum"))
|
||||
charset[CURLFNM_ALNUM] = 1;
|
||||
else if(strcmp(keyword, "alpha") == 0)
|
||||
else if(!strcmp(keyword, "alpha"))
|
||||
charset[CURLFNM_ALPHA] = 1;
|
||||
else if(strcmp(keyword, "xdigit") == 0)
|
||||
else if(!strcmp(keyword, "xdigit"))
|
||||
charset[CURLFNM_XDIGIT] = 1;
|
||||
else if(strcmp(keyword, "print") == 0)
|
||||
else if(!strcmp(keyword, "print"))
|
||||
charset[CURLFNM_PRINT] = 1;
|
||||
else if(strcmp(keyword, "graph") == 0)
|
||||
else if(!strcmp(keyword, "graph"))
|
||||
charset[CURLFNM_GRAPH] = 1;
|
||||
else if(strcmp(keyword, "space") == 0)
|
||||
else if(!strcmp(keyword, "space"))
|
||||
charset[CURLFNM_SPACE] = 1;
|
||||
else if(strcmp(keyword, "blank") == 0)
|
||||
else if(!strcmp(keyword, "blank"))
|
||||
charset[CURLFNM_BLANK] = 1;
|
||||
else if(strcmp(keyword, "upper") == 0)
|
||||
else if(!strcmp(keyword, "upper"))
|
||||
charset[CURLFNM_UPPER] = 1;
|
||||
else if(strcmp(keyword, "lower") == 0)
|
||||
else if(!strcmp(keyword, "lower"))
|
||||
charset[CURLFNM_LOWER] = 1;
|
||||
else
|
||||
return SETCHARSET_FAIL;
|
||||
|
|
|
|||
|
|
@ -939,7 +939,7 @@ static CURLcode parse_winnt(struct Curl_easy *data,
|
|||
parser->item_length++;
|
||||
if(c == ' ') {
|
||||
mem[parser->item_offset + parser->item_length - 1] = 0;
|
||||
if(strcmp("<DIR>", mem + parser->item_offset) == 0) {
|
||||
if(!strcmp("<DIR>", mem + parser->item_offset)) {
|
||||
finfo->filetype = CURLFILETYPE_DIRECTORY;
|
||||
finfo->size = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1505,7 +1505,7 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
|
|||
}
|
||||
|
||||
if(namelen == sizeof(HTTP_PSEUDO_STATUS) - 1 &&
|
||||
memcmp(HTTP_PSEUDO_STATUS, name, namelen) == 0) {
|
||||
!memcmp(HTTP_PSEUDO_STATUS, name, namelen)) {
|
||||
/* nghttp2 guarantees :status is received first and only once. */
|
||||
char buffer[32];
|
||||
size_t hlen;
|
||||
|
|
|
|||
|
|
@ -512,7 +512,7 @@ CURLcode Curl_http_proxy_inspect_tunnel_response(
|
|||
capsule_protocol = Curl_dynhds_cget(&resp->headers,
|
||||
"capsule-protocol");
|
||||
if(capsule_protocol) {
|
||||
if(strncmp(capsule_protocol->value, "?1", 2) == 0 &&
|
||||
if(!strncmp(capsule_protocol->value, "?1", 2) &&
|
||||
!capsule_protocol->value[2]) {
|
||||
infof(data, "CONNECT-UDP tunnel established, response %d",
|
||||
resp->status);
|
||||
|
|
|
|||
|
|
@ -658,7 +658,7 @@ static CURLcode rtsp_filter_rtp(struct Curl_easy *data,
|
|||
while(blen && buf[0] != '$') {
|
||||
if(!in_body && buf[0] == 'R' &&
|
||||
data->set.rtspreq != RTSPREQ_RECEIVE) {
|
||||
if(strncmp(buf, "RTSP/", (blen < 5) ? blen : 5) == 0) {
|
||||
if(!strncmp(buf, "RTSP/", (blen < 5) ? blen : 5)) {
|
||||
/* This could be the next response, no consume and return */
|
||||
if(*pconsumed) {
|
||||
DEBUGF(infof(data, "RTP rtsp_filter_rtp[SKIP] RTSP/ prefix, "
|
||||
|
|
|
|||
|
|
@ -379,7 +379,7 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data,
|
|||
return result;
|
||||
|
||||
/* We only support md5 sessions */
|
||||
if(strcmp(algorithm, "md5-sess") != 0)
|
||||
if(strcmp(algorithm, "md5-sess"))
|
||||
return CURLE_BAD_CONTENT_ENCODING;
|
||||
|
||||
/* Get the qop-values from the qop-options */
|
||||
|
|
|
|||
|
|
@ -361,8 +361,8 @@ CURLcode Curl_auth_decode_ntlm_type2_message(struct Curl_easy *data,
|
|||
ntlm->flags = 0;
|
||||
|
||||
if((type2len < 32) ||
|
||||
(memcmp(type2, NTLMSSP_SIGNATURE, 8) != 0) ||
|
||||
(memcmp(type2 + 8, type2_marker, sizeof(type2_marker)) != 0)) {
|
||||
memcmp(type2, NTLMSSP_SIGNATURE, 8) ||
|
||||
memcmp(type2 + 8, type2_marker, sizeof(type2_marker))) {
|
||||
/* This was not a good enough type-2 message */
|
||||
infof(data, "NTLM handshake failure (bad type-2 message)");
|
||||
return CURLE_BAD_CONTENT_ENCODING;
|
||||
|
|
|
|||
|
|
@ -662,14 +662,14 @@ static CURLcode ssh_force_knownhost_key_type(struct Curl_easy *data,
|
|||
if(!curlx_str_number(&p, &port, 0xffff) &&
|
||||
(kh_name_end && (port == conn->origin->port))) {
|
||||
kh_name_size = strlen(store->name) - 1 - strlen(kh_name_end);
|
||||
if(strncmp(store->name + 1,
|
||||
conn->origin->hostname, kh_name_size) == 0) {
|
||||
if(!strncmp(store->name + 1, conn->origin->hostname,
|
||||
kh_name_size)) {
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(strcmp(store->name, conn->origin->hostname) == 0) {
|
||||
else if(!strcmp(store->name, conn->origin->hostname)) {
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -639,7 +639,7 @@ uint16_t Curl_cipher_suite_lookup_id(const char *cs_str, size_t cs_len)
|
|||
|
||||
if(cs_len > 0 && cs_str_to_zip(cs_str, cs_len, zip) == 0) {
|
||||
for(i = 0; i < CS_LIST_LEN; i++) {
|
||||
if(memcmp(cs_list[i].zip, zip, sizeof(zip)) == 0)
|
||||
if(!memcmp(cs_list[i].zip, zip, sizeof(zip)))
|
||||
return cs_list[i].id;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -205,12 +205,12 @@ static gnutls_datum_t load_file(const char *file)
|
|||
f = curlx_fopen(file, "rb");
|
||||
if(!f)
|
||||
return loaded_file;
|
||||
if(fseek(f, 0, SEEK_END) != 0)
|
||||
if(fseek(f, 0, SEEK_END))
|
||||
goto out;
|
||||
filelen = ftell(f);
|
||||
if(filelen < 0 || filelen > CURL_MAX_INPUT_LENGTH)
|
||||
goto out;
|
||||
if(fseek(f, 0, SEEK_SET) != 0)
|
||||
if(fseek(f, 0, SEEK_SET))
|
||||
goto out;
|
||||
ptr = curlx_malloc((size_t)filelen);
|
||||
if(!ptr)
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ static CURLcode mbed_set_selected_ciphers(
|
|||
/* Add default TLSv1.3 ciphers to selection */
|
||||
for(j = 0; j < supported_len; j++) {
|
||||
uint16_t id = (uint16_t)supported[j];
|
||||
if(strncmp(mbedtls_ssl_get_ciphersuite_name(id), "TLS1-3", 6) != 0)
|
||||
if(strncmp(mbedtls_ssl_get_ciphersuite_name(id), "TLS1-3", 6))
|
||||
continue;
|
||||
|
||||
selected[count++] = id;
|
||||
|
|
@ -360,7 +360,7 @@ add_ciphers:
|
|||
/* Add default TLSv1.2 ciphers to selection */
|
||||
for(j = 0; j < supported_len; j++) {
|
||||
uint16_t id = (uint16_t)supported[j];
|
||||
if(strncmp(mbedtls_ssl_get_ciphersuite_name(id), "TLS1-3", 6) == 0)
|
||||
if(!strncmp(mbedtls_ssl_get_ciphersuite_name(id), "TLS1-3", 6))
|
||||
continue;
|
||||
|
||||
/* No duplicates allowed (so selected cannot overflow) */
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ static const char *c_memmem(const void *haystack, size_t haystacklen,
|
|||
return NULL;
|
||||
first = *(const char *)needle;
|
||||
for(p = (const char *)haystack; p <= (str_limit - needlelen); p++)
|
||||
if(((*p) == first) && (memcmp(p, needle, needlelen) == 0))
|
||||
if(((*p) == first) && !memcmp(p, needle, needlelen))
|
||||
return p;
|
||||
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -856,7 +856,7 @@ static CURLcode wssl_add_default_ciphers(bool tls13, struct dynbuf *buf)
|
|||
|
||||
for(i = 0; (str = wolfSSL_get_cipher_list(i)) != NULL; i++) {
|
||||
size_t n;
|
||||
if((strncmp(str, "TLS13", 5) == 0) != tls13)
|
||||
if((!strncmp(str, "TLS13", 5)) != tls13)
|
||||
continue;
|
||||
|
||||
/* if there already is data in the string, add colon separator */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue