tidy-up: make conditional checks more consistent

... remove '== NULL' and '!= 0'

Closes #6912
This commit is contained in:
Daniel Stenberg 2021-04-19 10:46:11 +02:00
parent 19ea52da4d
commit 063d3f3b96
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
85 changed files with 282 additions and 283 deletions

View file

@ -372,7 +372,7 @@ int main(int argc, char **argv)
args++;
}
if(mimetype == NULL || mimetypeaccept == NULL || p.p12file == NULL)
if(!mimetype || !mimetypeaccept || !p.p12file)
badarg = 1;
if(badarg) {
@ -385,11 +385,11 @@ int main(int argc, char **argv)
/* set input */
in = BIO_new(BIO_s_file());
if(in == NULL) {
if(!in) {
BIO_printf(p.errorbio, "Error setting input bio\n");
goto err;
}
else if(infile == NULL)
else if(!infile)
BIO_set_fp(in, stdin, BIO_NOCLOSE|BIO_FP_TEXT);
else if(BIO_read_filename(in, infile) <= 0) {
BIO_printf(p.errorbio, "Error opening input file %s\n", infile);
@ -400,11 +400,11 @@ int main(int argc, char **argv)
/* set output */
out = BIO_new(BIO_s_file());
if(out == NULL) {
if(!out) {
BIO_printf(p.errorbio, "Error setting output bio.\n");
goto err;
}
else if(outfile == NULL)
else if(!outfile)
BIO_set_fp(out, stdout, BIO_NOCLOSE|BIO_FP_TEXT);
else if(BIO_write_filename(out, outfile) <= 0) {
BIO_printf(p.errorbio, "Error opening output file %s\n", outfile);
@ -453,8 +453,8 @@ int main(int argc, char **argv)
serverurl = malloc(len);
snprintf(serverurl, len, "https://%s", hostporturl);
}
else if(p.accesstype != 0) { /* see whether we can find an AIA or SIA for a
given access type */
else if(p.accesstype) { /* see whether we can find an AIA or SIA for a
given access type */
serverurl = my_get_ext(p.usercert, p.accesstype, NID_info_access);
if(!serverurl) {
int j = 0;

View file

@ -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
@ -98,7 +98,7 @@ int main(void)
#ifdef WIN32
WSADATA wsaData;
int initwsa = WSAStartup(MAKEWORD(2, 0), &wsaData);
if(initwsa != 0) {
if(initwsa) {
printf("WSAStartup failed: %d\n", initwsa);
return 1;
}

View file

@ -13,7 +13,7 @@
* See the main() function at the bottom that shows an app that retrieves from
* a specified url using fgets() and fread() and saves as two output files.
*
* Copyright (c) 2003 - 2019 Simtec Electronics
* Copyright (c) 2003 - 2021 Simtec Electronics
*
* Re-implemented by Vincent Sanders <vince@kyllikki.org> with extensive
* reference to original curl example code
@ -107,7 +107,7 @@ static size_t write_callback(char *buffer,
if(size > rembuff) {
/* not enough space in buffer */
newbuff = realloc(url->buffer, url->buffer_len + (size - rembuff));
if(newbuff == NULL) {
if(!newbuff) {
fprintf(stderr, "callback buffer grow failed\n");
size = rembuff;
}

View file

@ -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
@ -43,7 +43,7 @@ WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp)
struct MemoryStruct *mem = (struct MemoryStruct *)userp;
char *ptr = realloc(mem->memory, mem->size + realsize + 1);
if(ptr == NULL) {
if(!ptr) {
/* out of memory! */
printf("not enough memory (realloc returned NULL)\n");
return 0;

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 - 2020, Jim Hollinger
* Copyright (c) 2011 - 2021, Jim Hollinger
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -94,7 +94,7 @@ static void rtsp_describe(CURL *curl, const char *uri,
CURLcode res = CURLE_OK;
FILE *sdp_fp = fopen(sdp_filename, "wb");
printf("\nRTSP: DESCRIBE %s\n", uri);
if(sdp_fp == NULL) {
if(!sdp_fp) {
fprintf(stderr, "Could not open '%s' for writing\n", sdp_filename);
sdp_fp = stdout;
}
@ -202,10 +202,10 @@ int main(int argc, char * const argv[])
/* check command line */
if((argc != 2) && (argc != 3)) {
base_name = strrchr(argv[0], '/');
if(base_name == NULL) {
if(!base_name) {
base_name = strrchr(argv[0], '\\');
}
if(base_name == NULL) {
if(!base_name) {
base_name = argv[0];
}
else {

View file

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2013 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2013 - 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
@ -119,7 +119,7 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm)
/* get a BIO */
bio = BIO_new_mem_buf((char *)mypem, -1);
if(bio == NULL) {
if(!bio) {
printf("BIO_new_mem_buf failed\n");
}
@ -127,7 +127,7 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm)
* structure that SSL can use
*/
cert = PEM_read_bio_X509(bio, NULL, 0, NULL);
if(cert == NULL) {
if(!cert) {
printf("PEM_read_bio_X509 failed...\n");
}
@ -139,13 +139,13 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm)
/*create a bio for the RSA key*/
kbio = BIO_new_mem_buf((char *)mykey, -1);
if(kbio == NULL) {
if(!kbio) {
printf("BIO_new_mem_buf failed\n");
}
/*read the key bio into an RSA object*/
rsa = PEM_read_bio_RSAPrivateKey(kbio, NULL, 0, NULL);
if(rsa == NULL) {
if(!rsa) {
printf("Failed to create key bio\n");
}