summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2021-12-25 21:41:14 +0100
committerDaniel Stenberg <daniel@haxx.se>2021-12-27 23:39:26 +0100
commit21248e052dbd0db33e8999aeeb919fb6f32c9567 (patch)
tree3345ae3b11c349ea56a58a387083fece2673e60c
parentacaa79f961a6fd4cde83ea16b5fb85f0a32c7f23 (diff)
downloadcurl-21248e052dbd0db33e8999aeeb919fb6f32c9567.tar.gz
checksrc: detect more kinds of NULL comparisons we avoid
Co-authored-by: Jay Satiro Closes #8180
-rw-r--r--docs/examples/rtsp.c8
-rw-r--r--docs/examples/synctime.c2
-rwxr-xr-xlib/checksrc.pl2
-rw-r--r--lib/cookie.c2
-rw-r--r--lib/easy.c2
-rw-r--r--lib/ftp.c6
-rw-r--r--lib/hostcheck.c2
-rw-r--r--lib/http.c4
-rw-r--r--lib/if2ip.c4
-rw-r--r--lib/inet_pton.c6
-rw-r--r--lib/krb5.c2
-rw-r--r--lib/ldap.c2
-rw-r--r--lib/md4.c4
-rw-r--r--lib/mprintf.c2
-rw-r--r--lib/splay.c2
-rw-r--r--lib/url.c6
-rw-r--r--lib/vauth/digest.c4
-rw-r--r--lib/vtls/gtls.c8
-rw-r--r--lib/vtls/nss.c22
-rw-r--r--lib/vtls/rustls.c2
-rw-r--r--lib/vtls/schannel.c8
-rw-r--r--lib/vtls/sectransp.c30
-rw-r--r--src/tool_dirhie.c6
-rw-r--r--src/tool_main.c2
-rw-r--r--src/tool_xattr.c2
-rw-r--r--tests/libtest/lib1536.c2
-rw-r--r--tests/libtest/lib1565.c2
-rw-r--r--tests/libtest/lib505.c4
-rw-r--r--tests/libtest/lib518.c2
-rw-r--r--tests/libtest/lib525.c4
-rw-r--r--tests/libtest/lib530.c2
-rw-r--r--tests/libtest/lib537.c2
-rw-r--r--tests/libtest/lib540.c4
-rw-r--r--tests/libtest/lib541.c4
-rw-r--r--tests/libtest/lib582.c6
-rw-r--r--tests/unit/unit1309.c2
36 files changed, 87 insertions, 87 deletions
diff --git a/docs/examples/rtsp.c b/docs/examples/rtsp.c
index 6f27b57ed..ca6bcfe13 100644
--- a/docs/examples/rtsp.c
+++ b/docs/examples/rtsp.c
@@ -154,7 +154,7 @@ static void get_sdp_filename(const char *url, char *sdp_filename,
{
const char *s = strrchr(url, '/');
strcpy(sdp_filename, "video.sdp");
- if(s != NULL) {
+ if(s) {
s++;
if(s[0] != '\0') {
snprintf(sdp_filename, namelen, "%s.sdp", s);
@@ -171,8 +171,8 @@ static void get_media_control_attribute(const char *sdp_filename,
char *s = malloc(max_len);
FILE *sdp_fp = fopen(sdp_filename, "rb");
control[0] = '\0';
- if(sdp_fp != NULL) {
- while(fgets(s, max_len - 2, sdp_fp) != NULL) {
+ if(sdp_fp) {
+ while(fgets(s, max_len - 2, sdp_fp)) {
sscanf(s, " a = control: %32s", control);
}
fclose(sdp_fp);
@@ -239,7 +239,7 @@ int main(int argc, char * const argv[])
/* initialize this curl session */
curl = curl_easy_init();
- if(curl != NULL) {
+ if(curl) {
my_curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L);
my_curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
my_curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout);
diff --git a/docs/examples/synctime.c b/docs/examples/synctime.c
index d55bb1e1a..bdf047390 100644
--- a/docs/examples/synctime.c
+++ b/docs/examples/synctime.c
@@ -218,7 +218,7 @@ int SyncTime_CURL_Fetch(CURL *curl, char *URL_Str, char *OutFileName,
curl_easy_setopt(curl, CURLOPT_URL, URL_Str);
res = curl_easy_perform(curl);
- if(outfile != NULL)
+ if(outfile)
fclose(outfile);
return res; /* (CURLE_OK) */
}
diff --git a/lib/checksrc.pl b/lib/checksrc.pl
index 8f98a99ab..eea1126d1 100755
--- a/lib/checksrc.pl
+++ b/lib/checksrc.pl
@@ -502,7 +502,7 @@ sub scanfile {
}
# check for '== NULL' in if/while conditions but not if the thing on
# the left of it is a function call
- if($nostr =~ /^(.*)(if|while)(\(.*[^)]) == NULL/) {
+ if($nostr =~ /^(.*)(if|while)(\(.*?)([!=]= NULL|NULL [!=]=)/) {
checkwarn("EQUALSNULL", $line,
length($1) + length($2) + length($3),
$file, $l, "we prefer !variable instead of \"== NULL\" comparisons");
diff --git a/lib/cookie.c b/lib/cookie.c
index b7531f742..d418efa33 100644
--- a/lib/cookie.c
+++ b/lib/cookie.c
@@ -1164,7 +1164,7 @@ struct CookieInfo *Curl_cookie_init(struct Curl_easy *data,
bool fromfile = TRUE;
char *line = NULL;
- if(NULL == inc) {
+ if(!inc) {
/* we didn't get a struct, create one */
c = calloc(1, sizeof(struct CookieInfo));
if(!c)
diff --git a/lib/easy.c b/lib/easy.c
index 349802a67..20293a710 100644
--- a/lib/easy.c
+++ b/lib/easy.c
@@ -822,7 +822,7 @@ static CURLcode dupset(struct Curl_easy *dst, struct Curl_easy *src)
struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data)
{
struct Curl_easy *outcurl = calloc(1, sizeof(struct Curl_easy));
- if(NULL == outcurl)
+ if(!outcurl)
goto fail;
/*
diff --git a/lib/ftp.c b/lib/ftp.c
index a8d209e3f..ce7f9c203 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -1004,7 +1004,7 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data,
}
/* parse the port */
- if(ip_end != NULL) {
+ if(ip_end) {
port_start = strchr(ip_end, ':');
if(port_start) {
port_min = curlx_ultous(strtoul(port_start + 1, NULL, 10));
@@ -4190,7 +4190,7 @@ CURLcode ftp_parse_url_path(struct Curl_easy *data)
}
/* parse the URL path into separate path components */
- while((slashPos = strchr(curPos, '/')) != NULL) {
+ while((slashPos = strchr(curPos, '/'))) {
size_t compLen = slashPos - curPos;
/* path starts with a slash: add that as a directory */
@@ -4357,7 +4357,7 @@ static CURLcode ftp_setup_connection(struct Curl_easy *data,
struct FTP *ftp;
data->req.p.ftp = ftp = calloc(sizeof(struct FTP), 1);
- if(NULL == ftp)
+ if(!ftp)
return CURLE_OUT_OF_MEMORY;
ftp->path = &data->state.up.path[1]; /* don't include the initial slash */
diff --git a/lib/hostcheck.c b/lib/hostcheck.c
index cf267a765..cd45bd07e 100644
--- a/lib/hostcheck.c
+++ b/lib/hostcheck.c
@@ -89,7 +89,7 @@ static int hostmatch(char *hostname, char *pattern)
match. */
wildcard_enabled = 1;
pattern_label_end = strchr(pattern, '.');
- if(!pattern_label_end || strchr(pattern_label_end + 1, '.') == NULL ||
+ if(!pattern_label_end || !strchr(pattern_label_end + 1, '.') ||
pattern_wildcard > pattern_label_end ||
strncasecompare(pattern, "xn--", 4)) {
wildcard_enabled = 0;
diff --git a/lib/http.c b/lib/http.c
index caa14bbd9..f08a343e3 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -3311,7 +3311,7 @@ checkhttpprefix(struct Curl_easy *data,
#ifdef CURL_DOES_CONVERSIONS
/* convert from the network encoding using a scratch area */
char *scratch = strdup(s);
- if(NULL == scratch) {
+ if(!scratch) {
failf(data, "Failed to allocate memory for conversion!");
return FALSE; /* can't return CURLE_OUT_OF_MEMORY so return FALSE */
}
@@ -3351,7 +3351,7 @@ checkrtspprefix(struct Curl_easy *data,
#ifdef CURL_DOES_CONVERSIONS
/* convert from the network encoding using a scratch area */
char *scratch = strdup(s);
- if(NULL == scratch) {
+ if(!scratch) {
failf(data, "Failed to allocate memory for conversion!");
return FALSE; /* can't return CURLE_OUT_OF_MEMORY so return FALSE */
}
diff --git a/lib/if2ip.c b/lib/if2ip.c
index 21e00b1f1..132b3eeee 100644
--- a/lib/if2ip.c
+++ b/lib/if2ip.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -114,7 +114,7 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
if(getifaddrs(&head) >= 0) {
for(iface = head; iface != NULL; iface = iface->ifa_next) {
- if(iface->ifa_addr != NULL) {
+ if(iface->ifa_addr) {
if(iface->ifa_addr->sa_family == af) {
if(strcasecompare(iface->ifa_name, interf)) {
void *addr;
diff --git a/lib/inet_pton.c b/lib/inet_pton.c
index 4923cae24..ada57af28 100644
--- a/lib/inet_pton.c
+++ b/lib/inet_pton.c
@@ -1,6 +1,6 @@
/* This is from the BIND 4.9.4 release, modified to compile by itself */
-/* Copyright (c) 1996 - 2020 by Internet Software Consortium.
+/* Copyright (c) 1996 - 2021 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -174,7 +174,7 @@ inet_pton6(const char *src, unsigned char *dst)
pch = strchr((xdigits = xdigits_l), ch);
if(!pch)
pch = strchr((xdigits = xdigits_u), ch);
- if(pch != NULL) {
+ if(pch) {
val <<= 4;
val |= (pch - xdigits);
if(++saw_xdigit > 4)
@@ -211,7 +211,7 @@ inet_pton6(const char *src, unsigned char *dst)
*tp++ = (unsigned char) ((val >> 8) & 0xff);
*tp++ = (unsigned char) (val & 0xff);
}
- if(colonp != NULL) {
+ if(colonp) {
/*
* Since some memmove()'s erroneously fail to handle
* overlapping regions, we'll do the shift by hand.
diff --git a/lib/krb5.c b/lib/krb5.c
index afe425b04..5edd34cbd 100644
--- a/lib/krb5.c
+++ b/lib/krb5.c
@@ -880,7 +880,7 @@ Curl_sec_login(struct Curl_easy *data, struct connectdata *conn)
void
Curl_sec_end(struct connectdata *conn)
{
- if(conn->mech != NULL && conn->mech->end)
+ if(conn->mech && conn->mech->end)
conn->mech->end(conn->app_data);
free(conn->app_data);
conn->app_data = NULL;
diff --git a/lib/ldap.c b/lib/ldap.c
index 284f165ea..3154db5cf 100644
--- a/lib/ldap.c
+++ b/lib/ldap.c
@@ -595,7 +595,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
attr_len = strlen(attr);
vals = ldap_get_values_len(server, entryIterator, attribute);
- if(vals != NULL) {
+ if(vals) {
for(i = 0; (vals[i] != NULL); i++) {
result = Curl_client_write(data, CLIENTWRITE_BODY, (char *)"\t", 1);
if(result) {
diff --git a/lib/md4.c b/lib/md4.c
index d90e45475..117cce4fd 100644
--- a/lib/md4.c
+++ b/lib/md4.c
@@ -189,7 +189,7 @@ static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size)
{
if(!ctx->data) {
ctx->data = malloc(size);
- if(ctx->data != NULL) {
+ if(ctx->data) {
memcpy(ctx->data, data, size);
ctx->size = size;
}
@@ -198,7 +198,7 @@ static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size)
static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
{
- if(ctx->data != NULL) {
+ if(ctx->data) {
#if !defined(HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS)
mbedtls_md4(ctx->data, ctx->size, result);
#else
diff --git a/lib/mprintf.c b/lib/mprintf.c
index 7a1aec570..0fd3afc8a 100644
--- a/lib/mprintf.c
+++ b/lib/mprintf.c
@@ -858,7 +858,7 @@ static int dprintf_formatf(
{
void *ptr;
ptr = (void *) p->data.ptr;
- if(ptr != NULL) {
+ if(ptr) {
/* If the pointer is not NULL, write it as a %#x spec. */
base = 16;
digits = (p->flags & FLAGS_UPPER)? upper_digits : lower_digits;
diff --git a/lib/splay.c b/lib/splay.c
index 1c1dafb92..bcc079521 100644
--- a/lib/splay.c
+++ b/lib/splay.c
@@ -107,7 +107,7 @@ struct Curl_tree *Curl_splayinsert(struct curltime i,
if(!node)
return t;
- if(t != NULL) {
+ if(t) {
t = Curl_splay(i, t);
if(compare(i, t->key) == 0) {
/* There already exists a node in the tree with the very same key. Build
diff --git a/lib/url.c b/lib/url.c
index a48af42c9..45b514c2b 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -845,7 +845,7 @@ CURLcode Curl_disconnect(struct Curl_easy *data,
return CURLE_OK;
}
- if(conn->dns_entry != NULL) {
+ if(conn->dns_entry) {
Curl_resolv_unlock(data, conn->dns_entry);
conn->dns_entry = NULL;
}
@@ -2592,7 +2592,7 @@ static CURLcode create_conn_helper_init_proxy(struct Curl_easy *data,
if(data->set.str[STRING_PROXY]) {
proxy = strdup(data->set.str[STRING_PROXY]);
/* if global proxy is set, this is it */
- if(NULL == proxy) {
+ if(!proxy) {
failf(data, "memory shortage");
result = CURLE_OUT_OF_MEMORY;
goto out;
@@ -2602,7 +2602,7 @@ static CURLcode create_conn_helper_init_proxy(struct Curl_easy *data,
if(data->set.str[STRING_PRE_PROXY]) {
socksproxy = strdup(data->set.str[STRING_PRE_PROXY]);
/* if global socks proxy is set, this is it */
- if(NULL == socksproxy) {
+ if(!socksproxy) {
failf(data, "memory shortage");
result = CURLE_OUT_OF_MEMORY;
goto out;
diff --git a/lib/vauth/digest.c b/lib/vauth/digest.c
index 62484be9d..d8aac66bd 100644
--- a/lib/vauth/digest.c
+++ b/lib/vauth/digest.c
@@ -230,7 +230,7 @@ static CURLcode auth_digest_get_qop_values(const char *options, int *value)
return CURLE_OUT_OF_MEMORY;
token = strtok_r(tmp, ",", &tok_buf);
- while(token != NULL) {
+ while(token) {
if(strcasecompare(token, DIGEST_QOP_VALUE_STRING_AUTH))
*value |= DIGEST_QOP_VALUE_AUTH;
else if(strcasecompare(token, DIGEST_QOP_VALUE_STRING_AUTH_INT))
@@ -556,7 +556,7 @@ CURLcode Curl_auth_decode_digest_http_message(const char *chlg,
return CURLE_OUT_OF_MEMORY;
token = strtok_r(tmp, ",", &tok_buf);
- while(token != NULL) {
+ while(token) {
if(strcasecompare(token, DIGEST_QOP_VALUE_STRING_AUTH)) {
foundAuth = TRUE;
}
diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c
index 3d7c29ebd..84a78e99b 100644
--- a/lib/vtls/gtls.c
+++ b/lib/vtls/gtls.c
@@ -761,10 +761,10 @@ static CURLcode pkp_pin_peer_pubkey(struct Curl_easy *data,
CURLcode result = CURLE_SSL_PINNEDPUBKEYNOTMATCH;
/* if a path wasn't specified, don't pin */
- if(NULL == pinnedpubkey)
+ if(!pinnedpubkey)
return CURLE_OK;
- if(NULL == cert)
+ if(!cert)
return result;
do {
@@ -782,7 +782,7 @@ static CURLcode pkp_pin_peer_pubkey(struct Curl_easy *data,
break; /* failed */
buff1 = malloc(len1);
- if(NULL == buff1)
+ if(!buff1)
break; /* failed */
len2 = len1;
@@ -797,7 +797,7 @@ static CURLcode pkp_pin_peer_pubkey(struct Curl_easy *data,
result = Curl_pin_peer_pubkey(data, pinnedpubkey, buff1, len1);
} while(0);
- if(NULL != key)
+ if(key)
gnutls_pubkey_deinit(key);
Curl_safefree(buff1);
diff --git a/lib/vtls/nss.c b/lib/vtls/nss.c
index 260ff0b04..2b44f0512 100644
--- a/lib/vtls/nss.c
+++ b/lib/vtls/nss.c
@@ -784,7 +784,7 @@ static char *nss_get_password(PK11SlotInfo *slot, PRBool retry, void *arg)
{
(void)slot; /* unused */
- if(retry || NULL == arg)
+ if(retry || !arg)
return NULL;
else
return (char *)PORT_Strdup((char *)arg);
@@ -1170,7 +1170,7 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock,
struct SECKEYPrivateKeyStr *key;
PK11SlotInfo *slot = nss_find_slot_by_name(pem_slotname);
- if(NULL == slot) {
+ if(!slot) {
failf(data, "NSS: PK11 slot not found: %s", pem_slotname);
return SECFailure;
}
@@ -1184,7 +1184,7 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock,
cert = PK11_FindCertFromDERCertItem(slot, &cert_der, proto_win);
SECITEM_FreeItem(&cert_der, PR_FALSE);
- if(NULL == cert) {
+ if(!cert) {
failf(data, "NSS: client certificate from file not found");
PK11_FreeSlot(slot);
return SECFailure;
@@ -1192,7 +1192,7 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock,
key = PK11_FindPrivateKeyFromCert(slot, cert, NULL);
PK11_FreeSlot(slot);
- if(NULL == key) {
+ if(!key) {
failf(data, "NSS: private key from file not found");
CERT_DestroyCertificate(cert);
return SECFailure;
@@ -1209,9 +1209,9 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock,
/* use the default NSS hook */
if(SECSuccess != NSS_GetClientAuthData((void *)nickname, sock, caNames,
pRetCert, pRetKey)
- || NULL == *pRetCert) {
+ || !*pRetCert) {
- if(NULL == nickname)
+ if(!nickname)
failf(data, "NSS: client certificate not found (nickname not "
"specified)");
else
@@ -1222,7 +1222,7 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock,
/* get certificate nickname if any */
nickname = (*pRetCert)->nickname;
- if(NULL == nickname)
+ if(!nickname)
nickname = "[unknown]";
if(!strncmp(nickname, pem_slotname, sizeof(pem_slotname) - 1U)) {
@@ -1231,7 +1231,7 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock,
return SECFailure;
}
- if(NULL == *pRetKey) {
+ if(!*pRetKey) {
failf(data, "NSS: private key not found for certificate: %s", nickname);
return SECFailure;
}
@@ -1346,7 +1346,7 @@ static CURLcode nss_init_core(struct Curl_easy *data, const char *cert_dir)
PRErrorCode err;
const char *err_name;
- if(nss_context != NULL)
+ if(nss_context)
return CURLE_OK;
memset((void *) &initparams, '\0', sizeof(initparams));
@@ -1362,7 +1362,7 @@ static CURLcode nss_init_core(struct Curl_easy *data, const char *cert_dir)
NSS_INIT_READONLY | NSS_INIT_PK11RELOAD);
free(certpath);
- if(nss_context != NULL)
+ if(nss_context)
return CURLE_OK;
err = PR_GetError();
@@ -1374,7 +1374,7 @@ static CURLcode nss_init_core(struct Curl_easy *data, const char *cert_dir)
nss_context = NSS_InitContext("", "", "", "", &initparams, NSS_INIT_READONLY
| NSS_INIT_NOCERTDB | NSS_INIT_NOMODDB | NSS_INIT_FORCEOPEN
| NSS_INIT_NOROOTINIT | NSS_INIT_OPTIMIZESPACE | NSS_INIT_PK11RELOAD);
- if(nss_context != NULL)
+ if(nss_context)
return CURLE_OK;
err = PR_GetError();
diff --git a/lib/vtls/rustls.c b/lib/vtls/rustls.c
index b8af83a7c..6dbb1ef3c 100644
--- a/lib/vtls/rustls.c
+++ b/lib/vtls/rustls.c
@@ -360,7 +360,7 @@ cr_set_negotiated_alpn(struct Curl_easy *data, struct connectdata *conn,
size_t len = 0;
rustls_connection_get_alpn_protocol(rconn, &protocol, &len);
- if(NULL == protocol) {
+ if(!protocol) {
infof(data, "ALPN, server did not agree to a protocol");
return;
}
diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c
index 4098f6a3b..0a8e60610 100644
--- a/lib/vtls/schannel.c
+++ b/lib/vtls/schannel.c
@@ -599,7 +599,7 @@ schannel_acquire_credential_handle(struct Curl_easy *data,
datablob.pbData = (BYTE*)certdata;
datablob.cbData = (DWORD)certsize;
- if(data->set.ssl.key_passwd != NULL)
+ if(data->set.ssl.key_passwd)
pwd_len = strlen(data->set.ssl.key_passwd);
pszPassword = (WCHAR*)malloc(sizeof(WCHAR)*(pwd_len + 1));
if(pszPassword) {
@@ -1192,7 +1192,7 @@ schannel_connect_step2(struct Curl_easy *data, struct connectdata *conn,
}
/* free obsolete buffer */
- if(outbuf[i].pvBuffer != NULL) {
+ if(outbuf[i].pvBuffer) {
s_pSecFn->FreeContextBuffer(outbuf[i].pvBuffer);
}
}
@@ -2239,7 +2239,7 @@ static int schannel_shutdown(struct Curl_easy *data, struct connectdata *conn,
}
/* free internal buffer for received encrypted data */
- if(backend->encdata_buffer != NULL) {
+ if(backend->encdata_buffer) {
Curl_safefree(backend->encdata_buffer);
backend->encdata_length = 0;
backend->encdata_offset = 0;
@@ -2247,7 +2247,7 @@ static int schannel_shutdown(struct Curl_easy *data, struct connectdata *conn,
}
/* free internal buffer for received decrypted data */
- if(backend->decdata_buffer != NULL) {
+ if(backend->decdata_buffer) {
Curl_safefree(backend->decdata_buffer);
backend->decdata_length = 0;
backend->decdata_offset = 0;
diff --git a/lib/vtls/sectransp.c b/lib/vtls/sectransp.c
index 0bf515460..f7a20b20b 100644
--- a/lib/vtls/sectransp.c
+++ b/lib/vtls/sectransp.c
@@ -997,14 +997,14 @@ CF_INLINE CFStringRef getsubject(SecCertificateRef cert)
#else
#if CURL_BUILD_MAC_10_7
/* Lion & later: Get the long description if we can. */
- if(SecCertificateCopyLongDescription != NULL)
+ if(SecCertificateCopyLongDescription)
server_cert_summary =
SecCertificateCopyLongDescription(NULL, cert, NULL);
else
#endif /* CURL_BUILD_MAC_10_7 */
#if CURL_BUILD_MAC_10_6
/* Snow Leopard: Get the certificate summary. */
- if(SecCertificateCopySubjectSummary != NULL)
+ if(SecCertificateCopySubjectSummary)
server_cert_summary = SecCertificateCopySubjectSummary(cert);
else
#endif /* CURL_BUILD_MAC_10_6 */
@@ -1118,7 +1118,7 @@ static OSStatus CopyIdentityWithLabel(char *label,
/* SecItemCopyMatching() was introduced in iOS and Snow Leopard.
kSecClassIdentity was introduced in Lion. If both exist, let's use them
to find the certificate. */
- if(SecItemCopyMatching != NULL && kSecClassIdentity != NULL) {
+ if(SecItemCopyMatching && kSecClassIdentity) {
CFTypeRef keys[5];
CFTypeRef values[5];
CFDictionaryRef query_dict;
@@ -1248,7 +1248,7 @@ static OSStatus CopyIdentityFromPKCS12File(const char *cPath,
CFDictionaryRef options = CFDictionaryCreate(NULL, cKeys, cValues,
password ? 1L : 0L, NULL, NULL);
- if(options != NULL) {
+ if(options) {
status = SecPKCS12Import(pkcs_data, options, &items);
CFRelease(options);
}
@@ -1406,7 +1406,7 @@ set_ssl_version_min_max(struct Curl_easy *data, struct connectdata *conn,
}
#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
- if(SSLSetProtocolVersionMax != NULL) {
+ if(SSLSetProtocolVersionMax) {
SSLProtocol darwin_ver_min = kTLSProtocol1;
SSLProtocol darwin_ver_max = kTLSProtocol1;
CURLcode result = sectransp_version_from_curl(&darwin_ver_min,
@@ -1608,7 +1608,7 @@ static CURLcode sectransp_set_selected_ciphers(struct Curl_easy *data,
if(tls_name) {
table_cipher_name = ciphertable[i].name;
}
- else if(ciphertable[i].alias_name != NULL) {
+ else if(ciphertable[i].alias_name) {
table_cipher_name = ciphertable[i].alias_name;
}
else {
@@ -1688,7 +1688,7 @@ static CURLcode sectransp_connect_step1(struct Curl_easy *data,
#endif /* CURL_BUILD_MAC */
#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
- if(SSLCreateContext != NULL) { /* use the newer API if available */
+ if(SSLCreateContext) { /* use the newer API if available */
if(backend->ssl_ctx)
CFRelease(backend->ssl_ctx);
backend->ssl_ctx = SSLCreateContext(NULL, kSSLClientSide, kSSLStreamType);
@@ -1722,7 +1722,7 @@ static CURLcode sectransp_connect_step1(struct Curl_easy *data,
/* check to see if we've been told to use an explicit SSL/TLS version */
#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
- if(SSLSetProtocolVersionMax != NULL) {
+ if(SSLSetProtocolVersionMax) {
switch(conn->ssl_config.version) {
case CURL_SSLVERSION_TLSv1:
(void)SSLSetProtocolVersionMin(backend->ssl_ctx, kTLSProtocol1);
@@ -1980,9 +1980,9 @@ static CURLcode sectransp_connect_step1(struct Curl_easy *data,
Darwin 15.x.x is El Capitan (10.11)
*/
#if CURL_BUILD_MAC
- if(SSLSetSessionOption != NULL && darwinver_maj >= 13) {
+ if(SSLSetSessionOption && darwinver_maj >= 13) {
#else
- if(SSLSetSessionOption != NULL) {
+ if(SSLSetSessionOption) {
#endif /* CURL_BUILD_MAC */
bool break_on_auth = !conn->ssl_config.verifypeer ||
ssl_cafile || ssl_cablob;
@@ -2065,7 +2065,7 @@ static CURLcode sectransp_connect_step1(struct Curl_easy *data,
#if CURL_BUILD_MAC_10_9 || CURL_BUILD_IOS_7
/* We want to enable 1/n-1 when using a CBC cipher unless the user
specifically doesn't want us doing that: */
- if(SSLSetSessionOption != NULL) {
+ if(SSLSetSessionOption) {
SSLSetSessionOption(backend->ssl_ctx, kSSLSessionOptionSendOneByteRecord,
!SSL_SET_OPTION(enable_beast));
SSLSetSessionOption(backend->ssl_ctx, kSSLSessionOptionFalseStart,
@@ -2521,7 +2521,7 @@ static CURLcode pkp_pin_peer_pubkey(struct Curl_easy *data,
} while(0);
Curl_safefree(realpubkey);
- if(publicKeyBits != NULL)
+ if(publicKeyBits)
CFRelease(publicKeyBits);
return result;
@@ -2947,7 +2947,7 @@ collect_server_cert(struct Curl_easy *data,
private API and doesn't work as expected. So we have to look for
a different symbol to make sure this code is only executed under
Lion or later. */
- if(SecTrustEvaluateAsync != NULL) {
+ if(SecTrustEvaluateAsync) {
#pragma unused(server_certs)
err = SSLCopyPeerTrust(backend->ssl_ctx, &trust);
/* For some reason, SSLCopyPeerTrust() can return noErr and yet return
@@ -3165,7 +3165,7 @@ static void sectransp_close(struct Curl_easy *data, struct connectdata *conn,
if(backend->ssl_ctx) {
(void)SSLClose(backend->ssl_ctx);
#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
- if(SSLCreateContext != NULL)
+ if(SSLCreateContext)
CFRelease(backend->ssl_ctx);
#if CURL_SUPPORT_MAC_10_8
else
@@ -3329,7 +3329,7 @@ static CURLcode sectransp_sha256sum(const unsigned char *tmp, /* input */
static bool sectransp_false_start(void)
{
#if CURL_BUILD_MAC_10_9 || CURL_BUILD_IOS_7
- if(SSLSetSessionOption != NULL)
+ if(SSLSetSessionOption)
return TRUE;
#endif
return FALSE;
diff --git a/src/tool_dirhie.c b/src/tool_dirhie.c
index bf11005e0..93882d9b2 100644
--- a/src/tool_dirhie.c
+++ b/src/tool_dirhie.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -124,12 +124,12 @@ CURLcode create_dir_hierarchy(const char *outfile, FILE *errors)
/* !checksrc! disable BANNEDFUNC 2 */
tempdir = strtok(outdup, PATH_DELIMITERS);
- while(tempdir != NULL) {
+ while(tempdir) {
bool skip = false;
tempdir2 = strtok(NULL, PATH_DELIMITERS);
/* since strtok returns a token for the last word even
if not ending with DIR_CHAR, we need to prune it */
- if(tempdir2 != NULL) {
+ if(tempdir2) {
size_t dlen = strlen(dirbuildup);
if(dlen)
msnprintf(&dirbuildup[dlen], outlen - dlen, "%s%s", DIR_CHAR, tempdir);
diff --git a/src/tool_main.c b/src/tool_main.c
index 23ba6cb20..7db2e9359 100644
--- a/src/tool_main.c
+++ b/src/tool_main.c
@@ -280,7 +280,7 @@ int main(int argc, char *argv[])
}
#ifdef __NOVELL_LIBC__
- if(getenv("_IN_NETWARE_BASH_") == NULL)
+ if(!getenv("_IN_NETWARE_BASH_"))
tool_pressanykey();
#endif
diff --git a/src/tool_xattr.c b/src/tool_xattr.c
index 76ee52482..91fc4ed38 100644
--- a/src/tool_xattr.c
+++ b/src/tool_xattr.c
@@ -100,7 +100,7 @@ int fwrite_xattr(CURL *curl, int fd)
int err = 0;
/* loop through all xattr-curlinfo pairs and abort on a set error */
- while(err == 0 && mappings[i].attr != NULL) {
+ while(err == 0 && mappings[i].attr) {
char *value = NULL;
CURLcode result = curl_easy_getinfo(curl, mappings[i].info, &value);
if(!result && value) {
diff --git a/tests/libtest/lib1536.c b/tests/libtest/lib1536.c
index b047c9d76..1875c5b61 100644
--- a/tests/libtest/lib1536.c
+++ b/tests/libtest/lib1536.c
@@ -44,7 +44,7 @@ int test(char *URL)
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
- if(scheme != NULL) {
+ if(scheme) {
fprintf(stderr, "%s:%d scheme init failed; expected NULL\n",
__FILE__, __LINE__);
res = CURLE_FAILED_INIT;
diff --git a/tests/libtest/lib1565.c b/tests/libtest/lib1565.c
index 24fff72d0..e4d1820cd 100644
--- a/tests/libtest/lib1565.c
+++ b/tests/libtest/lib1565.c
@@ -122,7 +122,7 @@ int test(char *URL)
abort_on_test_timeout();
- while((message = curl_multi_info_read(multi, &num)) != NULL) {
+ while((message = curl_multi_info_read(multi, &num))) {
if(message->msg == CURLMSG_DONE) {
res = message->data.result;
if(res)
diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c
index 6a101d728..b22027a77 100644
--- a/tests/libtest/lib505.c
+++ b/tests/libtest/lib505.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -53,7 +53,7 @@ int test(char *URL)
}
hd_src = fopen(libtest_arg2, "rb");
- if(NULL == hd_src) {
+ if(!hd_src) {
fprintf(stderr, "fopen failed with error: %d %s\n",
errno, strerror(errno));
fprintf(stderr, "Error opening file: %s\n", libtest_arg2);
diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c
index 71b7dc2be..bf7fe8ebf 100644
--- a/tests/libtest/lib518.c
+++ b/tests/libtest/lib518.c
@@ -91,7 +91,7 @@ static int fopen_works(void)
}
}
for(i = 0; i < 3; i++) {
- if(fpa[i] != NULL)
+ if(fpa[i])
fclose(fpa[i]);
}
return ret;
diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c
index 0826de3f1..1400b9248 100644
--- a/tests/libtest/lib525.c
+++ b/tests/libtest/lib525.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -53,7 +53,7 @@ int test(char *URL)
}
hd_src = fopen(libtest_arg2, "rb");
- if(NULL == hd_src) {
+ if(!hd_src) {
fprintf(stderr, "fopen failed with error: %d (%s)\n",
errno, strerror(errno));
fprintf(stderr, "Error opening file: (%s)\n", libtest_arg2);
diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c
index 883ec7a63..3d31f3d0d 100644
--- a/tests/libtest/lib530.c
+++ b/tests/libtest/lib530.c
@@ -179,7 +179,7 @@ static int checkForCompletion(CURLM *curl, int *success)
CURLMsg *message;
int result = 0;
*success = 0;
- while((message = curl_multi_info_read(curl, &numMessages)) != NULL) {
+ while((message = curl_multi_info_read(curl, &numMessages))) {
if(message->msg == CURLMSG_DONE) {
result = 1;
if(message->data.result == CURLE_OK)
diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c
index 730278521..fd852b6b9 100644
--- a/tests/libtest/lib537.c
+++ b/tests/libtest/lib537.c
@@ -92,7 +92,7 @@ static int fopen_works(void)
}
}
for(i = 0; i < 3; i++) {
- if(fpa[i] != NULL)
+ if(fpa[i])
fclose(fpa[i]);
}
return ret;
diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c
index 94ee58e4b..2e5885ff2 100644
--- a/tests/libtest/lib540.c
+++ b/tests/libtest/lib540.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -155,7 +155,7 @@ static int loop(int num, CURLM *cm, const char *url, const char *userpwd,
return res;
}
- while((msg = curl_multi_info_read(cm, &Q)) != NULL) {
+ while((msg = curl_multi_info_read(cm, &Q))) {
if(msg->msg == CURLMSG_DONE) {
int i;
CURL *e = msg->easy_handle;
diff --git a/tests/libtest/lib541.c b/tests/libtest/lib541.c
index 81939aacd..9a8d19938 100644
--- a/tests/libtest/lib541.c
+++ b/tests/libtest/lib541.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -45,7 +45,7 @@ int test(char *URL)
}
hd_src = fopen(libtest_arg2, "rb");
- if(NULL == hd_src) {
+ if(!hd_src) {
fprintf(stderr, "fopen failed with error: %d %s\n",
errno, strerror(errno));
fprintf(stderr, "Error opening file: %s\n", libtest_arg2);
diff --git a/tests/libtest/lib582.c b/tests/libtest/lib582.c
index caaefe0bf..031793d6a 100644
--- a/tests/libtest/lib582.c
+++ b/tests/libtest/lib582.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -151,7 +151,7 @@ static int checkForCompletion(CURLM *curl, int *success)
CURLMsg *message;
int result = 0;
*success = 0;
- while((message = curl_multi_info_read(curl, &numMessages)) != NULL) {
+ while((message = curl_multi_info_read(curl, &numMessages))) {
if(message->msg == CURLMSG_DONE) {
result = 1;
if(message->data.result == CURLE_OK)
@@ -242,7 +242,7 @@ int test(char *URL)
}
hd_src = fopen(libtest_arg2, "rb");
- if(NULL == hd_src) {
+ if(!hd_src) {
fprintf(stderr, "fopen() failed with error: %d (%s)\n",
errno, strerror(errno));
fprintf(stderr, "Error opening file: (%s)\n", libtest_arg2);
diff --git a/tests/unit/unit1309.c b/tests/unit/unit1309.c
index 91eb04090..6d6a3274f 100644
--- a/tests/unit/unit1309.c
+++ b/tests/unit/unit1309.c
@@ -129,7 +129,7 @@ UNITTEST_START
printf("Removing nodes not larger than %d\n", i);
tv_now.tv_usec = i;
root = Curl_splaygetbest(tv_now, root, &removed);
- while(removed != NULL) {
+ while(removed) {
printf("removed payload %zu[%zu]\n",
(*(size_t *)removed->payload) / 10,
(*(size_t *)removed->payload) % 10);