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:
Viktor Szakats 2026-06-10 13:03:41 +02:00
parent 2f3fa479dd
commit 97aed9c960
No known key found for this signature in database
43 changed files with 142 additions and 143 deletions

View file

@ -119,10 +119,10 @@ static CURLcode test_unit1304(const char *arg)
Curl_netrc_init(&store);
res = Curl_netrc_scan(data, &store, "example.com", NULL, arg, &cr_out);
fail_unless(res == NETRC_OK, "Host should have been found");
fail_unless(strncmp(Curl_creds_passwd(cr_out), "passwd", 6) == 0,
fail_unless(!strncmp(Curl_creds_passwd(cr_out), "passwd", 6),
"password should be 'passwd'");
fail_unless(!t1304_no_user(cr_out), "returned NULL!");
fail_unless(strncmp(Curl_creds_user(cr_out), "admin", 5) == 0,
fail_unless(!strncmp(Curl_creds_user(cr_out), "admin", 5),
"login should be 'admin'");
Curl_netrc_cleanup(&store);
@ -132,10 +132,10 @@ static CURLcode test_unit1304(const char *arg)
Curl_netrc_init(&store);
res = Curl_netrc_scan(data, &store, "curl.example.com", NULL, arg, &cr_out);
fail_unless(res == NETRC_OK, "Host should have been found");
fail_unless(strncmp(Curl_creds_passwd(cr_out), "none", 4) == 0,
fail_unless(!strncmp(Curl_creds_passwd(cr_out), "none", 4),
"password should be 'none'");
fail_unless(!t1304_no_user(cr_out), "returned NULL!");
fail_unless(strncmp(Curl_creds_user(cr_out), "none", 4) == 0,
fail_unless(!strncmp(Curl_creds_user(cr_out), "none", 4),
"login should be 'none'");
Curl_netrc_cleanup(&store);

View file

@ -50,13 +50,13 @@ static void t1620_parse(const char *input,
if(!unitfail) {
fail_unless(!userstr || !exp_username ||
strcmp(userstr, exp_username) == 0,
!strcmp(userstr, exp_username),
"userstr should be equal to exp_username");
fail_unless(!passwdstr || !exp_password ||
strcmp(passwdstr, exp_password) == 0,
!strcmp(passwdstr, exp_password),
"passwdstr should be equal to exp_password");
fail_unless(!options || !exp_options ||
strcmp(options, exp_options) == 0,
!strcmp(options, exp_options),
"options should be equal to exp_options");
}

View file

@ -56,11 +56,11 @@ static void t1663_parse(const char *input_data,
fail_unless(!!exp_host == !!host, "host expectation failed");
if(!unitfail) {
fail_unless(!dev || !exp_dev || strcmp(dev, exp_dev) == 0,
fail_unless(!dev || !exp_dev || !strcmp(dev, exp_dev),
"dev should be equal to exp_dev");
fail_unless(!iface || !exp_iface || strcmp(iface, exp_iface) == 0,
fail_unless(!iface || !exp_iface || !strcmp(iface, exp_iface),
"iface should be equal to exp_iface");
fail_unless(!host || !exp_host || strcmp(host, exp_host) == 0,
fail_unless(!host || !exp_host || !strcmp(host, exp_host),
"host should be equal to exp_host");
}

View file

@ -92,23 +92,22 @@ static CURLcode test_unit1676(const char *arg)
if(result == CURLE_OK) {
/* Walk certinfo entries to find dh(p), dh(g), and dh(pub_key) */
for(slist = data->info.certs.certinfo[0]; slist; slist = slist->next) {
if(strncmp(slist->data, "dh(p):", 6) == 0)
if(!strncmp(slist->data, "dh(p):", 6))
dhp_value = slist->data + 6;
else if(strncmp(slist->data, "dh(g):", 6) == 0)
else if(!strncmp(slist->data, "dh(g):", 6))
dhg_value = slist->data + 6;
else if(strncmp(slist->data, "dh(pub_key):", 12) == 0)
else if(!strncmp(slist->data, "dh(pub_key):", 12))
dhpk_value = slist->data + 12;
}
abort_unless(dhp_value, "dh(p) not found in certinfo");
abort_unless(dhg_value, "dh(g) not found in certinfo");
abort_unless(dhpk_value, "dh(pub_key) not found in certinfo");
fail_if(strcmp(dhp_value, dhg_value) == 0,
fail_if(!strcmp(dhp_value, dhg_value),
"dh(p) and dh(g) have the same value (bug: g re-reads p)");
fail_unless(strcmp(dhp_value, "17") == 0, "dh(p) expected 17 (0x11)");
fail_unless(strcmp(dhg_value, "34") == 0, "dh(g) expected 34 (0x22)");
fail_unless(strcmp(dhpk_value, "51") == 0,
"dh(pub_key) expected 51 (0x33)");
fail_unless(!strcmp(dhp_value, "17"), "dh(p) expected 17 (0x11)");
fail_unless(!strcmp(dhg_value, "34"), "dh(g) expected 34 (0x22)");
fail_unless(!strcmp(dhpk_value, "51"), "dh(pub_key) expected 51 (0x33)");
}
curl_easy_cleanup(data);

View file

@ -544,7 +544,7 @@ static CURLcode test_unit3205(const char *arg)
Curl_cipher_suite_get_str(test->id, buf, sizeof(buf), TRUE);
if(expect && strcmp(buf, expect) != 0) {
if(expect && strcmp(buf, expect)) {
curl_mfprintf(stderr, "Curl_cipher_suite_get_str FAILED for 0x%04x, "
"result = \"%s\", expected = \"%s\"\n",
test->id, buf, expect);
@ -559,17 +559,17 @@ static CURLcode test_unit3205(const char *arg)
/* suites matched by EDH alias will return the DHE name */
if(test->id >= 0x0011 && test->id < 0x0017) {
if(expect && memcmp(expect, "EDH-", 4) == 0) {
if(expect && !memcmp(expect, "EDH-", 4)) {
curlx_strcopy(alt, sizeof(alt), expect, strlen(expect));
expect = (const char *)memcpy(alt, "DHE-", sizeof("DHE-") - 1);
}
if(expect && memcmp(expect + 4, "EDH-", 4) == 0) {
if(expect && !memcmp(expect + 4, "EDH-", 4)) {
curlx_strcopy(alt, sizeof(alt), expect, strlen(expect));
expect = (const char *)memcpy(alt + 4, "DHE-", sizeof("DHE-") - 1) - 4;
}
}
if(expect && strcmp(buf, expect) != 0) {
if(expect && strcmp(buf, expect)) {
curl_mfprintf(stderr, "Curl_cipher_suite_get_str FAILED for 0x%04x, "
"result = \"%s\", expected = \"%s\"\n",
test->id, buf, expect);
@ -598,7 +598,7 @@ static CURLcode test_unit3205(const char *arg)
test->str, id, test->id);
unitfail++;
}
if(len > 64 || strncmp(ptr, test->str, len) != 0) {
if(len > 64 || strncmp(ptr, test->str, len)) {
curl_mfprintf(stderr, "Curl_cipher_suite_walk_str ABORT for \"%s\" "
"unexpected pointers\n",
test->str);