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

@ -79,7 +79,7 @@ int cgetopt(int argc, const char * const argv[], const char *optstring)
}
arg = argv[coptind];
if(arg && strcmp(arg, "--") == 0) {
if(arg && !strcmp(arg, "--")) {
coptind++;
return -1;
}
@ -248,7 +248,7 @@ int main(int argc, const char **argv)
entry_name = argv[1];
entry_func = NULL;
for(tmp = 0; s_entries[tmp].ptr; ++tmp) {
if(strcmp(entry_name, s_entries[tmp].name) == 0) {
if(!strcmp(entry_name, s_entries[tmp].name)) {
entry_func = s_entries[tmp].ptr;
break;
}

View file

@ -73,7 +73,7 @@ static CURLcode test_lib1536(const char *URL)
__FILE__, __LINE__, (int)result, curl_easy_strerror(result));
goto test_cleanup;
}
if(!scheme || memcmp(scheme, "http", 5) != 0) {
if(!scheme || memcmp(scheme, "http", 5)) {
curl_mfprintf(stderr, "%s:%d scheme of http resource is incorrect; "
"expected 'http' but is %s\n",
__FILE__, __LINE__, scheme ? "invalid" : "NULL");

View file

@ -2135,7 +2135,7 @@ static int clear_url(void)
rc = curl_url_get(u, clear_url_list[i].part, &p, 0);
if(rc != clear_url_list[i].ucode ||
(p && clear_url_list[i].out && strcmp(p, clear_url_list[i].out) != 0)) {
(p && clear_url_list[i].out && strcmp(p, clear_url_list[i].out))) {
curl_mfprintf(stderr, "unexpected return code line %d\n", __LINE__);
error++;

View file

@ -63,7 +63,7 @@ static bool is_chain_in_order(struct curl_certinfo *cert_info)
if(last_issuer) {
/* If the last certificate's issuer matches the current certificate's
* subject, then the chain is in order */
if(strcmp(last_issuer, subject) != 0) {
if(strcmp(last_issuer, subject)) {
curl_mfprintf(stderr,
"cert %d issuer does not match cert %d subject\n",
cert - 1, cert);

View file

@ -99,7 +99,7 @@ static int t518_test_rlimit(int keep_open)
/* get initial open file limits */
if(getrlimit(RLIMIT_NOFILE, &rl) != 0) {
if(getrlimit(RLIMIT_NOFILE, &rl)) {
t518_store_errmsg("getrlimit() failed", errno);
curl_mfprintf(stderr, "%s\n", t518_msgbuff);
return -1;
@ -135,7 +135,7 @@ static int t518_test_rlimit(int keep_open)
(rl.rlim_cur < OPEN_MAX)) {
curl_mfprintf(stderr, "raising soft limit up to OPEN_MAX\n");
rl.rlim_cur = OPEN_MAX;
if(setrlimit(RLIMIT_NOFILE, &rl) != 0) {
if(setrlimit(RLIMIT_NOFILE, &rl)) {
/* on failure do not abort, only issue a warning */
t518_store_errmsg("setrlimit() failed", errno);
curl_mfprintf(stderr, "%s\n", t518_msgbuff);
@ -146,7 +146,7 @@ static int t518_test_rlimit(int keep_open)
curl_mfprintf(stderr, "raising soft limit up to hard limit\n");
rl.rlim_cur = rl.rlim_max;
if(setrlimit(RLIMIT_NOFILE, &rl) != 0) {
if(setrlimit(RLIMIT_NOFILE, &rl)) {
/* on failure do not abort, only issue a warning */
t518_store_errmsg("setrlimit() failed", errno);
curl_mfprintf(stderr, "%s\n", t518_msgbuff);
@ -155,7 +155,7 @@ static int t518_test_rlimit(int keep_open)
/* get current open file limits */
if(getrlimit(RLIMIT_NOFILE, &rl) != 0) {
if(getrlimit(RLIMIT_NOFILE, &rl)) {
t518_store_errmsg("getrlimit() failed", errno);
curl_mfprintf(stderr, "%s\n", t518_msgbuff);
return -3;

View file

@ -96,7 +96,7 @@ static int t537_test_rlimit(int keep_open)
/* get initial open file limits */
if(getrlimit(RLIMIT_NOFILE, &rl) != 0) {
if(getrlimit(RLIMIT_NOFILE, &rl)) {
t537_store_errmsg("getrlimit() failed", errno);
curl_mfprintf(stderr, "%s\n", t537_msgbuff);
return -1;
@ -136,7 +136,7 @@ static int t537_test_rlimit(int keep_open)
(rl.rlim_cur < OPEN_MAX)) {
curl_mfprintf(stderr, "raising soft limit up to OPEN_MAX\n");
rl.rlim_cur = OPEN_MAX;
if(setrlimit(RLIMIT_NOFILE, &rl) != 0) {
if(setrlimit(RLIMIT_NOFILE, &rl)) {
/* on failure do not abort, only issue a warning */
t537_store_errmsg("setrlimit() failed", errno);
curl_mfprintf(stderr, "%s\n", t537_msgbuff);
@ -147,7 +147,7 @@ static int t537_test_rlimit(int keep_open)
curl_mfprintf(stderr, "raising soft limit up to hard limit\n");
rl.rlim_cur = rl.rlim_max;
if(setrlimit(RLIMIT_NOFILE, &rl) != 0) {
if(setrlimit(RLIMIT_NOFILE, &rl)) {
/* on failure do not abort, only issue a warning */
t537_store_errmsg("setrlimit() failed", errno);
curl_mfprintf(stderr, "%s\n", t537_msgbuff);
@ -156,7 +156,7 @@ static int t537_test_rlimit(int keep_open)
/* get current open file limits */
if(getrlimit(RLIMIT_NOFILE, &rl) != 0) {
if(getrlimit(RLIMIT_NOFILE, &rl)) {
t537_store_errmsg("getrlimit() failed", errno);
curl_mfprintf(stderr, "%s\n", t537_msgbuff);
return -3;

View file

@ -67,7 +67,7 @@ static size_t rtp_write(char *data, size_t size, size_t nmemb, void *stream)
data += 4;
for(i = 0; i < message_size; i += RTP_DATA_SIZE) {
if(message_size - i > RTP_DATA_SIZE) {
if(memcmp(RTP_DATA, data + i, RTP_DATA_SIZE) != 0) {
if(memcmp(RTP_DATA, data + i, RTP_DATA_SIZE)) {
curl_mprintf("RTP PAYLOAD CORRUPTED [%s]\n", data + i);
#if 0
return failure;
@ -75,7 +75,7 @@ static size_t rtp_write(char *data, size_t size, size_t nmemb, void *stream)
}
}
else {
if(memcmp(RTP_DATA, data + i, message_size - i) != 0) {
if(memcmp(RTP_DATA, data + i, message_size - i)) {
curl_mprintf("RTP PAYLOAD END CORRUPTED (%d), [%s]\n",
message_size - i, data + i);
#if 0

View file

@ -73,7 +73,7 @@ static long chunk_bgn(const void *f, void *ptr, int remains)
"-------------------------------------------"
"------------------\n");
}
if(strcmp(finfo->filename, "someothertext.txt") == 0) {
if(!strcmp(finfo->filename, "someothertext.txt")) {
curl_mprintf("# THIS CONTENT WAS SKIPPED IN CHUNK_BGN CALLBACK #\n");
return CURL_CHUNK_BGN_FUNC_SKIP;
}