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

@ -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
@ -65,7 +65,7 @@ CURLcode convert_to_network(char *buffer, size_t length)
in_bytes = out_bytes = length;
res = iconv(outbound_cd, &input_ptr, &in_bytes,
&output_ptr, &out_bytes);
if((res == (size_t)-1) || (in_bytes != 0)) {
if((res == (size_t)-1) || (in_bytes)) {
return CURLE_CONV_FAILED;
}
@ -95,7 +95,7 @@ CURLcode convert_from_network(char *buffer, size_t length)
in_bytes = out_bytes = length;
res = iconv(inbound_cd, &input_ptr, &in_bytes,
&output_ptr, &out_bytes);
if((res == (size_t)-1) || (in_bytes != 0)) {
if((res == (size_t)-1) || (in_bytes)) {
return CURLE_CONV_FAILED;
}

View file

@ -534,7 +534,7 @@ int metalink_check_hash(struct GlobalConfig *config,
{
int rv;
fprintf(config->errors, "Metalink: validating (%s)...\n", filename);
if(mlfile->checksum == NULL) {
if(!mlfile->checksum) {
fprintf(config->errors,
"Metalink: validating (%s) FAILED (digest missing)\n", filename);
return -2;
@ -649,7 +649,7 @@ static struct metalinkfile *new_metalinkfile(metalink_file_t *fileinfo)
fileinfo->resources point to the target file. BitTorrent
metainfo file URL may be appeared in fileinfo->metaurls.
*/
if((*p)->type == NULL ||
if(!(*p)->type ||
curl_strequal((*p)->type, "http") ||
curl_strequal((*p)->type, "https") ||
curl_strequal((*p)->type, "ftp") ||
@ -691,10 +691,10 @@ int parse_metalink(struct OperationConfig *config, struct OutStruct *outs,
/* metlaink_parse_final deletes outs->metalink_parser */
r = metalink_parse_final(outs->metalink_parser, NULL, 0, &metalink);
outs->metalink_parser = NULL;
if(r != 0) {
if(r) {
return -1;
}
if(metalink->files == NULL) {
if(!metalink->files) {
fprintf(config->global->errors, "Metalink: parsing (%s) WARNING "
"(missing or invalid file name)\n",
metalink_url);
@ -824,7 +824,7 @@ static void delete_metalink_checksum(struct metalink_checksum *chksum)
static void delete_metalink_resource(struct metalink_resource *res)
{
if(res == NULL) {
if(!res) {
return;
}
Curl_safefree(res->url);
@ -834,7 +834,7 @@ static void delete_metalink_resource(struct metalink_resource *res)
void delete_metalinkfile(struct metalinkfile *mlfile)
{
struct metalink_resource *res;
if(mlfile == NULL) {
if(!mlfile) {
return;
}
Curl_safefree(mlfile->filename);

View file

@ -167,14 +167,14 @@ static curl_off_t vms_realfilesize(const char *name,
/* !checksrc! disable FOPENMODE 1 */
file = fopen(name, "r"); /* VMS */
if(file == NULL) {
if(!file) {
return 0;
}
count = 0;
ret_stat = 1;
while(ret_stat > 0) {
ret_stat = fread(buffer, 1, sizeof(buffer), file);
if(ret_stat != 0)
if(ret_stat)
count += ret_stat;
}
fclose(file);
@ -764,7 +764,7 @@ static CURLcode single_transfer(struct GlobalConfig *global,
urlnode = config->state.urlnode;
if(urlnode->flags & GETOUT_METALINK) {
metalink = 1;
if(mlfile_last == NULL) {
if(!mlfile_last) {
mlfile_last = config->metalinkfile_list;
}
mlfile = mlfile_last;
@ -1979,7 +1979,7 @@ static CURLcode single_transfer(struct GlobalConfig *global,
/* curl 7.17.1 */
if(!config->nokeepalive) {
my_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
if(config->alivetime != 0) {
if(config->alivetime) {
my_setopt(curl, CURLOPT_TCP_KEEPIDLE, config->alivetime);
my_setopt(curl, CURLOPT_TCP_KEEPINTVL, config->alivetime);
}
@ -2128,7 +2128,7 @@ static CURLcode single_transfer(struct GlobalConfig *global,
#ifdef USE_METALINK
if(!metalink && config->use_metalink) {
outs->metalink_parser = metalink_parser_context_new();
if(outs->metalink_parser == NULL) {
if(!outs->metalink_parser) {
result = CURLE_OUT_OF_MEMORY;
break;
}

View file

@ -56,7 +56,7 @@ int is_vms_shell(void)
shell = getenv("SHELL");
/* No shell, means DCL */
if(shell == NULL) {
if(!shell) {
vms_shell = 1;
return 1;
}