ソースを参照

tidy-up: make conditional checks more consistent

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

Closes #6912
Daniel Stenberg 3 年 前
コミット
063d3f3b96
85 ファイル変更282 行追加283 行削除
  1. 7 7
      docs/examples/curlx.c
  2. 2 2
      docs/examples/externalsocket.c
  3. 2 2
      docs/examples/fopen.c
  4. 2 2
      docs/examples/getinmemory.c
  5. 4 4
      docs/examples/rtsp.c
  6. 5 5
      docs/examples/usercertinmem.c
  7. 1 1
      lib/asyn-ares.c
  8. 2 2
      lib/asyn-thread.c
  9. 3 3
      lib/content_encoding.c
  10. 2 3
      lib/cookie.c
  11. 1 1
      lib/curl_addrinfo.c
  12. 1 1
      lib/curl_gssapi.c
  13. 5 5
      lib/curl_path.c
  14. 5 5
      lib/dict.c
  15. 1 1
      lib/easy.c
  16. 1 1
      lib/ftp.c
  17. 1 1
      lib/ftplistparser.c
  18. 2 2
      lib/hash.c
  19. 4 4
      lib/hostcheck.c
  20. 9 9
      lib/http2.c
  21. 1 1
      lib/http_negotiate.c
  22. 2 2
      lib/http_ntlm.c
  23. 2 2
      lib/inet_ntop.c
  24. 2 2
      lib/krb5.c
  25. 7 7
      lib/ldap.c
  26. 3 3
      lib/llist.c
  27. 1 1
      lib/md4.c
  28. 2 2
      lib/mime.c
  29. 2 2
      lib/mprintf.c
  30. 2 2
      lib/multi.c
  31. 4 4
      lib/non-ascii.c
  32. 2 2
      lib/openldap.c
  33. 2 2
      lib/rtsp.c
  34. 1 1
      lib/select.c
  35. 1 1
      lib/sendf.c
  36. 1 1
      lib/setopt.c
  37. 4 4
      lib/setup-vms.h
  38. 2 2
      lib/share.c
  39. 3 3
      lib/socks.c
  40. 1 1
      lib/socks_gssapi.c
  41. 1 1
      lib/socks_sspi.c
  42. 9 9
      lib/splay.c
  43. 2 2
      lib/system_win32.c
  44. 3 3
      lib/tftp.c
  45. 3 3
      lib/url.c
  46. 1 1
      lib/vauth/cleartext.c
  47. 12 12
      lib/vquic/ngtcp2.c
  48. 1 1
      lib/vquic/quiche.c
  49. 21 21
      lib/vssh/libssh.c
  50. 12 12
      lib/vssh/libssh2.c
  51. 2 2
      lib/vssh/wolfssh.c
  52. 2 2
      lib/vtls/gtls.c
  53. 2 2
      lib/vtls/nss.c
  54. 7 7
      lib/vtls/openssl.c
  55. 1 1
      lib/vtls/rustls.c
  56. 15 15
      lib/vtls/schannel.c
  57. 2 2
      lib/vtls/schannel_verify.c
  58. 11 11
      lib/vtls/sectransp.c
  59. 3 3
      src/tool_convert.c
  60. 6 6
      src/tool_metalink.c
  61. 5 5
      src/tool_operate.c
  62. 1 1
      src/tool_vms.c
  63. 2 2
      tests/libtest/lib1511.c
  64. 2 2
      tests/libtest/lib1532.c
  65. 2 2
      tests/libtest/lib1533.c
  66. 4 4
      tests/libtest/lib1535.c
  67. 3 3
      tests/libtest/lib1536.c
  68. 2 2
      tests/libtest/lib510.c
  69. 2 2
      tests/libtest/lib518.c
  70. 2 2
      tests/libtest/lib537.c
  71. 3 3
      tests/libtest/lib539.c
  72. 2 2
      tests/libtest/lib556.c
  73. 2 2
      tests/libtest/lib568.c
  74. 2 2
      tests/libtest/lib569.c
  75. 2 2
      tests/libtest/lib571.c
  76. 2 2
      tests/libtest/lib572.c
  77. 2 2
      tests/libtest/lib579.c
  78. 2 2
      tests/libtest/lib661.c
  79. 4 4
      tests/server/rtspd.c
  80. 3 3
      tests/server/sockfilt.c
  81. 2 2
      tests/server/socksd.c
  82. 4 4
      tests/server/sws.c
  83. 3 3
      tests/server/util.c
  84. 2 2
      tests/unit/unit1309.c
  85. 1 1
      tests/unit/unit1607.c

+ 7 - 7
docs/examples/curlx.c

@@ -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;

+ 2 - 2
docs/examples/externalsocket.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
@@ -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;
   }

+ 2 - 2
docs/examples/fopen.c

@@ -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;
     }

+ 2 - 2
docs/examples/getinmemory.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
@@ -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;

+ 4 - 4
docs/examples/rtsp.c

@@ -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 {

+ 5 - 5
docs/examples/usercertinmem.c

@@ -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");
   }
 

+ 1 - 1
lib/asyn-ares.c

@@ -309,7 +309,7 @@ static int waitperform(struct Curl_easy *data, timediff_t timeout_ms)
       pfd[i].fd = socks[i];
       pfd[i].events |= POLLWRNORM|POLLOUT;
     }
-    if(pfd[i].events != 0)
+    if(pfd[i].events)
       num++;
     else
       break;

+ 2 - 2
lib/asyn-thread.c

@@ -238,7 +238,7 @@ int init_thread_sync_data(struct thread_data *td,
 #endif
 
   tsd->mtx = malloc(sizeof(curl_mutex_t));
-  if(tsd->mtx == NULL)
+  if(!tsd->mtx)
     goto err_exit;
 
   Curl_mutex_init(tsd->mtx);
@@ -305,7 +305,7 @@ static unsigned int CURL_STDCALL getaddrinfo_thread(void *arg)
 
   rc = Curl_getaddrinfo_ex(tsd->hostname, service, &tsd->hints, &tsd->res);
 
-  if(rc != 0) {
+  if(rc) {
     tsd->sock_error = SOCKERRNO?SOCKERRNO:rc;
     if(tsd->sock_error == 0)
       tsd->sock_error = RESOLVER_ENOMEM;

+ 3 - 3
lib/content_encoding.c

@@ -178,7 +178,7 @@ static CURLcode inflate_stream(struct Curl_easy *data,
   /* Dynamically allocate a buffer for decompression because it's uncommonly
      large to hold on the stack */
   decomp = malloc(DSIZ);
-  if(decomp == NULL)
+  if(!decomp)
     return exit_zlib(data, z, &zp->zlib_init, CURLE_OUT_OF_MEMORY);
 
   /* because the buffer size is fixed, iteratively decompress and transfer to
@@ -487,7 +487,7 @@ static CURLcode gzip_unencode_write(struct Curl_easy *data,
        */
       z->avail_in = (uInt) nbytes;
       z->next_in = malloc(z->avail_in);
-      if(z->next_in == NULL) {
+      if(!z->next_in) {
         return exit_zlib(data, z, &zp->zlib_init, CURLE_OUT_OF_MEMORY);
       }
       memcpy(z->next_in, buf, z->avail_in);
@@ -509,7 +509,7 @@ static CURLcode gzip_unencode_write(struct Curl_easy *data,
     ssize_t hlen;
     z->avail_in += (uInt) nbytes;
     z->next_in = Curl_saferealloc(z->next_in, z->avail_in);
-    if(z->next_in == NULL) {
+    if(!z->next_in) {
       return exit_zlib(data, z, &zp->zlib_init, CURLE_OUT_OF_MEMORY);
     }
     /* Append the new block of data to the previous one */

+ 2 - 3
lib/cookie.c

@@ -1579,7 +1579,7 @@ static int cookie_output(struct Curl_easy *data,
 
     for(i = 0; i < nvalid; i++) {
       char *format_ptr = get_netscape_format(array[i]);
-      if(format_ptr == NULL) {
+      if(!format_ptr) {
         fprintf(out, "#\n# Fatal libcurl error\n");
         free(array);
         goto error;
@@ -1618,8 +1618,7 @@ static struct curl_slist *cookie_list(struct Curl_easy *data)
   char *line;
   unsigned int i;
 
-  if((data->cookies == NULL) ||
-      (data->cookies->numcookies == 0))
+  if(!data->cookies || (data->cookies->numcookies == 0))
     return NULL;
 
   for(i = 0; i < COOKIE_HASH_SIZE; i++) {

+ 1 - 1
lib/curl_addrinfo.c

@@ -141,7 +141,7 @@ Curl_getaddrinfo_ex(const char *nodename,
       continue;
 
     /* ignore elements without required address info */
-    if((ai->ai_addr == NULL) || !(ai->ai_addrlen > 0))
+    if(!ai->ai_addr || !(ai->ai_addrlen > 0))
       continue;
 
     /* ignore elements with bogus address size */

+ 1 - 1
lib/curl_gssapi.c

@@ -102,7 +102,7 @@ static size_t display_gss_error(OM_uint32 status, int type,
                        (char *)status_string.value);
     }
     gss_release_buffer(&min_stat, &status_string);
-  } while(!GSS_ERROR(maj_stat) && msg_ctx != 0);
+  } while(!GSS_ERROR(maj_stat) && msg_ctx);
 
   return len;
 }

+ 5 - 5
lib/curl_path.c

@@ -48,7 +48,7 @@ CURLcode Curl_getworkingpath(struct Curl_easy *data,
   /* Check for /~/, indicating relative to the user's home directory */
   if(data->conn->handler->protocol & CURLPROTO_SCP) {
     real_path = malloc(working_path_len + 1);
-    if(real_path == NULL) {
+    if(!real_path) {
       free(working_path);
       return CURLE_OUT_OF_MEMORY;
     }
@@ -62,7 +62,7 @@ CURLcode Curl_getworkingpath(struct Curl_easy *data,
     if((working_path_len > 1) && (working_path[1] == '~')) {
       size_t homelen = strlen(homedir);
       real_path = malloc(homelen + working_path_len + 1);
-      if(real_path == NULL) {
+      if(!real_path) {
         free(working_path);
         return CURLE_OUT_OF_MEMORY;
       }
@@ -78,7 +78,7 @@ CURLcode Curl_getworkingpath(struct Curl_easy *data,
     }
     else {
       real_path = malloc(working_path_len + 1);
-      if(real_path == NULL) {
+      if(!real_path) {
         free(working_path);
         return CURLE_OUT_OF_MEMORY;
       }
@@ -130,7 +130,7 @@ CURLcode Curl_get_pathname(const char **cpp, char **path, char *homedir)
   /* Allocate enough space for home directory and filename + separator */
   fullPathLength = strlen(cp) + strlen(homedir) + 2;
   *path = malloc(fullPathLength);
-  if(*path == NULL)
+  if(!*path)
     return CURLE_OUT_OF_MEMORY;
 
   /* Check for quoted filenames */
@@ -169,7 +169,7 @@ CURLcode Curl_get_pathname(const char **cpp, char **path, char *homedir)
   else {
     /* Read to end of filename - either to whitespace or terminator */
     end = strpbrk(cp, WHITESPACE);
-    if(end == NULL)
+    if(!end)
       end = strchr(cp, '\0');
     /* return pointer to second parameter if it exists */
     *cpp = end + strspn(end, WHITESPACE);

+ 5 - 5
lib/dict.c

@@ -214,14 +214,14 @@ static CURLcode dict_do(struct Curl_easy *data, bool *done)
       }
     }
 
-    if((word == NULL) || (*word == (char)0)) {
+    if(!word || (*word == (char)0)) {
       infof(data, "lookup word is missing\n");
       word = (char *)"default";
     }
-    if((database == NULL) || (*database == (char)0)) {
+    if(!database || (*database == (char)0)) {
       database = (char *)"!";
     }
-    if((strategy == NULL) || (*strategy == (char)0)) {
+    if(!strategy || (*strategy == (char)0)) {
       strategy = (char *)".";
     }
 
@@ -265,11 +265,11 @@ static CURLcode dict_do(struct Curl_easy *data, bool *done)
       }
     }
 
-    if((word == NULL) || (*word == (char)0)) {
+    if(!word || (*word == (char)0)) {
       infof(data, "lookup word is missing\n");
       word = (char *)"default";
     }
-    if((database == NULL) || (*database == (char)0)) {
+    if(!database || (*database == (char)0)) {
       database = (char *)"!";
     }
 

+ 1 - 1
lib/easy.c

@@ -1105,7 +1105,7 @@ static CURLcode easy_connection(struct Curl_easy *data,
                                 curl_socket_t *sfd,
                                 struct connectdata **connp)
 {
-  if(data == NULL)
+  if(!data)
     return CURLE_BAD_FUNCTION_ARGUMENT;
 
   /* only allow these to be called on handles with CURLOPT_CONNECT_ONLY */

+ 1 - 1
lib/ftp.c

@@ -1090,7 +1090,7 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data,
   else
     res = NULL; /* failure! */
 
-  if(res == NULL) {
+  if(!res) {
     failf(data, "failed to resolve the address provided to PORT: %s", host);
     free(addr);
     return CURLE_FTP_PORT_FAILED;

+ 1 - 1
lib/ftplistparser.c

@@ -424,7 +424,7 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
                 endptr++;
               while(ISDIGIT(*endptr))
                 endptr++;
-              if(*endptr != 0) {
+              if(*endptr) {
                 parser->error = CURLE_FTP_BAD_FILE_LIST;
                 goto fail;
               }

+ 2 - 2
lib/hash.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
@@ -245,7 +245,7 @@ Curl_hash_clean_with_criterium(struct Curl_hash *h, void *user,
       struct Curl_hash_element *he = le->ptr;
       lnext = le->next;
       /* ask the callback function if we shall remove this entry or not */
-      if(comp == NULL || comp(user, he->ptr)) {
+      if(!comp || comp(user, he->ptr)) {
         Curl_llist_remove(list, le, (void *) h);
         --h->size; /* one less entry in the hash now */
       }

+ 4 - 4
lib/hostcheck.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
@@ -81,7 +81,7 @@ static int hostmatch(char *hostname, char *pattern)
     pattern[len-1] = 0;
 
   pattern_wildcard = strchr(pattern, '*');
-  if(pattern_wildcard == NULL)
+  if(!pattern_wildcard)
     return strcasecompare(pattern, hostname) ?
       CURL_HOST_MATCH : CURL_HOST_NOMATCH;
 
@@ -97,7 +97,7 @@ static int hostmatch(char *hostname, char *pattern)
      match. */
   wildcard_enabled = 1;
   pattern_label_end = strchr(pattern, '.');
-  if(pattern_label_end == NULL || strchr(pattern_label_end + 1, '.') == NULL ||
+  if(!pattern_label_end || strchr(pattern_label_end + 1, '.') == NULL ||
      pattern_wildcard > pattern_label_end ||
      strncasecompare(pattern, "xn--", 4)) {
     wildcard_enabled = 0;
@@ -107,7 +107,7 @@ static int hostmatch(char *hostname, char *pattern)
       CURL_HOST_MATCH : CURL_HOST_NOMATCH;
 
   hostname_label_end = strchr(hostname, '.');
-  if(hostname_label_end == NULL ||
+  if(!hostname_label_end ||
      !strcasecompare(pattern_label_end, hostname_label_end))
     return CURL_HOST_NOMATCH;
 

+ 9 - 9
lib/http2.c

@@ -1242,7 +1242,7 @@ static CURLcode http2_init(struct Curl_easy *data, struct connectdata *conn)
     nghttp2_session_callbacks *callbacks;
 
     conn->proto.httpc.inbuf = malloc(H2_BUFSIZE);
-    if(conn->proto.httpc.inbuf == NULL)
+    if(!conn->proto.httpc.inbuf)
       return CURLE_OUT_OF_MEMORY;
 
     rc = nghttp2_session_callbacks_new(&callbacks);
@@ -1383,7 +1383,7 @@ static int h2_process_pending_input(struct Curl_easy *data,
   }
 
   rv = h2_session_send(data, httpc->h2);
-  if(rv != 0) {
+  if(rv) {
     *err = CURLE_SEND_ERROR;
     return -1;
   }
@@ -1447,7 +1447,7 @@ CURLcode Curl_http2_done_sending(struct Curl_easy *data,
 
       /* and attempt to send the pending frames */
       rv = h2_session_send(data, h2);
-      if(rv != 0)
+      if(rv)
         result = CURLE_SEND_ERROR;
 
       if(nghttp2_session_want_write(h2)) {
@@ -1963,7 +1963,7 @@ static ssize_t http2_send(struct Curl_easy *data, int sockindex,
      more space. */
   nheader += 1;
   nva = malloc(sizeof(nghttp2_nv) * nheader);
-  if(nva == NULL) {
+  if(!nva) {
     *err = CURLE_OUT_OF_MEMORY;
     return -1;
   }
@@ -2086,7 +2086,7 @@ static ssize_t http2_send(struct Curl_easy *data, int sockindex,
   }
 
   /* :authority must come before non-pseudo header fields */
-  if(authority_idx != 0 && authority_idx != AUTHORITY_DST_IDX) {
+  if(authority_idx && authority_idx != AUTHORITY_DST_IDX) {
     nghttp2_nv authority = nva[authority_idx];
     for(i = authority_idx; i > AUTHORITY_DST_IDX; --i) {
       nva[i] = nva[i - 1];
@@ -2156,7 +2156,7 @@ static ssize_t http2_send(struct Curl_easy *data, int sockindex,
   stream->stream_id = stream_id;
 
   rv = h2_session_send(data, h2);
-  if(rv != 0) {
+  if(rv) {
     H2BUGF(infof(data,
                  "http2_send() nghttp2_session_send error (%s)%d\n",
                  nghttp2_strerror(rv), rv));
@@ -2264,7 +2264,7 @@ CURLcode Curl_http2_switched(struct Curl_easy *data,
     /* queue SETTINGS frame (again) */
     rv = nghttp2_session_upgrade(httpc->h2, httpc->binsettings,
                                  httpc->binlen, NULL);
-    if(rv != 0) {
+    if(rv) {
       failf(data, "nghttp2_session_upgrade() failed: %s(%d)",
             nghttp2_strerror(rv), rv);
       return CURLE_HTTP2;
@@ -2287,7 +2287,7 @@ CURLcode Curl_http2_switched(struct Curl_easy *data,
     rv = nghttp2_submit_settings(httpc->h2, NGHTTP2_FLAG_NONE,
                                  httpc->local_settings,
                                  httpc->local_settings_num);
-    if(rv != 0) {
+    if(rv) {
       failf(data, "nghttp2_submit_settings() failed: %s(%d)",
             nghttp2_strerror(rv), rv);
       return CURLE_HTTP2;
@@ -2296,7 +2296,7 @@ CURLcode Curl_http2_switched(struct Curl_easy *data,
 
   rv = nghttp2_session_set_local_window_size(httpc->h2, NGHTTP2_FLAG_NONE, 0,
                                              HTTP2_HUGE_WINDOW_SIZE);
-  if(rv != 0) {
+  if(rv) {
     failf(data, "nghttp2_session_set_local_window_size() failed: %s(%d)",
           nghttp2_strerror(rv), rv);
     return CURLE_HTTP2;

+ 1 - 1
lib/http_negotiate.c

@@ -179,7 +179,7 @@ CURLcode Curl_output_negotiate(struct Curl_easy *data,
 
     free(base64);
 
-    if(userp == NULL) {
+    if(!userp) {
       return CURLE_OUT_OF_MEMORY;
     }
 

+ 2 - 2
lib/http_ntlm.c

@@ -186,10 +186,10 @@ CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy)
     passwdp = "";
 
 #ifdef USE_WINDOWS_SSPI
-  if(s_hSecDll == NULL) {
+  if(!s_hSecDll) {
     /* not thread safe and leaks - use curl_global_init() to avoid */
     CURLcode err = Curl_sspi_global_init();
-    if(s_hSecDll == NULL)
+    if(!s_hSecDll)
       return err;
   }
 #ifdef SECPKG_ATTR_ENDPOINT_BINDINGS

+ 2 - 2
lib/inet_ntop.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2019  Internet Software Consortium.
+ * Copyright (C) 1996-2021  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
@@ -134,7 +134,7 @@ static char *inet_ntop6 (const unsigned char *src, char *dst, size_t size)
 
     /* Are we following an initial run of 0x00s or any real hex?
      */
-    if(i != 0)
+    if(i)
       *tp++ = ':';
 
     /* Is this address an encapsulated IPv4?

+ 2 - 2
lib/krb5.c

@@ -305,7 +305,7 @@ krb5_auth(void *app_data, struct Curl_easy *data, struct connectdata *conn)
         break;
       }
 
-      if(output_buffer.length != 0) {
+      if(output_buffer.length) {
         char *cmd;
 
         result = Curl_base64_encode(data, (char *)output_buffer.value,
@@ -817,7 +817,7 @@ static CURLcode choose_mech(struct Curl_easy *data, struct connectdata *conn)
   const struct Curl_sec_client_mech *mech = &Curl_krb5_client_mech;
 
   tmp_allocation = realloc(conn->app_data, mech->size);
-  if(tmp_allocation == NULL) {
+  if(!tmp_allocation) {
     failf(data, "Failed realloc of size %zu", mech->size);
     mech = NULL;
     return CURLE_OUT_OF_MEMORY;

+ 7 - 7
lib/ldap.c

@@ -303,7 +303,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
 #else
   rc = _ldap_url_parse(data, conn, &ludp);
 #endif
-  if(rc != 0) {
+  if(rc) {
     failf(data, "LDAP local: %s", ldap_err2string(rc));
     result = CURLE_LDAP_INVALID_URL;
     goto quit;
@@ -387,7 +387,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
       goto quit;
     }
     server = ldapssl_init(host, (int)conn->port, 1);
-    if(server == NULL) {
+    if(!server) {
       failf(data, "LDAP local: Cannot connect to %s:%ld",
             conn->host.dispname, conn->port);
       result = CURLE_COULDNT_CONNECT;
@@ -428,7 +428,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
       goto quit;
     }
     server = ldap_init(host, (int)conn->port);
-    if(server == NULL) {
+    if(!server) {
       failf(data, "LDAP local: Cannot connect to %s:%ld",
             conn->host.dispname, conn->port);
       result = CURLE_COULDNT_CONNECT;
@@ -464,7 +464,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
   }
   else {
     server = ldap_init(host, (int)conn->port);
-    if(server == NULL) {
+    if(!server) {
       failf(data, "LDAP local: Cannot connect to %s:%ld",
             conn->host.dispname, conn->port);
       result = CURLE_COULDNT_CONNECT;
@@ -477,7 +477,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
 #else
   rc = ldap_simple_bind_s(server, user, passwd);
 #endif
-  if(!ldap_ssl && rc != 0) {
+  if(!ldap_ssl && rc) {
     ldap_proto = LDAP_VERSION2;
     ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
 #ifdef USE_WIN32_LDAP
@@ -486,7 +486,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
     rc = ldap_simple_bind_s(server, user, passwd);
 #endif
   }
-  if(rc != 0) {
+  if(rc) {
 #ifdef USE_WIN32_LDAP
     failf(data, "LDAP local: bind via ldap_win_bind %s",
           ldap_err2string(rc));
@@ -501,7 +501,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
   rc = ldap_search_s(server, ludp->lud_dn, ludp->lud_scope,
                      ludp->lud_filter, ludp->lud_attrs, 0, &ldapmsg);
 
-  if(rc != 0 && rc != LDAP_SIZELIMIT_EXCEEDED) {
+  if(rc && rc != LDAP_SIZELIMIT_EXCEEDED) {
     failf(data, "LDAP remote: %s", ldap_err2string(rc));
     result = CURLE_LDAP_SEARCH_FAILED;
     goto quit;

+ 3 - 3
lib/llist.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
@@ -94,13 +94,13 @@ Curl_llist_remove(struct Curl_llist *list, struct Curl_llist_element *e,
                   void *user)
 {
   void *ptr;
-  if(e == NULL || list->size == 0)
+  if(!e || list->size == 0)
     return;
 
   if(e == list->head) {
     list->head = e->next;
 
-    if(list->head == NULL)
+    if(!list->head)
       list->tail = NULL;
     else
       e->next->prev = NULL;

+ 1 - 1
lib/md4.c

@@ -174,7 +174,7 @@ static void MD4_Init(MD4_CTX *ctx)
 
 static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size)
 {
-  if(ctx->data == NULL) {
+  if(!ctx->data) {
     ctx->data = malloc(size);
     if(ctx->data != NULL) {
       memcpy(ctx->data, data, size);

+ 2 - 2
lib/mime.c

@@ -152,14 +152,14 @@ curl_off_t VmsRealFileSize(const char *name,
   FILE * file;
 
   file = fopen(name, FOPEN_READTEXT); /* 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);

+ 2 - 2
lib/mprintf.c

@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1999 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1999 - 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
@@ -815,7 +815,7 @@ static int dprintf_formatf(
         size_t len;
 
         str = (char *) p->data.str;
-        if(str == NULL) {
+        if(!str) {
           /* Write null[] if there's space.  */
           if(prec == -1 || prec >= (long) sizeof(null) - 1) {
             str = null;

+ 2 - 2
lib/multi.c

@@ -1289,7 +1289,7 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
             mask |= CURL_WAIT_POLLOUT;
           if(wsa_events.lNetworkEvents & FD_OOB)
             mask |= CURL_WAIT_POLLPRI;
-          if(ret && pollrc <= 0 && wsa_events.lNetworkEvents != 0)
+          if(ret && pollrc <= 0 && wsa_events.lNetworkEvents)
             retcode++;
         }
         WSAEventSelect(extra_fds[i].fd, multi->wsa_event, 0);
@@ -1317,7 +1317,7 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
             if(bitmap & (GETSOCK_READSOCK(i) | GETSOCK_WRITESOCK(i))) {
               wsa_events.lNetworkEvents = 0;
               if(WSAEnumNetworkEvents(sockbunch[i], NULL, &wsa_events) == 0) {
-                if(ret && pollrc <= 0 && wsa_events.lNetworkEvents != 0)
+                if(ret && pollrc <= 0 && wsa_events.lNetworkEvents)
                   retcode++;
               }
               WSAEventSelect(sockbunch[i], multi->wsa_event, 0);

+ 4 - 4
lib/non-ascii.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
@@ -127,7 +127,7 @@ CURLcode Curl_convert_to_network(struct Curl_easy *data,
                &output_ptr, &out_bytes);
     if(!data)
       iconv_close(tmpcd);
-    if((rc == ICONV_ERROR) || (in_bytes != 0)) {
+    if((rc == ICONV_ERROR) || (in_bytes)) {
       failf(data,
             "The Curl_convert_to_network iconv call failed with errno %i: %s",
             errno, strerror(errno));
@@ -193,7 +193,7 @@ CURLcode Curl_convert_from_network(struct Curl_easy *data,
                &output_ptr, &out_bytes);
     if(!data)
       iconv_close(tmpcd);
-    if((rc == ICONV_ERROR) || (in_bytes != 0)) {
+    if((rc == ICONV_ERROR) || (in_bytes)) {
       failf(data,
             "Curl_convert_from_network iconv call failed with errno %i: %s",
             errno, strerror(errno));
@@ -260,7 +260,7 @@ CURLcode Curl_convert_from_utf8(struct Curl_easy *data,
                &output_ptr, &out_bytes);
     if(!data)
       iconv_close(tmpcd);
-    if((rc == ICONV_ERROR) || (in_bytes != 0)) {
+    if((rc == ICONV_ERROR) || (in_bytes)) {
       failf(data,
             "The Curl_convert_from_utf8 iconv call failed with errno %i: %s",
             errno, strerror(errno));

+ 2 - 2
lib/openldap.c

@@ -549,7 +549,7 @@ static ssize_t ldap_recv(struct Curl_easy *data, int sockindex, char *buf,
         rc = ldap_get_attribute_ber(li->ld, ent, ber, &bv, &bvals)) {
       int i;
 
-      if(bv.bv_val == NULL)
+      if(!bv.bv_val)
         break;
 
       if(bv.bv_len > 7 && !strncmp(bv.bv_val + bv.bv_len - 7, ";binary", 7))
@@ -557,7 +557,7 @@ static ssize_t ldap_recv(struct Curl_easy *data, int sockindex, char *buf,
       else
         binary = 0;
 
-      if(bvals == NULL) {
+      if(!bvals) {
         writeerr = Curl_client_write(data, CLIENTWRITE_BODY, (char *)"\t", 1);
         if(writeerr) {
           *err = writeerr;

+ 2 - 2
lib/rtsp.c

@@ -680,7 +680,7 @@ static CURLcode rtsp_rtp_readwrite(struct Curl_easy *data,
     }
   }
 
-  if(rtp_dataleft != 0 && rtp[0] == '$') {
+  if(rtp_dataleft && rtp[0] == '$') {
     DEBUGF(infof(data, "RTP Rewinding %zd %s\n", rtp_dataleft,
           *readmore ? "(READMORE)" : ""));
 
@@ -824,7 +824,7 @@ CURLcode Curl_rtsp_parseheader(struct Curl_easy *data, char *header)
 
       /* Copy the id substring into a new buffer */
       data->set.str[STRING_RTSP_SESSION_ID] = malloc(idlen + 1);
-      if(data->set.str[STRING_RTSP_SESSION_ID] == NULL)
+      if(!data->set.str[STRING_RTSP_SESSION_ID])
         return CURLE_OUT_OF_MEMORY;
       memcpy(data->set.str[STRING_RTSP_SESSION_ID], start, idlen);
       (data->set.str[STRING_RTSP_SESSION_ID])[idlen] = '\0';

+ 1 - 1
lib/select.c

@@ -442,7 +442,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, timediff_t timeout_ms)
       if(ufds[i].events & POLLPRI)
         ufds[i].revents |= POLLPRI;
     }
-    if(ufds[i].revents != 0)
+    if(ufds[i].revents)
       r++;
   }
 

+ 1 - 1
lib/sendf.c

@@ -65,7 +65,7 @@ static size_t convert_lineends(struct Curl_easy *data,
   char *inPtr, *outPtr;
 
   /* sanity check */
-  if((startPtr == NULL) || (size < 1)) {
+  if(!startPtr || (size < 1)) {
     return size;
   }
 

+ 1 - 1
lib/setopt.c

@@ -813,7 +813,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
   case CURLOPT_COOKIELIST:
     argptr = va_arg(param, char *);
 
-    if(argptr == NULL)
+    if(!argptr)
       break;
 
     if(strcasecompare(argptr, "ALL")) {

+ 4 - 4
lib/setup-vms.h

@@ -7,7 +7,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
@@ -87,7 +87,7 @@ static char *vms_translate_path(const char *path)
   /* See if the result is in VMS format, if not, we are done */
   /* Assume that this is a PATH, not just some data */
   test_str = strpbrk(path, ":[<^");
-  if(test_str == NULL) {
+  if(!test_str) {
     return (char *)path;
   }
 
@@ -119,7 +119,7 @@ static char *vms_getenv(const char *envvar)
 
   /* first use the DECC getenv() function */
   result = decc$getenv(envvar);
-  if(result == NULL) {
+  if(!result) {
     return result;
   }
 
@@ -154,7 +154,7 @@ static struct passwd *vms_getpwuid(uid_t uid)
 #endif
 
   my_passwd = decc_getpwuid(uid);
-  if(my_passwd == NULL) {
+  if(!my_passwd) {
     return my_passwd;
   }
 

+ 2 - 2
lib/share.c

@@ -235,7 +235,7 @@ Curl_share_lock(struct Curl_easy *data, curl_lock_data type,
 {
   struct Curl_share *share = data->share;
 
-  if(share == NULL)
+  if(!share)
     return CURLSHE_INVALID;
 
   if(share->specifier & (1<<type)) {
@@ -252,7 +252,7 @@ Curl_share_unlock(struct Curl_easy *data, curl_lock_data type)
 {
   struct Curl_share *share = data->share;
 
-  if(share == NULL)
+  if(!share)
     return CURLSHE_INVALID;
 
   if(share->specifier & (1<<type)) {

+ 3 - 3
lib/socks.c

@@ -426,7 +426,7 @@ CURLproxycode Curl_SOCKS4(const char *proxy_user,
    */
 
   /* wrong version ? */
-  if(socksreq[0] != 0) {
+  if(socksreq[0]) {
     failf(data,
           "SOCKS4 reply has wrong version, version should be 0.");
     return CURLPX_BAD_VERSION;
@@ -742,7 +742,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
       return CURLPX_OK;
     }
     /* ignore the first (VER) byte */
-    else if(socksreq[1] != 0) { /* status */
+    else if(socksreq[1]) { /* status */
       failf(data, "User was rejected by the SOCKS5 server (%d %d).",
             socksreq[0], socksreq[1]);
       return CURLPX_USER_REJECTED;
@@ -927,7 +927,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
             "SOCKS5 reply has wrong version, version should be 5.");
       return CURLPX_BAD_VERSION;
     }
-    else if(socksreq[1] != 0) { /* Anything besides 0 is an error */
+    else if(socksreq[1]) { /* Anything besides 0 is an error */
       CURLproxycode rc = CURLPX_REPLY_UNASSIGNED;
       int code = socksreq[1];
       failf(data, "Can't complete SOCKS5 connection to %s. (%d)",

+ 1 - 1
lib/socks_gssapi.c

@@ -195,7 +195,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
       return CURLE_COULDNT_CONNECT;
     }
 
-    if(gss_send_token.length != 0) {
+    if(gss_send_token.length) {
       socksreq[0] = 1;    /* GSS-API subnegotiation version */
       socksreq[1] = 1;    /* authentication message type */
       us_length = htons((short)gss_send_token.length);

+ 1 - 1
lib/socks_sspi.c

@@ -198,7 +198,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
       return CURLE_COULDNT_CONNECT;
     }
 
-    if(sspi_send_token.cbBuffer != 0) {
+    if(sspi_send_token.cbBuffer) {
       socksreq[0] = 1;    /* GSS-API subnegotiation version */
       socksreq[1] = 1;    /* authentication message type */
       us_length = htons((short)sspi_send_token.cbBuffer);

+ 9 - 9
lib/splay.c

@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1997 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1997 - 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
@@ -42,7 +42,7 @@ struct Curl_tree *Curl_splay(struct curltime i,
 {
   struct Curl_tree N, *l, *r, *y;
 
-  if(t == NULL)
+  if(!t)
     return t;
   N.smaller = N.larger = NULL;
   l = r = &N;
@@ -50,14 +50,14 @@ struct Curl_tree *Curl_splay(struct curltime i,
   for(;;) {
     long comp = compare(i, t->key);
     if(comp < 0) {
-      if(t->smaller == NULL)
+      if(!t->smaller)
         break;
       if(compare(i, t->smaller->key) < 0) {
         y = t->smaller;                           /* rotate smaller */
         t->smaller = y->larger;
         y->larger = t;
         t = y;
-        if(t->smaller == NULL)
+        if(!t->smaller)
           break;
       }
       r->smaller = t;                               /* link smaller */
@@ -65,14 +65,14 @@ struct Curl_tree *Curl_splay(struct curltime i,
       t = t->smaller;
     }
     else if(comp > 0) {
-      if(t->larger == NULL)
+      if(!t->larger)
         break;
       if(compare(i, t->larger->key) > 0) {
         y = t->larger;                          /* rotate larger */
         t->larger = y->smaller;
         y->smaller = t;
         t = y;
-        if(t->larger == NULL)
+        if(!t->larger)
           break;
       }
       l->larger = t;                              /* link larger */
@@ -104,7 +104,7 @@ struct Curl_tree *Curl_splayinsert(struct curltime i,
     (time_t)-1, (unsigned int)-1
   }; /* will *NEVER* appear */
 
-  if(node == NULL)
+  if(!node)
     return t;
 
   if(t != NULL) {
@@ -125,7 +125,7 @@ struct Curl_tree *Curl_splayinsert(struct curltime i,
     }
   }
 
-  if(t == NULL) {
+  if(!t) {
     node->smaller = node->larger = NULL;
   }
   else if(compare(i, t->key) < 0) {
@@ -262,7 +262,7 @@ int Curl_splayremove(struct Curl_tree *t,
   }
   else {
     /* Remove the root node */
-    if(t->smaller == NULL)
+    if(!t->smaller)
       x = t->larger;
     else {
       x = Curl_splay(removenode->key, t->smaller);

+ 2 - 2
lib/system_win32.c

@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 2016 - 2020, Steve Holme, <steve_holme@hotmail.com>.
+ * Copyright (C) 2016 - 2021, Steve Holme, <steve_holme@hotmail.com>.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -58,7 +58,7 @@ CURLcode Curl_win32_init(long flags)
     wVersionRequested = MAKEWORD(2, 2);
     res = WSAStartup(wVersionRequested, &wsaData);
 
-    if(res != 0)
+    if(res)
       /* Tell the user that we couldn't find a usable */
       /* winsock.dll.     */
       return CURLE_FAILED_INIT;

+ 3 - 3
lib/tftp.c

@@ -319,7 +319,7 @@ static CURLcode tftp_parse_option_ack(struct tftp_state_data *state,
     const char *option, *value;
 
     tmp = tftp_option_get(tmp, ptr + len - tmp, &option, &value);
-    if(tmp == NULL) {
+    if(!tmp) {
       failf(data, "Malformed ACK packet, rejecting");
       return CURLE_TFTP_ILLEGAL;
     }
@@ -776,7 +776,7 @@ static CURLcode tftp_tx(struct tftp_state_data *state, tftp_event_t event)
         return result;
       state->sbytes += (int)cb;
       state->data->req.upload_fromhere += cb;
-    } while(state->sbytes < state->blksize && cb != 0);
+    } while(state->sbytes < state->blksize && cb);
 
     sbytes = sendto(state->sockfd, (void *) state->spacket.data,
                     4 + state->sbytes, SEND_4TH_ARG,
@@ -1256,7 +1256,7 @@ static CURLcode tftp_multi_statemach(struct Curl_easy *data, bool *done)
       failf(data, "%s", Curl_strerror(error, buffer, sizeof(buffer)));
       state->event = TFTP_EVENT_ERROR;
     }
-    else if(rc != 0) {
+    else if(rc) {
       result = tftp_receive_packet(data);
       if(result)
         return result;

+ 3 - 3
lib/url.c

@@ -923,14 +923,14 @@ socks_proxy_info_matches(const struct proxy_info *data,
   /* the user information is case-sensitive
      or at least it is not defined as case-insensitive
      see https://tools.ietf.org/html/rfc3986#section-3.2.1 */
-  if((data->user == NULL) != (needle->user == NULL))
+  if(!data->user != !needle->user)
     return FALSE;
   /* curl_strequal does a case insentive comparison, so do not use it here! */
   if(data->user &&
      needle->user &&
      strcmp(data->user, needle->user) != 0)
     return FALSE;
-  if((data->passwd == NULL) != (needle->passwd == NULL))
+  if(!data->passwd != !needle->passwd)
     return FALSE;
   /* curl_strequal does a case insentive comparison, so do not use it here! */
   if(data->passwd &&
@@ -3563,7 +3563,7 @@ static CURLcode create_conn(struct Curl_easy *data,
 #ifdef USE_UNIX_SOCKETS
   if(data->set.str[STRING_UNIX_SOCKET_PATH]) {
     conn->unix_domain_socket = strdup(data->set.str[STRING_UNIX_SOCKET_PATH]);
-    if(conn->unix_domain_socket == NULL) {
+    if(!conn->unix_domain_socket) {
       result = CURLE_OUT_OF_MEMORY;
       goto out;
     }

+ 1 - 1
lib/vauth/cleartext.c

@@ -83,7 +83,7 @@ CURLcode Curl_auth_create_plain_message(const char *authzid,
     return CURLE_OUT_OF_MEMORY;
 
   /* Calculate the reply */
-  if(zlen != 0)
+  if(zlen)
     memcpy(plainauth, authzid, zlen);
   plainauth[zlen] = '\0';
   memcpy(plainauth + zlen + 1, authcid, clen);

+ 12 - 12
lib/vquic/ngtcp2.c

@@ -226,7 +226,7 @@ static int write_client_handshake(struct quicsocket *qs,
   int rv;
 
   crypto_data = &qs->crypto_data[level];
-  if(crypto_data->buf == NULL) {
+  if(!crypto_data->buf) {
     crypto_data->buf = malloc(4096);
     if(!crypto_data->buf)
       return 0;
@@ -615,7 +615,7 @@ cb_acked_stream_data_offset(ngtcp2_conn *tconn, int64_t stream_id,
   (void)stream_user_data;
 
   rv = nghttp3_conn_add_ack_offset(qs->h3conn, stream_id, datalen);
-  if(rv != 0) {
+  if(rv) {
     return NGTCP2_ERR_CALLBACK_FAILURE;
   }
 
@@ -634,7 +634,7 @@ static int cb_stream_close(ngtcp2_conn *tconn, int64_t stream_id,
 
   rv = nghttp3_conn_close_stream(qs->h3conn, stream_id,
                                  app_error_code);
-  if(rv != 0) {
+  if(rv) {
     return NGTCP2_ERR_CALLBACK_FAILURE;
   }
 
@@ -653,7 +653,7 @@ static int cb_stream_reset(ngtcp2_conn *tconn, int64_t stream_id,
   (void)stream_user_data;
 
   rv = nghttp3_conn_reset_stream(qs->h3conn, stream_id);
-  if(rv != 0) {
+  if(rv) {
     return NGTCP2_ERR_CALLBACK_FAILURE;
   }
 
@@ -682,7 +682,7 @@ static int cb_extend_max_stream_data(ngtcp2_conn *tconn, int64_t stream_id,
   (void)stream_user_data;
 
   rv = nghttp3_conn_unblock_stream(qs->h3conn, stream_id);
-  if(rv != 0) {
+  if(rv) {
     return NGTCP2_ERR_CALLBACK_FAILURE;
   }
 
@@ -1309,7 +1309,7 @@ static int cb_h3_acked_stream_data(nghttp3_conn *conn, int64_t stream_id,
 
     if(stream->h3out->used == 0) {
       int rv = nghttp3_conn_resume_stream(conn, stream_id);
-      if(rv != 0) {
+      if(rv) {
         return NGTCP2_ERR_CALLBACK_FAILURE;
       }
     }
@@ -1545,7 +1545,7 @@ static CURLcode http_request(struct Curl_easy *data, const void *mem,
   }
 
   /* :authority must come before non-pseudo header fields */
-  if(authority_idx != 0 && authority_idx != AUTHORITY_DST_IDX) {
+  if(authority_idx && authority_idx != AUTHORITY_DST_IDX) {
     nghttp3_nv authority = nva[authority_idx];
     for(i = authority_idx; i > AUTHORITY_DST_IDX; --i) {
       nva[i] = nva[i - 1];
@@ -1741,7 +1741,7 @@ static CURLcode ng_process_ingress(struct Curl_easy *data,
                      remote_addrlen);
 
     rv = ngtcp2_conn_read_pkt(qs->qconn, &path, &pi, buf, recvd, ts);
-    if(rv != 0) {
+    if(rv) {
       /* TODO Send CONNECTION_CLOSE if possible */
       return CURLE_RECV_ERROR;
     }
@@ -1785,7 +1785,7 @@ static CURLcode ng_flush_egress(struct Curl_easy *data,
   }
 
   rv = ngtcp2_conn_handle_expiry(qs->qconn, ts);
-  if(rv != 0) {
+  if(rv) {
     failf(data, "ngtcp2_conn_handle_expiry returned error: %s",
           ngtcp2_strerror(rv));
     return CURLE_SEND_ERROR;
@@ -1821,7 +1821,7 @@ static CURLcode ng_flush_egress(struct Curl_easy *data,
          outlen == NGTCP2_ERR_STREAM_SHUT_WR) {
         assert(ndatalen == -1);
         rv = nghttp3_conn_block_stream(qs->h3conn, stream_id);
-        if(rv != 0) {
+        if(rv) {
           failf(data, "nghttp3_conn_block_stream returned error: %s\n",
                 nghttp3_strerror(rv));
           return CURLE_SEND_ERROR;
@@ -1831,7 +1831,7 @@ static CURLcode ng_flush_egress(struct Curl_easy *data,
       else if(outlen == NGTCP2_ERR_WRITE_MORE) {
         assert(ndatalen >= 0);
         rv = nghttp3_conn_add_write_offset(qs->h3conn, stream_id, ndatalen);
-        if(rv != 0) {
+        if(rv) {
           failf(data, "nghttp3_conn_add_write_offset returned error: %s\n",
                 nghttp3_strerror(rv));
           return CURLE_SEND_ERROR;
@@ -1847,7 +1847,7 @@ static CURLcode ng_flush_egress(struct Curl_easy *data,
     }
     else if(ndatalen >= 0) {
       rv = nghttp3_conn_add_write_offset(qs->h3conn, stream_id, ndatalen);
-      if(rv != 0) {
+      if(rv) {
         failf(data, "nghttp3_conn_add_write_offset returned error: %s\n",
               nghttp3_strerror(rv));
         return CURLE_SEND_ERROR;

+ 1 - 1
lib/vquic/quiche.c

@@ -750,7 +750,7 @@ static CURLcode http_request(struct Curl_easy *data, const void *mem,
   }
 
   /* :authority must come before non-pseudo header fields */
-  if(authority_idx != 0 && authority_idx != AUTHORITY_DST_IDX) {
+  if(authority_idx && authority_idx != AUTHORITY_DST_IDX) {
     quiche_h3_header authority = nva[authority_idx];
     for(i = authority_idx; i > AUTHORITY_DST_IDX; --i) {
       nva[i] = nva[i - 1];

+ 21 - 21
lib/vssh/libssh.c

@@ -628,7 +628,7 @@ restart:
         rc = SSH_OK;
       else if(rc == SSH_AUTH_INFO) {
         nprompts = ssh_userauth_kbdint_getnprompts(sshc->ssh_session);
-        if(nprompts != 0)
+        if(nprompts)
           return SSH_ERROR;
 
         sshc->kbd_state = 2;
@@ -958,7 +958,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
        * Get the "home" directory
        */
       sshc->homedir = sftp_canonicalize_path(sshc->sftp_session, ".");
-      if(sshc->homedir == NULL) {
+      if(!sshc->homedir) {
         MOVE_TO_ERROR_STATE(CURLE_COULDNT_CONNECT);
         break;
       }
@@ -1033,7 +1033,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
     case SSH_SFTP_QUOTE_SETSTAT:
       rc = sftp_setstat(sshc->sftp_session, sshc->quote_path2,
                         sshc->quote_attrs);
-      if(rc != 0 && !sshc->acceptfail) {
+      if(rc && !sshc->acceptfail) {
         Curl_safefree(sshc->quote_path1);
         Curl_safefree(sshc->quote_path2);
         failf(data, "Attempt to set SFTP stats failed: %s",
@@ -1052,7 +1052,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
     case SSH_SFTP_QUOTE_SYMLINK:
       rc = sftp_symlink(sshc->sftp_session, sshc->quote_path2,
                         sshc->quote_path1);
-      if(rc != 0 && !sshc->acceptfail) {
+      if(rc && !sshc->acceptfail) {
         Curl_safefree(sshc->quote_path1);
         Curl_safefree(sshc->quote_path2);
         failf(data, "symlink command failed: %s",
@@ -1068,7 +1068,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
     case SSH_SFTP_QUOTE_MKDIR:
       rc = sftp_mkdir(sshc->sftp_session, sshc->quote_path1,
                       (mode_t)data->set.new_directory_perms);
-      if(rc != 0 && !sshc->acceptfail) {
+      if(rc && !sshc->acceptfail) {
         Curl_safefree(sshc->quote_path1);
         failf(data, "mkdir command failed: %s",
               ssh_get_error(sshc->ssh_session));
@@ -1083,7 +1083,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
     case SSH_SFTP_QUOTE_RENAME:
       rc = sftp_rename(sshc->sftp_session, sshc->quote_path1,
                        sshc->quote_path2);
-      if(rc != 0 && !sshc->acceptfail) {
+      if(rc && !sshc->acceptfail) {
         Curl_safefree(sshc->quote_path1);
         Curl_safefree(sshc->quote_path2);
         failf(data, "rename command failed: %s",
@@ -1098,7 +1098,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
 
     case SSH_SFTP_QUOTE_RMDIR:
       rc = sftp_rmdir(sshc->sftp_session, sshc->quote_path1);
-      if(rc != 0 && !sshc->acceptfail) {
+      if(rc && !sshc->acceptfail) {
         Curl_safefree(sshc->quote_path1);
         failf(data, "rmdir command failed: %s",
               ssh_get_error(sshc->ssh_session));
@@ -1112,7 +1112,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
 
     case SSH_SFTP_QUOTE_UNLINK:
       rc = sftp_unlink(sshc->sftp_session, sshc->quote_path1);
-      if(rc != 0 && !sshc->acceptfail) {
+      if(rc && !sshc->acceptfail) {
         Curl_safefree(sshc->quote_path1);
         failf(data, "rm command failed: %s",
               ssh_get_error(sshc->ssh_session));
@@ -1187,7 +1187,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
       sftp_attributes attrs;
 
       attrs = sftp_stat(sshc->sftp_session, protop->path);
-      if(attrs != 0) {
+      if(attrs) {
         data->info.filetime = attrs->mtime;
         sftp_attributes_free(attrs);
       }
@@ -1211,12 +1211,12 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
     {
       int flags;
 
-      if(data->state.resume_from != 0) {
+      if(data->state.resume_from) {
         sftp_attributes attrs;
 
         if(data->state.resume_from < 0) {
           attrs = sftp_stat(sshc->sftp_session, protop->path);
-          if(attrs != 0) {
+          if(attrs) {
             curl_off_t size = attrs->size;
             if(size < 0) {
               failf(data, "Bad file size (%" CURL_FORMAT_CURL_OFF_T ")", size);
@@ -1317,7 +1317,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
         }
 
         rc = sftp_seek64(sshc->sftp_file, data->state.resume_from);
-        if(rc != 0) {
+        if(rc) {
           MOVE_TO_SFTP_CLOSE_STATE();
           break;
         }
@@ -1433,7 +1433,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
           char *tmpLine;
 
           tmpLine = aprintf("%s\n", sshc->readdir_filename);
-          if(tmpLine == NULL) {
+          if(!tmpLine) {
             state(data, SSH_SFTP_CLOSE);
             sshc->actualcode = CURLE_OUT_OF_MEMORY;
             break;
@@ -1472,7 +1472,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
             sshc->readdir_linkPath = aprintf("%s%s", protop->path,
                                              sshc->readdir_filename);
 
-            if(sshc->readdir_linkPath == NULL) {
+            if(!sshc->readdir_linkPath) {
               state(data, SSH_SFTP_CLOSE);
               sshc->actualcode = CURLE_OUT_OF_MEMORY;
               break;
@@ -1510,10 +1510,10 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
         break;
       }
 
-      if(sshc->readdir_link_attrs->name == NULL) {
+      if(!sshc->readdir_link_attrs->name) {
         sshc->readdir_tmp = sftp_readlink(sshc->sftp_session,
                                           sshc->readdir_linkPath);
-        if(sshc->readdir_filename == NULL)
+        if(!sshc->readdir_filename)
           sshc->readdir_len = 0;
         else
           sshc->readdir_len = strlen(sshc->readdir_tmp);
@@ -1679,7 +1679,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
           }
 
           rc = sftp_seek64(sshc->sftp_file, from);
-          if(rc != 0) {
+          if(rc) {
             MOVE_TO_SFTP_CLOSE_STATE();
             break;
           }
@@ -1718,7 +1718,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
                                  size - data->state.resume_from);
 
         rc = sftp_seek64(sshc->sftp_file, data->state.resume_from);
-        if(rc != 0) {
+        if(rc) {
           MOVE_TO_SFTP_CLOSE_STATE();
           break;
         }
@@ -2187,7 +2187,7 @@ static CURLcode myssh_connect(struct Curl_easy *data, bool *done)
   ssh = &conn->proto.sshc;
 
   ssh->ssh_session = ssh_new();
-  if(ssh->ssh_session == NULL) {
+  if(!ssh->ssh_session) {
     failf(data, "Failure initialising ssh session");
     return CURLE_FAILED_INIT;
   }
@@ -2685,7 +2685,7 @@ static void sftp_quote(struct Curl_easy *data)
    * command with a space so we can check for it unconditionally
    */
   cp = strchr(cmd, ' ');
-  if(cp == NULL) {
+  if(!cp) {
     failf(data, "Syntax error in SFTP command. Supply parameter(s)!");
     state(data, SSH_SFTP_CLOSE);
     sshc->nextstate = SSH_NO_STATE;
@@ -2834,7 +2834,7 @@ static void sftp_quote_stat(struct Curl_easy *data)
   if(sshc->quote_attrs)
     sftp_attributes_free(sshc->quote_attrs);
   sshc->quote_attrs = sftp_stat(sshc->sftp_session, sshc->quote_path2);
-  if(sshc->quote_attrs == NULL) {
+  if(!sshc->quote_attrs) {
     Curl_safefree(sshc->quote_path1);
     Curl_safefree(sshc->quote_path2);
     failf(data, "Attempt to get SFTP stats failed: %d",

+ 12 - 12
lib/vssh/libssh2.c

@@ -956,7 +956,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
             out_of_memory = TRUE;
         }
 
-        if(out_of_memory || sshc->rsa == NULL) {
+        if(out_of_memory || !sshc->rsa) {
           Curl_safefree(sshc->rsa);
           Curl_safefree(sshc->rsa_pub);
           state(data, SSH_SESSION_FREE);
@@ -1359,7 +1359,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
          * command with a space so we can check for it unconditionally
          */
         cp = strchr(cmd, ' ');
-        if(cp == NULL) {
+        if(!cp) {
           failf(data, "Syntax error command '%s'. Missing parameter!",
                 cmd);
           state(data, SSH_SFTP_CLOSE);
@@ -1534,7 +1534,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
         if(rc == LIBSSH2_ERROR_EAGAIN) {
           break;
         }
-        if(rc != 0 && !sshc->acceptfail) { /* get those attributes */
+        if(rc && !sshc->acceptfail) { /* get those attributes */
           sftperr = libssh2_sftp_last_error(sshc->sftp_session);
           Curl_safefree(sshc->quote_path1);
           Curl_safefree(sshc->quote_path2);
@@ -1633,7 +1633,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
       if(rc == LIBSSH2_ERROR_EAGAIN) {
         break;
       }
-      if(rc != 0 && !sshc->acceptfail) {
+      if(rc && !sshc->acceptfail) {
         sftperr = libssh2_sftp_last_error(sshc->sftp_session);
         Curl_safefree(sshc->quote_path1);
         Curl_safefree(sshc->quote_path2);
@@ -1656,7 +1656,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
       if(rc == LIBSSH2_ERROR_EAGAIN) {
         break;
       }
-      if(rc != 0 && !sshc->acceptfail) {
+      if(rc && !sshc->acceptfail) {
         sftperr = libssh2_sftp_last_error(sshc->sftp_session);
         Curl_safefree(sshc->quote_path1);
         Curl_safefree(sshc->quote_path2);
@@ -1677,7 +1677,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
       if(rc == LIBSSH2_ERROR_EAGAIN) {
         break;
       }
-      if(rc != 0 && !sshc->acceptfail) {
+      if(rc && !sshc->acceptfail) {
         sftperr = libssh2_sftp_last_error(sshc->sftp_session);
         Curl_safefree(sshc->quote_path1);
         failf(data, "mkdir command failed: %s",
@@ -1702,7 +1702,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
       if(rc == LIBSSH2_ERROR_EAGAIN) {
         break;
       }
-      if(rc != 0 && !sshc->acceptfail) {
+      if(rc && !sshc->acceptfail) {
         sftperr = libssh2_sftp_last_error(sshc->sftp_session);
         Curl_safefree(sshc->quote_path1);
         Curl_safefree(sshc->quote_path2);
@@ -1722,7 +1722,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
       if(rc == LIBSSH2_ERROR_EAGAIN) {
         break;
       }
-      if(rc != 0 && !sshc->acceptfail) {
+      if(rc && !sshc->acceptfail) {
         sftperr = libssh2_sftp_last_error(sshc->sftp_session);
         Curl_safefree(sshc->quote_path1);
         failf(data, "rmdir command failed: %s",
@@ -1741,7 +1741,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
       if(rc == LIBSSH2_ERROR_EAGAIN) {
         break;
       }
-      if(rc != 0 && !sshc->acceptfail) {
+      if(rc && !sshc->acceptfail) {
         sftperr = libssh2_sftp_last_error(sshc->sftp_session);
         Curl_safefree(sshc->quote_path1);
         failf(data, "rm command failed: %s", sftp_libssh2_strerror(sftperr));
@@ -1764,7 +1764,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
       if(rc == LIBSSH2_ERROR_EAGAIN) {
         break;
       }
-      if(rc != 0 && !sshc->acceptfail) {
+      if(rc && !sshc->acceptfail) {
         sftperr = libssh2_sftp_last_error(sshc->sftp_session);
         Curl_safefree(sshc->quote_path1);
         failf(data, "statvfs command failed: %s",
@@ -1857,7 +1857,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
        *          same name as the last directory in the path.
        */
 
-      if(data->state.resume_from != 0) {
+      if(data->state.resume_from) {
         LIBSSH2_SFTP_ATTRIBUTES attrs;
         if(data->state.resume_from < 0) {
           rc = libssh2_sftp_stat_ex(sshc->sftp_session, sshp->path,
@@ -3084,7 +3084,7 @@ static CURLcode ssh_connect(struct Curl_easy *data, bool *done)
   sshc->ssh_session = libssh2_session_init_ex(my_libssh2_malloc,
                                               my_libssh2_free,
                                               my_libssh2_realloc, data);
-  if(sshc->ssh_session == NULL) {
+  if(!sshc->ssh_session) {
     failf(data, "Failure initialising ssh session");
     return CURLE_FAILED_INIT;
   }

+ 2 - 2
lib/vssh/wolfssh.c

@@ -388,7 +388,7 @@ static CURLcode wssh_connect(struct Curl_easy *data, bool *done)
   }
 
   sshc->ssh_session = wolfSSH_new(sshc->ctx);
-  if(sshc->ssh_session == NULL) {
+  if(!sshc->ssh_session) {
     failf(data, "No wolfSSH session");
     goto error;
   }
@@ -861,7 +861,7 @@ static CURLcode wssh_statemach_act(struct Curl_easy *data, bool *block)
           char *line = aprintf("%s\n",
                                data->set.list_only ?
                                name->fName : name->lName);
-          if(line == NULL) {
+          if(!line) {
             state(data, SSH_SFTP_CLOSE);
             sshc->actualcode = CURLE_OUT_OF_MEMORY;
             break;

+ 2 - 2
lib/vtls/gtls.c

@@ -263,7 +263,7 @@ static CURLcode handshake(struct Curl_easy *data,
         strerr = gnutls_alert_get_name(alert);
       }
 
-      if(strerr == NULL)
+      if(!strerr)
         strerr = gnutls_strerror(rc);
 
       infof(data, "gnutls_handshake() warning: %s\n", strerr);
@@ -277,7 +277,7 @@ static CURLcode handshake(struct Curl_easy *data,
         strerr = gnutls_alert_get_name(alert);
       }
 
-      if(strerr == NULL)
+      if(!strerr)
         strerr = gnutls_strerror(rc);
 
       failf(data, "gnutls_handshake() failed: %s", strerr);

+ 2 - 2
lib/vtls/nss.c

@@ -405,7 +405,7 @@ static int is_file(const char *filename)
 {
   struct_stat st;
 
-  if(filename == NULL)
+  if(!filename)
     return 0;
 
   if(stat(filename, &st) == 0)
@@ -1448,7 +1448,7 @@ static CURLcode nss_setup(struct Curl_easy *data)
 static int nss_init(void)
 {
   /* curl_global_init() is not thread-safe so this test is ok */
-  if(nss_initlock == NULL) {
+  if(!nss_initlock) {
     PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
     nss_initlock = PR_NewLock();
     nss_crllock = PR_NewLock();

+ 7 - 7
lib/vtls/openssl.c

@@ -619,7 +619,7 @@ SSL_CTX_use_certificate_blob(SSL_CTX *ctx, const struct curl_blob *blob,
     goto end;
   }
 
-  if(x == NULL) {
+  if(!x) {
     ret = 0;
     goto end;
   }
@@ -650,7 +650,7 @@ SSL_CTX_use_PrivateKey_blob(SSL_CTX *ctx, const struct curl_blob *blob,
     ret = 0;
     goto end;
   }
-  if(pkey == NULL) {
+  if(!pkey) {
     ret = 0;
     goto end;
   }
@@ -681,7 +681,7 @@ SSL_CTX_use_certificate_chain_blob(SSL_CTX *ctx, const struct curl_blob *blob,
   x = PEM_read_bio_X509_AUX(in, NULL,
                             passwd_callback, (void *)key_passwd);
 
-  if(x == NULL) {
+  if(!x) {
     ret = 0;
     goto end;
   }
@@ -869,7 +869,7 @@ int cert_stuff(struct Curl_easy *data,
       STACK_OF(X509) *ca = NULL;
       if(cert_blob) {
         cert_bio = BIO_new_mem_buf(cert_blob->data, (int)(cert_blob->len));
-        if(cert_bio == NULL) {
+        if(!cert_bio) {
           failf(data,
                 "BIO_new_mem_buf NULL, " OSSL_PACKAGE
                 " error %s",
@@ -880,7 +880,7 @@ int cert_stuff(struct Curl_easy *data,
       }
       else {
         cert_bio = BIO_new(BIO_s_file());
-        if(cert_bio == NULL) {
+        if(!cert_bio) {
           failf(data,
                 "BIO_new return NULL, " OSSL_PACKAGE
                 " error %s",
@@ -3346,7 +3346,7 @@ static CURLcode ossl_connect_step2(struct Curl_easy *data,
       const unsigned char *neg_protocol;
       unsigned int len;
       SSL_get0_alpn_selected(backend->handle, &neg_protocol, &len);
-      if(len != 0) {
+      if(len) {
         infof(data, "ALPN, server accepted to use %.*s\n", len, neg_protocol);
 
 #ifdef USE_NGHTTP2
@@ -3838,7 +3838,7 @@ static CURLcode servercert(struct Curl_easy *data,
                              (int)SSL_SET_OPTION(issuercert_blob)->len);
       else {
         fp = BIO_new(BIO_s_file());
-        if(fp == NULL) {
+        if(!fp) {
           failf(data,
                 "BIO_new return NULL, " OSSL_PACKAGE
                 " error %s",

+ 1 - 1
lib/vtls/rustls.c

@@ -323,7 +323,7 @@ cr_init_backend(struct Curl_easy *data, struct connectdata *conn,
   int result;
 
   backend->tlsbuf = calloc(TLSBUF_SIZE, 1);
-  if(backend->tlsbuf == NULL) {
+  if(!backend->tlsbuf) {
     return CURLE_OUT_OF_MEMORY;
   }
 

+ 15 - 15
lib/vtls/schannel.c

@@ -358,7 +358,7 @@ get_cert_location(TCHAR *path, DWORD *store_name, TCHAR **store_path,
   size_t store_name_len;
 
   sep = _tcschr(path, TEXT('\\'));
-  if(sep == NULL)
+  if(!sep)
     return CURLE_SSL_CERTPROBLEM;
 
   store_name_len = sep - path;
@@ -388,7 +388,7 @@ get_cert_location(TCHAR *path, DWORD *store_name, TCHAR **store_path,
   store_path_start = sep + 1;
 
   sep = _tcschr(store_path_start, TEXT('\\'));
-  if(sep == NULL)
+  if(!sep)
     return CURLE_SSL_CERTPROBLEM;
 
   *thumbprint = sep + 1;
@@ -398,7 +398,7 @@ get_cert_location(TCHAR *path, DWORD *store_name, TCHAR **store_path,
   *sep = TEXT('\0');
   *store_path = _tcsdup(store_path_start);
   *sep = TEXT('\\');
-  if(*store_path == NULL)
+  if(!*store_path)
     return CURLE_OUT_OF_MEMORY;
 
   return CURLE_OK;
@@ -698,7 +698,7 @@ schannel_connect_step1(struct Curl_easy *data, struct connectdata *conn,
         }
         if(!blob)
           free(certdata);
-        if(cert_store == NULL) {
+        if(!cert_store) {
           DWORD errorcode = GetLastError();
           if(errorcode == ERROR_INVALID_PASSWORD)
             failf(data, "schannel: Failed to import cert file %s, "
@@ -715,7 +715,7 @@ schannel_connect_step1(struct Curl_easy *data, struct connectdata *conn,
           cert_store, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0,
           CERT_FIND_ANY, NULL, NULL);
 
-        if(client_certs[0] == NULL) {
+        if(!client_certs[0]) {
           failf(data, "schannel: Failed to get certificate from file %s"
                 ", last error is 0x%x",
                 cert_showfilename_error, GetLastError());
@@ -1013,23 +1013,23 @@ schannel_connect_step2(struct Curl_easy *data, struct connectdata *conn,
     return CURLE_SSL_CONNECT_ERROR;
 
   /* buffer to store previously received and decrypted data */
-  if(BACKEND->decdata_buffer == NULL) {
+  if(!BACKEND->decdata_buffer) {
     BACKEND->decdata_offset = 0;
     BACKEND->decdata_length = CURL_SCHANNEL_BUFFER_INIT_SIZE;
     BACKEND->decdata_buffer = malloc(BACKEND->decdata_length);
-    if(BACKEND->decdata_buffer == NULL) {
+    if(!BACKEND->decdata_buffer) {
       failf(data, "schannel: unable to allocate memory");
       return CURLE_OUT_OF_MEMORY;
     }
   }
 
   /* buffer to store previously received and encrypted data */
-  if(BACKEND->encdata_buffer == NULL) {
+  if(!BACKEND->encdata_buffer) {
     BACKEND->encdata_is_incomplete = false;
     BACKEND->encdata_offset = 0;
     BACKEND->encdata_length = CURL_SCHANNEL_BUFFER_INIT_SIZE;
     BACKEND->encdata_buffer = malloc(BACKEND->encdata_length);
-    if(BACKEND->encdata_buffer == NULL) {
+    if(!BACKEND->encdata_buffer) {
       failf(data, "schannel: unable to allocate memory");
       return CURLE_OUT_OF_MEMORY;
     }
@@ -1044,7 +1044,7 @@ schannel_connect_step2(struct Curl_easy *data, struct connectdata *conn,
     reallocated_buffer = realloc(BACKEND->encdata_buffer,
                                  reallocated_length);
 
-    if(reallocated_buffer == NULL) {
+    if(!reallocated_buffer) {
       failf(data, "schannel: unable to re-allocate memory");
       return CURLE_OUT_OF_MEMORY;
     }
@@ -1099,7 +1099,7 @@ schannel_connect_step2(struct Curl_easy *data, struct connectdata *conn,
     InitSecBuffer(&outbuf[2], SECBUFFER_EMPTY, NULL, 0);
     InitSecBufferDesc(&outbuf_desc, outbuf, 3);
 
-    if(inbuf[0].pvBuffer == NULL) {
+    if(!inbuf[0].pvBuffer) {
       failf(data, "schannel: unable to allocate memory");
       return CURLE_OUT_OF_MEMORY;
     }
@@ -1451,7 +1451,7 @@ schannel_connect_step3(struct Curl_easy *data, struct connectdata *conn,
                                        SECPKG_ATTR_REMOTE_CERT_CONTEXT,
                                        &ccert_context);
 
-    if((sspi_status != SEC_E_OK) || (ccert_context == NULL)) {
+    if((sspi_status != SEC_E_OK) || !ccert_context) {
       failf(data, "schannel: failed to retrieve remote cert context");
       return CURLE_PEER_FAILED_VERIFICATION;
     }
@@ -1803,7 +1803,7 @@ schannel_recv(struct Curl_easy *data, int sockindex,
       }
       reallocated_buffer = realloc(BACKEND->encdata_buffer,
                                    reallocated_length);
-      if(reallocated_buffer == NULL) {
+      if(!reallocated_buffer) {
         *err = CURLE_OUT_OF_MEMORY;
         failf(data, "schannel: unable to re-allocate memory");
         goto cleanup;
@@ -1892,7 +1892,7 @@ schannel_recv(struct Curl_easy *data, int sockindex,
           }
           reallocated_buffer = realloc(BACKEND->decdata_buffer,
                                        reallocated_length);
-          if(reallocated_buffer == NULL) {
+          if(!reallocated_buffer) {
             *err = CURLE_OUT_OF_MEMORY;
             failf(data, "schannel: unable to re-allocate memory");
             goto cleanup;
@@ -2294,7 +2294,7 @@ static CURLcode pkp_pin_peer_pubkey(struct Curl_easy *data,
                                        SECPKG_ATTR_REMOTE_CERT_CONTEXT,
                                        &pCertContextServer);
 
-    if((sspi_status != SEC_E_OK) || (pCertContextServer == NULL)) {
+    if((sspi_status != SEC_E_OK) || !pCertContextServer) {
       char buffer[STRERROR_LEN];
       failf(data, "schannel: Failed to read remote certificate context: %s",
             Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));

+ 2 - 2
lib/vtls/schannel_verify.c

@@ -389,7 +389,7 @@ static DWORD cert_get_name_string(struct Curl_easy *data,
     if(entry->dwAltNameChoice != CERT_ALT_NAME_DNS_NAME) {
       continue;
     }
-    if(entry->pwszDNSName == NULL) {
+    if(!entry->pwszDNSName) {
       infof(data, "schannel: Empty DNS name.");
       continue;
     }
@@ -549,7 +549,7 @@ CURLcode Curl_verify_certificate(struct Curl_easy *data,
                                      SECPKG_ATTR_REMOTE_CERT_CONTEXT,
                                      &pCertContextServer);
 
-  if((sspi_status != SEC_E_OK) || (pCertContextServer == NULL)) {
+  if((sspi_status != SEC_E_OK) || !pCertContextServer) {
     char buffer[STRERROR_LEN];
     failf(data, "schannel: Failed to read remote certificate context: %s",
           Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));

+ 11 - 11
lib/vtls/sectransp.c

@@ -1324,7 +1324,7 @@ CF_INLINE bool is_file(const char *filename)
 {
   struct_stat st;
 
-  if(filename == NULL)
+  if(!filename)
     return false;
 
   if(stat(filename, &st) == 0)
@@ -2142,21 +2142,21 @@ static long pem_to_der(const char *in, unsigned char **out, size_t *outlen)
 
   /* Jump through the separators at the beginning of the certificate. */
   sep_start = strstr(in, "-----");
-  if(sep_start == NULL)
+  if(!sep_start)
     return 0;
   cert_start = strstr(sep_start + 1, "-----");
-  if(cert_start == NULL)
+  if(!cert_start)
     return -1;
 
   cert_start += 5;
 
   /* Find separator after the end of the certificate. */
   cert_end = strstr(cert_start, "-----");
-  if(cert_end == NULL)
+  if(!cert_end)
     return -1;
 
   sep_end = strstr(cert_end + 1, "-----");
-  if(sep_end == NULL)
+  if(!sep_end)
     return -1;
   sep_end += 5;
 
@@ -2293,7 +2293,7 @@ static CURLcode verify_cert(const char *cafile, struct Curl_easy *data,
    */
   CFMutableArrayRef array = CFArrayCreateMutable(kCFAllocatorDefault, 0,
                                                  &kCFTypeArrayCallBacks);
-  if(array == NULL) {
+  if(!array) {
     free(certbuf);
     failf(data, "SSL: out of memory creating CA certificate array");
     return CURLE_OUT_OF_MEMORY;
@@ -2343,7 +2343,7 @@ static CURLcode verify_cert(const char *cafile, struct Curl_easy *data,
 
   SecTrustRef trust;
   OSStatus ret = SSLCopyPeerTrust(ctx, &trust);
-  if(trust == NULL) {
+  if(!trust) {
     failf(data, "SSL: error getting certificate chain");
     CFRelease(array);
     return CURLE_PEER_FAILED_VERIFICATION;
@@ -2416,19 +2416,19 @@ static CURLcode pkp_pin_peer_pubkey(struct Curl_easy *data,
   do {
     SecTrustRef trust;
     OSStatus ret = SSLCopyPeerTrust(ctx, &trust);
-    if(ret != noErr || trust == NULL)
+    if(ret != noErr || !trust)
       break;
 
     SecKeyRef keyRef = SecTrustCopyPublicKey(trust);
     CFRelease(trust);
-    if(keyRef == NULL)
+    if(!keyRef)
       break;
 
 #ifdef SECTRANSP_PINNEDPUBKEY_V1
 
     publicKeyBits = SecKeyCopyExternalRepresentation(keyRef, NULL);
     CFRelease(keyRef);
-    if(publicKeyBits == NULL)
+    if(!publicKeyBits)
       break;
 
 #elif SECTRANSP_PINNEDPUBKEY_V2
@@ -2436,7 +2436,7 @@ static CURLcode pkp_pin_peer_pubkey(struct Curl_easy *data,
     OSStatus success = SecItemExport(keyRef, kSecFormatOpenSSL, 0, NULL,
                                      &publicKeyBits);
     CFRelease(keyRef);
-    if(success != errSecSuccess || publicKeyBits == NULL)
+    if(success != errSecSuccess || !publicKeyBits)
       break;
 
 #endif /* SECTRANSP_PINNEDPUBKEY_V2 */

+ 3 - 3
src/tool_convert.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
@@ -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;
   }
 

+ 6 - 6
src/tool_metalink.c

@@ -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);

+ 5 - 5
src/tool_operate.c

@@ -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;
           }

+ 1 - 1
src/tool_vms.c

@@ -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;
   }

+ 2 - 2
tests/libtest/lib1511.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
@@ -58,7 +58,7 @@ int test(char *URL)
     goto test_cleanup;
 
   curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &unmet);
-  if(unmet != 0L) {
+  if(unmet) {
     res = TEST_ERR_FAILURE; /* not correct */
     goto test_cleanup;
   }

+ 2 - 2
tests/libtest/lib1532.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
@@ -66,7 +66,7 @@ int test(char *URL)
             __FILE__, __LINE__, res, curl_easy_strerror(res));
     goto test_cleanup;
   }
-  if(httpcode != 0) {
+  if(httpcode) {
     fprintf(stderr, "%s:%d curl_easy_reset failed to zero the response code\n"
             "possible regression of github bug 1017\n", __FILE__, __LINE__);
     res = CURLE_HTTP_RETURNED_ERROR;

+ 2 - 2
tests/libtest/lib1533.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
@@ -137,7 +137,7 @@ int test(char *URL)
   }
 
   curl = curl_easy_init();
-  if(curl == NULL) {
+  if(!curl) {
     fprintf(stderr, "curl_easy_init() failed\n");
     curl_global_cleanup();
     return TEST_ERR_MAJOR_BAD;

+ 4 - 4
tests/libtest/lib1535.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
@@ -44,7 +44,7 @@ int test(char *URL)
             __FILE__, __LINE__, res, curl_easy_strerror(res));
     goto test_cleanup;
   }
-  if(protocol != 0) {
+  if(protocol) {
     fprintf(stderr, "%s:%d protocol init failed; expected 0 but is %ld\n",
             __FILE__, __LINE__, protocol);
     res = CURLE_FAILED_INIT;
@@ -94,7 +94,7 @@ int test(char *URL)
             __FILE__, __LINE__, res, curl_easy_strerror(res));
     goto test_cleanup;
   }
-  if(protocol != 0) {
+  if(protocol) {
     fprintf(stderr, "%s:%d protocol init failed; expected 0 but is %ld\n",
             __FILE__, __LINE__, protocol);
     res = CURLE_FAILED_INIT;
@@ -113,7 +113,7 @@ int test(char *URL)
             __FILE__, __LINE__, res, curl_easy_strerror(res));
     goto test_cleanup;
   }
-  if(protocol != 0) {
+  if(protocol) {
     fprintf(stderr, "%s:%d protocol init failed; expected 0 but is %ld\n",
             __FILE__, __LINE__, protocol);
     res = CURLE_FAILED_INIT;

+ 3 - 3
tests/libtest/lib1536.c

@@ -69,7 +69,7 @@ int test(char *URL)
             __FILE__, __LINE__, res, curl_easy_strerror(res));
     goto test_cleanup;
   }
-  if(scheme == NULL || memcmp(scheme, "HTTP", 5) != 0) {
+  if(!scheme || memcmp(scheme, "HTTP", 5) != 0) {
     fprintf(stderr, "%s:%d scheme of http resource is incorrect; "
             "expected 'HTTP' but is %s\n",
             __FILE__, __LINE__,
@@ -95,7 +95,7 @@ int test(char *URL)
             __FILE__, __LINE__, res, curl_easy_strerror(res));
     goto test_cleanup;
   }
-  if(scheme != 0) {
+  if(scheme) {
     fprintf(stderr, "%s:%d scheme init failed; expected NULL\n",
             __FILE__, __LINE__);
     res = CURLE_FAILED_INIT;
@@ -114,7 +114,7 @@ int test(char *URL)
             __FILE__, __LINE__, res, curl_easy_strerror(res));
     goto test_cleanup;
   }
-  if(scheme != 0) {
+  if(scheme) {
     fprintf(stderr, "%s:%d scheme init failed; expected NULL\n",
             __FILE__, __LINE__);
     res = CURLE_FAILED_INIT;

+ 2 - 2
tests/libtest/lib510.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
@@ -80,7 +80,7 @@ int test(char *URL)
   }
 
   slist = curl_slist_append(slist, "Transfer-Encoding: chunked");
-  if(slist == NULL) {
+  if(!slist) {
     fprintf(stderr, "curl_slist_append() failed\n");
     curl_easy_cleanup(curl);
     curl_global_cleanup();

+ 2 - 2
tests/libtest/lib518.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
@@ -83,7 +83,7 @@ static int fopen_works(void)
   }
   for(i = 0; i < 3; i++) {
     fpa[i] = fopen(DEV_NULL, FOPEN_READTEXT);
-    if(fpa[i] == NULL) {
+    if(!fpa[i]) {
       store_errmsg("fopen failed", errno);
       fprintf(stderr, "%s\n", msgbuff);
       ret = 0;

+ 2 - 2
tests/libtest/lib537.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
@@ -84,7 +84,7 @@ static int fopen_works(void)
   }
   for(i = 0; i < 3; i++) {
     fpa[i] = fopen(DEV_NULL, FOPEN_READTEXT);
-    if(fpa[i] == NULL) {
+    if(!fpa[i]) {
       store_errmsg("fopen failed", errno);
       fprintf(stderr, "%s\n", msgbuff);
       ret = 0;

+ 3 - 3
tests/libtest/lib539.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
@@ -60,14 +60,14 @@ int test(char *URL)
     * call to freedirs).
     */
    newURL = aprintf("%s./", URL);
-   if(newURL == NULL) {
+   if(!newURL) {
      curl_easy_cleanup(curl);
      curl_global_cleanup();
      return TEST_ERR_MAJOR_BAD;
    }
 
    slist = curl_slist_append(NULL, "SYST");
-   if(slist == NULL) {
+   if(!slist) {
      free(newURL);
      curl_easy_cleanup(curl);
      curl_global_cleanup();

+ 2 - 2
tests/libtest/lib556.c

@@ -92,10 +92,10 @@ int test(char *URL)
             break;
         }
 
-      } while((res == CURLE_OK && iolen != 0) || (res == CURLE_AGAIN));
+      } while((res == CURLE_OK && iolen) || (res == CURLE_AGAIN));
     }
 
-    if(iolen != 0)
+    if(iolen)
       res = (CURLcode)TEST_ERR_FAILURE;
   }
 

+ 2 - 2
tests/libtest/lib568.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
@@ -81,7 +81,7 @@ int test(char *URL)
   close(sdp);
 
   sdpf = fopen("log/file568.txt", "rb");
-  if(sdpf == NULL) {
+  if(!sdpf) {
     fprintf(stderr, "can't open log/file568.txt\n");
     res = TEST_ERR_MAJOR_BAD;
     goto test_cleanup;

+ 2 - 2
tests/libtest/lib569.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
@@ -41,7 +41,7 @@ int test(char *URL)
   int i;
 
   FILE *idfile = fopen(libtest_arg2, "wb");
-  if(idfile == NULL) {
+  if(!idfile) {
     fprintf(stderr, "couldn't open the Session ID File\n");
     return TEST_ERR_MAJOR_BAD;
   }

+ 2 - 2
tests/libtest/lib571.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
@@ -106,7 +106,7 @@ int test(char *URL)
   int request = 1;
 
   FILE *protofile = fopen(libtest_arg2, "wb");
-  if(protofile == NULL) {
+  if(!protofile) {
     fprintf(stderr, "Couldn't open the protocol dump file\n");
     return TEST_ERR_MAJOR_BAD;
   }

+ 2 - 2
tests/libtest/lib572.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
@@ -100,7 +100,7 @@ int test(char *URL)
   close(params);
 
   paramsf = fopen("log/file572.txt", "rb");
-  if(paramsf == NULL) {
+  if(!paramsf) {
     fprintf(stderr, "can't open log/file572.txt\n");
     res = TEST_ERR_MAJOR_BAD;
     goto test_cleanup;

+ 2 - 2
tests/libtest/lib579.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
@@ -104,7 +104,7 @@ int test(char *URL)
   }
 
   slist = curl_slist_append(slist, "Transfer-Encoding: chunked");
-  if(slist == NULL) {
+  if(!slist) {
     fprintf(stderr, "curl_slist_append() failed\n");
     curl_easy_cleanup(curl);
     curl_global_cleanup();

+ 2 - 2
tests/libtest/lib661.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
@@ -97,7 +97,7 @@ int test(char *URL)
    }
 
    slist = curl_slist_append(NULL, "SYST");
-   if(slist == NULL) {
+   if(!slist) {
      fprintf(stderr, "curl_slist_append() failed\n");
      res = TEST_ERR_MAJOR_BAD;
      goto test_cleanup;

+ 4 - 4
tests/server/rtspd.c

@@ -369,7 +369,7 @@ static int ProcessRequest(struct httprequest *req)
                   memcpy(rtp_scratch + 4 + i, RTP_DATA, RTP_DATA_SIZE);
                 }
 
-                if(req->rtp_buffer == NULL) {
+                if(!req->rtp_buffer) {
                   req->rtp_buffer = rtp_scratch;
                   req->rtp_buffersize = rtp_size + 4;
                 }
@@ -599,15 +599,15 @@ static void storerequest(char *reqbuf, size_t totalsize)
   size_t writeleft;
   FILE *dump;
 
-  if(reqbuf == NULL)
+  if(!reqbuf)
     return;
   if(totalsize == 0)
     return;
 
   do {
     dump = fopen(REQUEST_DUMP, "ab");
-  } while((dump == NULL) && ((error = errno) == EINTR));
-  if(dump == NULL) {
+  } while(!dump && ((error = errno) == EINTR));
+  if(!dump) {
     logmsg("Error opening file %s error: %d %s",
            REQUEST_DUMP, error, strerror(error));
     logmsg("Failed to write request input to " REQUEST_DUMP);

+ 3 - 3
tests/server/sockfilt.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
@@ -668,7 +668,7 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds,
 
   /* allocate internal array for the internal data */
   data = calloc(nfds, sizeof(struct select_ws_data));
-  if(data == NULL) {
+  if(!data) {
     CloseHandle(abort);
     CloseHandle(mutex);
     errno = ENOMEM;
@@ -677,7 +677,7 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds,
 
   /* allocate internal array for the internal event handles */
   handles = calloc(nfds + 1, sizeof(HANDLE));
-  if(handles == NULL) {
+  if(!handles) {
     CloseHandle(abort);
     CloseHandle(mutex);
     free(data);

+ 2 - 2
tests/server/socksd.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
@@ -479,7 +479,7 @@ static curl_socket_t sockit(curl_socket_t fd)
     return CURL_SOCKET_BAD;
   }
   /* reserved, should be zero */
-  if(buffer[SOCKS5_RESERVED] != 0) {
+  if(buffer[SOCKS5_RESERVED]) {
     logmsg("Request COMMAND byte not %d", config.reqcmd);
     return CURL_SOCKET_BAD;
   }

+ 4 - 4
tests/server/sws.c

@@ -792,15 +792,15 @@ static void storerequest(const char *reqbuf, size_t totalsize)
   FILE *dump;
   const char *dumpfile = is_proxy?REQUEST_PROXY_DUMP:REQUEST_DUMP;
 
-  if(reqbuf == NULL)
+  if(!reqbuf)
     return;
   if(totalsize == 0)
     return;
 
   do {
     dump = fopen(dumpfile, "ab");
-  } while((dump == NULL) && ((error = errno) == EINTR));
-  if(dump == NULL) {
+  } while(!dump && ((error = errno) == EINTR));
+  if(!dump) {
     logmsg("[2] Error opening file %s error: %d %s",
            dumpfile, error, strerror(error));
     logmsg("Failed to write request input ");
@@ -2313,7 +2313,7 @@ int main(int argc, char *argv[])
           }
 
           /* Reset the request, unless we're still in the middle of reading */
-          if(rc != 0)
+          if(rc)
             init_httprequest(&req);
         } while(rc > 0);
       }

+ 3 - 3
tests/server/util.c

@@ -171,7 +171,7 @@ void win32_init(void)
   wVersionRequested = MAKEWORD(2, 2);
   err = WSAStartup(wVersionRequested, &wsaData);
 
-  if(err != 0) {
+  if(err) {
     perror("Winsock init failed");
     logmsg("Error initialising winsock -- aborting");
     exit(1);
@@ -317,8 +317,8 @@ void set_advisor_read_lock(const char *filename)
 
   do {
     lockfile = fopen(filename, "wb");
-  } while((lockfile == NULL) && ((error = errno) == EINTR));
-  if(lockfile == NULL) {
+  } while(!lockfile && ((error = errno) == EINTR));
+  if(!lockfile) {
     logmsg("Error creating lock file %s error: %d %s",
            filename, error, strerror(error));
     return;

+ 2 - 2
tests/unit/unit1309.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
@@ -40,7 +40,7 @@ static void splayprint(struct Curl_tree *t, int d, char output)
   struct Curl_tree *node;
   int i;
   int count;
-  if(t == NULL)
+  if(!t)
     return;
 
   splayprint(t->larger, d + 1, output);

+ 1 - 1
tests/unit/unit1607.c

@@ -194,7 +194,7 @@ UNITTEST_START
         break;
       }
 
-      if(dns->timestamp != 0 && tests[i].permanent) {
+      if(dns->timestamp && tests[i].permanent) {
         fprintf(stderr, "%s:%d tests[%d] failed. the timestamp is not zero "
                 "but tests[%d].permanent is TRUE\n",
                 __FILE__, __LINE__, i, i);