[glib-networking/mcatanzaro/#72] Stop writing out '== NULL' and '!= NULL'



commit c13f8cfd7f06b98e30fca34c610c6c2c6965eac8
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Mon Jun 24 11:59:22 2019 -0500

    Stop writing out '== NULL' and '!= NULL'
    
    Currently glib-networking code style is inconsistent on whether to test
    for NULL using !pointer or pointer == NULL. This is harmful because it
    forces us to think and make a decision each time when writing such
    conditions.
    
    We have somewhat-arbitrarily agreed to stop writing this out longways.
    The tiebreaker is the C++ core guidelines (endorsed by the C++
    standardization people):
    
    http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es87-dont-add-redundant--or--to-conditions
    
    glib-networking is not C++, but the decision either way is arbitrary, so
    this seems like as good a tiebreaker as any. Also, WebKit requires it
    this way, and therefore so does Epiphany.
    
    Fixes #72

 proxy/gnome/gproxyresolvergnome.c          |  6 ++---
 proxy/libproxy/glibproxyresolver.c         |  4 ++--
 tls/base/gtlsconnection-base.c             | 38 ++++++++++++++----------------
 tls/base/gtlsinputstream.c                 | 10 ++++----
 tls/base/gtlsoutputstream.c                | 10 ++++----
 tls/gnutls/gtlsbackend-gnutls.c            |  4 ++--
 tls/gnutls/gtlscertificate-gnutls.c        | 16 ++++++-------
 tls/gnutls/gtlsclientconnection-gnutls.c   |  2 +-
 tls/gnutls/gtlsconnection-gnutls.c         |  2 +-
 tls/gnutls/gtlsdatabase-gnutls.c           | 28 +++++++++++-----------
 tls/openssl/gtlsbackend-openssl.c          |  2 +-
 tls/openssl/gtlsbio.c                      | 30 +++++++++++------------
 tls/openssl/gtlscertificate-openssl.c      | 12 +++++-----
 tls/openssl/gtlsclientconnection-openssl.c | 20 ++++++++--------
 tls/openssl/gtlsconnection-openssl.c       | 12 +++++-----
 tls/openssl/gtlsdatabase-openssl.c         |  8 +++----
 tls/openssl/gtlsfiledatabase-openssl.c     | 26 ++++++++++----------
 tls/openssl/gtlsserverconnection-openssl.c | 18 +++++++-------
 tls/tests/file-database.c                  | 10 ++++----
 19 files changed, 128 insertions(+), 130 deletions(-)
---
diff --git a/proxy/gnome/gproxyresolvergnome.c b/proxy/gnome/gproxyresolvergnome.c
index 7b6c310..1d81773 100644
--- a/proxy/gnome/gproxyresolvergnome.c
+++ b/proxy/gnome/gproxyresolvergnome.c
@@ -318,14 +318,14 @@ g_proxy_resolver_gnome_is_supported (GProxyResolver *object)
   const char *desktops;
 
   desktops = g_getenv ("XDG_CURRENT_DESKTOP");
-  if (desktops == NULL)
+  if (!desktops)
     return FALSE;
 
   /* Remember that XDG_CURRENT_DESKTOP is a list of strings. Desktops that
    * pretend to be GNOME and want to use our proxy settings will list
    * themselves alongside GNOME. That's fine; they'll get our proxy settings.
    */
-  return strstr (desktops, "GNOME") != NULL;
+  return !!strstr (desktops, "GNOME");
 }
 
 /* Threadsafely determines what to do with @uri; returns %FALSE if an
@@ -527,7 +527,7 @@ void
 g_proxy_resolver_gnome_register (GIOModule *module)
 {
   g_proxy_resolver_gnome_register_type (G_TYPE_MODULE (module));
-  if (module == NULL)
+  if (!module)
     g_io_extension_point_register (G_PROXY_RESOLVER_EXTENSION_POINT_NAME);
   g_io_extension_point_implement (G_PROXY_RESOLVER_EXTENSION_POINT_NAME,
                                   g_proxy_resolver_gnome_get_type(),
diff --git a/proxy/libproxy/glibproxyresolver.c b/proxy/libproxy/glibproxyresolver.c
index 402d5a3..40fb940 100644
--- a/proxy/libproxy/glibproxyresolver.c
+++ b/proxy/libproxy/glibproxyresolver.c
@@ -83,7 +83,7 @@ static gboolean
 g_libproxy_resolver_is_supported (GProxyResolver *object)
 {
   GLibproxyResolver *resolver = G_LIBPROXY_RESOLVER (object);
-  return resolver->factory != NULL;
+  return !!resolver->factory;
 }
 
 static gchar **
@@ -233,7 +233,7 @@ void
 g_libproxy_resolver_register (GIOModule *module)
 {
   g_libproxy_resolver_register_type (G_TYPE_MODULE (module));
-  if (module == NULL)
+  if (!module)
     g_io_extension_point_register (G_PROXY_RESOLVER_EXTENSION_POINT_NAME);
   g_io_extension_point_implement (G_PROXY_RESOLVER_EXTENSION_POINT_NAME,
                                   g_libproxy_resolver_get_type(),
diff --git a/tls/base/gtlsconnection-base.c b/tls/base/gtlsconnection-base.c
index 5e747c5..e28a3b8 100644
--- a/tls/base/gtlsconnection-base.c
+++ b/tls/base/gtlsconnection-base.c
@@ -204,7 +204,7 @@ g_tls_connection_base_is_dtls (GTlsConnectionBase *tls)
 {
   GTlsConnectionBasePrivate *priv = g_tls_connection_base_get_instance_private (tls);
 
-  return priv->base_socket != NULL;
+  return !!priv->base_socket;
 }
 
 static void
@@ -357,8 +357,7 @@ g_tls_connection_base_set_property (GObject      *object,
   switch (prop_id)
     {
     case PROP_BASE_IO_STREAM:
-      g_assert (g_value_get_object (value) == NULL ||
-                priv->base_socket == NULL);
+      g_assert (!g_value_get_object (value) || !priv->base_socket);
 
       if (priv->base_io_stream)
         {
@@ -388,8 +387,7 @@ g_tls_connection_base_set_property (GObject      *object,
       break;
 
     case PROP_BASE_SOCKET:
-      g_assert (g_value_get_object (value) == NULL ||
-                priv->base_io_stream == NULL);
+      g_assert (!g_value_get_object (value) || !priv->base_io_stream);
 
       g_clear_object (&priv->base_socket);
       priv->base_socket = g_value_dup_object (value);
@@ -1038,9 +1036,9 @@ g_tls_connection_base_create_source (GTlsConnectionBase  *tls,
   tls_source->condition = condition;
   if (g_tls_connection_base_is_dtls (tls))
     tls_source->base = G_OBJECT (tls);
-  else if (priv->tls_istream != NULL && condition & G_IO_IN)
+  else if (priv->tls_istream && condition & G_IO_IN)
     tls_source->base = G_OBJECT (priv->tls_istream);
-  else if (priv->tls_ostream != NULL && condition & G_IO_OUT)
+  else if (priv->tls_ostream && condition & G_IO_OUT)
     tls_source->base = G_OBJECT (priv->tls_ostream);
   else
     g_assert_not_reached ();
@@ -1160,7 +1158,7 @@ verify_peer_certificate (GTlsConnectionBase *tls,
   errors = 0;
 
   database = g_tls_connection_get_database (G_TLS_CONNECTION (tls));
-  if (database == NULL)
+  if (!database)
     {
       errors |= G_TLS_CERTIFICATE_UNKNOWN_CA;
       errors |= g_tls_certificate_verify (peer_certificate, peer_identity, NULL);
@@ -1233,7 +1231,7 @@ accept_or_reject_peer_certificate (gpointer user_data)
 
   update_peer_certificate_and_compute_errors (tls);
 
-  if (G_IS_TLS_CLIENT_CONNECTION (tls) && priv->peer_certificate != NULL)
+  if (G_IS_TLS_CLIENT_CONNECTION (tls) && priv->peer_certificate)
     {
       GTlsCertificateFlags validation_flags;
 
@@ -1328,7 +1326,7 @@ handshake_thread (GTask        *task,
   gint64 timeout;
 
   /* A timeout, in microseconds, must be provided as a gint64* task_data. */
-  g_assert (task_data != NULL);
+  g_assert (task_data);
   start_time = g_get_monotonic_time ();
   timeout = *((gint64 *)task_data);
 
@@ -1509,7 +1507,7 @@ g_tls_connection_base_handshake (GTlsConnection   *conn,
   gint64 *timeout = NULL;
   GError *my_error = NULL;
 
-  g_assert (priv->handshake_context == NULL);
+  g_assert (!priv->handshake_context);
   priv->handshake_context = g_main_context_new ();
 
   g_main_context_push_thread_default (priv->handshake_context);
@@ -1696,7 +1694,7 @@ do_implicit_handshake (GTlsConnectionBase  *tls,
 
   /* We have op_mutex */
 
-  g_assert (priv->handshake_context == NULL);
+  g_assert (!priv->handshake_context);
   if (timeout != 0)
     {
       priv->handshake_context = g_main_context_new ();
@@ -1707,7 +1705,7 @@ do_implicit_handshake (GTlsConnectionBase  *tls,
       priv->handshake_context = g_main_context_ref_thread_default ();
     }
 
-  g_assert (priv->implicit_handshake == NULL);
+  g_assert (!priv->implicit_handshake);
   priv->implicit_handshake = g_task_new (tls, cancellable,
                                         timeout ? sync_handshake_thread_completed : NULL,
                                         NULL);
@@ -1893,7 +1891,7 @@ g_tls_connection_base_receive_messages (GDatagramBased  *datagram_based,
       return -1;
     }
 
-  for (i = 0; i < num_messages && child_error == NULL; i++)
+  for (i = 0; i < num_messages && !child_error; i++)
     {
       GInputMessage *message = &messages[i];
       gssize n_bytes_read;
@@ -1905,10 +1903,10 @@ g_tls_connection_base_receive_messages (GDatagramBased  *datagram_based,
                                                          cancellable,
                                                          &child_error);
 
-      if (message->address != NULL)
+      if (message->address)
         *message->address = NULL;
       message->flags = G_SOCKET_MSG_NONE;
-      if (message->control_messages != NULL)
+      if (message->control_messages)
         *message->control_messages = NULL;
       message->num_control_messages = 0;
 
@@ -1939,7 +1937,7 @@ g_tls_connection_base_receive_messages (GDatagramBased  *datagram_based,
         }
     }
 
-  if (child_error != NULL)
+  if (child_error)
     {
       g_propagate_error (error, child_error);
       return -1;
@@ -2028,7 +2026,7 @@ g_tls_connection_base_send_messages (GDatagramBased  *datagram_based,
       return -1;
     }
 
-  for (i = 0; i < num_messages && child_error == NULL; i++)
+  for (i = 0; i < num_messages && !child_error; i++)
     {
       GOutputMessage *message = &messages[i];
       gssize n_bytes_sent;
@@ -2062,7 +2060,7 @@ g_tls_connection_base_send_messages (GDatagramBased  *datagram_based,
         }
     }
 
-  if (child_error != NULL)
+  if (child_error)
     {
       g_propagate_error (error, child_error);
       return -1;
@@ -2138,7 +2136,7 @@ g_tls_connection_base_close_internal (GIOStream      *stream,
   /* Close the underlying streams. Do this even if the close_fn() call failed,
    * as the parent GIOStream will have set its internal closed flag and hence
    * this implementation will never be called again. */
-  if (priv->base_io_stream != NULL)
+  if (priv->base_io_stream)
     {
       if (direction == G_TLS_DIRECTION_BOTH)
         success = g_io_stream_close (priv->base_io_stream,
diff --git a/tls/base/gtlsinputstream.c b/tls/base/gtlsinputstream.c
index bc4ebcf..3b3a02f 100644
--- a/tls/base/gtlsinputstream.c
+++ b/tls/base/gtlsinputstream.c
@@ -72,7 +72,7 @@ g_tls_input_stream_read (GInputStream  *stream,
   gssize ret;
 
   conn = g_weak_ref_get (&tls_stream->weak_conn);
-  if (conn == NULL)
+  if (!conn)
     {
       g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
                            _("Connection is closed"));
@@ -94,7 +94,7 @@ g_tls_input_stream_pollable_is_readable (GPollableInputStream *pollable)
   gboolean ret;
 
   conn = g_weak_ref_get (&tls_stream->weak_conn);
-  if (conn == NULL)
+  if (!conn)
     return FALSE;
 
   ret = g_tls_connection_base_check (conn, G_IO_IN);
@@ -112,7 +112,7 @@ g_tls_input_stream_pollable_create_source (GPollableInputStream *pollable,
   GSource *ret;
 
   conn = g_weak_ref_get (&tls_stream->weak_conn);
-  if (conn == NULL)
+  if (!conn)
     {
       ret = g_idle_source_new ();
       g_source_set_name (ret, "[glib-networking] g_tls_input_stream_pollable_create_source dummy source");
@@ -135,7 +135,7 @@ g_tls_input_stream_pollable_read_nonblocking (GPollableInputStream  *pollable,
   gssize ret;
 
   conn = g_weak_ref_get (&tls_stream->weak_conn);
-  if (conn == NULL)
+  if (!conn)
     {
       g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
                            _("Connection is closed"));
@@ -160,7 +160,7 @@ g_tls_input_stream_close (GInputStream             *stream,
 
   conn = g_weak_ref_get (&tls_stream->weak_conn);
 
-  if (conn == NULL)
+  if (!conn)
     return TRUE;
 
   ret = g_tls_connection_base_close_internal (conn, G_TLS_DIRECTION_READ,
diff --git a/tls/base/gtlsoutputstream.c b/tls/base/gtlsoutputstream.c
index 30f9d76..249dc44 100644
--- a/tls/base/gtlsoutputstream.c
+++ b/tls/base/gtlsoutputstream.c
@@ -72,7 +72,7 @@ g_tls_output_stream_write (GOutputStream  *stream,
   gssize ret;
 
   conn = g_weak_ref_get (&tls_stream->weak_conn);
-  if (conn == NULL)
+  if (!conn)
     {
       g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
                            _("Connection is closed"));
@@ -93,7 +93,7 @@ g_tls_output_stream_pollable_is_writable (GPollableOutputStream *pollable)
   gboolean ret;
 
   conn = g_weak_ref_get (&tls_stream->weak_conn);
-  if (conn == NULL)
+  if (!conn)
     return FALSE;
 
   ret = g_tls_connection_base_check (conn, G_IO_OUT);
@@ -112,7 +112,7 @@ g_tls_output_stream_pollable_create_source (GPollableOutputStream *pollable,
   GSource *ret;
 
   conn = g_weak_ref_get (&tls_stream->weak_conn);
-  if (conn == NULL)
+  if (!conn)
     {
       ret = g_idle_source_new ();
       g_source_set_name (ret, "[glib-networking] g_tls_output_stream_pollable_create_source dummy source");
@@ -137,7 +137,7 @@ g_tls_output_stream_pollable_write_nonblocking (GPollableOutputStream  *pollable
   gssize ret;
 
   conn = g_weak_ref_get (&tls_stream->weak_conn);
-  if (conn == NULL)
+  if (!conn)
     {
       g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
                            _("Connection is closed"));
@@ -162,7 +162,7 @@ g_tls_output_stream_close (GOutputStream            *stream,
 
   conn = g_weak_ref_get (&tls_stream->weak_conn);
 
-  if (conn == NULL)
+  if (!conn)
     return TRUE;
 
   ret = g_tls_connection_base_close_internal (conn, G_TLS_DIRECTION_WRITE,
diff --git a/tls/gnutls/gtlsbackend-gnutls.c b/tls/gnutls/gtlsbackend-gnutls.c
index ec68152..d0e5eaa 100644
--- a/tls/gnutls/gtlsbackend-gnutls.c
+++ b/tls/gnutls/gtlsbackend-gnutls.c
@@ -72,7 +72,7 @@ gtls_gnutls_init (gpointer data)
 
   /* Leak the module to keep it from being unloaded. */
   plugin = g_type_get_plugin (G_TYPE_TLS_BACKEND_GNUTLS);
-  if (plugin != NULL)
+  if (plugin)
     g_type_plugin_use (plugin);
   return NULL;
 }
@@ -306,7 +306,7 @@ void
 g_tls_backend_gnutls_register (GIOModule *module)
 {
   g_tls_backend_gnutls_register_type (G_TYPE_MODULE (module));
-  if (module == NULL)
+  if (!module)
     g_io_extension_point_register (G_TLS_BACKEND_EXTENSION_POINT_NAME);
   g_io_extension_point_implement (G_TLS_BACKEND_EXTENSION_POINT_NAME,
                                   g_tls_backend_gnutls_get_type (),
diff --git a/tls/gnutls/gtlscertificate-gnutls.c b/tls/gnutls/gtlscertificate-gnutls.c
index ff18c46..c6a79fd 100644
--- a/tls/gnutls/gtlscertificate-gnutls.c
+++ b/tls/gnutls/gtlscertificate-gnutls.c
@@ -434,15 +434,15 @@ g_tls_certificate_gnutls_copy  (GTlsCertificateGnutls  *gnutls,
   int status;
 
   g_return_if_fail (G_IS_TLS_CERTIFICATE_GNUTLS (gnutls));
-  g_return_if_fail (pcert != NULL);
-  g_return_if_fail (pcert_length != NULL);
-  g_return_if_fail (pkey != NULL);
+  g_return_if_fail (pcert);
+  g_return_if_fail (pcert_length);
+  g_return_if_fail (pkey);
 
   /* We will do this loop twice. It's probably more efficient than
    * re-allocating memory.
    */
   chain = gnutls;
-  while (chain != NULL)
+  while (chain)
     {
       num_certs++;
       chain = chain->issuer;
@@ -453,7 +453,7 @@ g_tls_certificate_gnutls_copy  (GTlsCertificateGnutls  *gnutls,
 
   /* Now do the actual copy of the whole chain. */
   chain = gnutls;
-  while (chain != NULL)
+  while (chain)
     {
       gnutls_x509_crt_t cert;
       gnutls_datum_t data;
@@ -472,7 +472,7 @@ g_tls_certificate_gnutls_copy  (GTlsCertificateGnutls  *gnutls,
       chain = chain->issuer;
     }
 
-    if (gnutls->key != NULL)
+    if (gnutls->key)
       {
         gnutls_x509_privkey_t x509_privkey;
         gnutls_privkey_t privkey;
@@ -496,14 +496,14 @@ g_tls_certificate_gnutls_copy_free (gnutls_pcert_st  *pcert,
                                     unsigned int      pcert_length,
                                     gnutls_privkey_t  pkey)
 {
-  if (pcert != NULL)
+  if (pcert)
     {
       for (unsigned int i = 0; i < pcert_length; i++)
         gnutls_pcert_deinit (&pcert[i]);
       g_free (pcert);
     }
 
-  if (pkey != NULL)
+  if (pkey)
     gnutls_privkey_deinit (pkey);
 }
 
diff --git a/tls/gnutls/gtlsclientconnection-gnutls.c b/tls/gnutls/gtlsclientconnection-gnutls.c
index d450cac..e51b30d 100644
--- a/tls/gnutls/gtlsclientconnection-gnutls.c
+++ b/tls/gnutls/gtlsclientconnection-gnutls.c
@@ -369,7 +369,7 @@ g_tls_client_connection_gnutls_retrieve_function (gnutls_session_t
         }
     }
 
-  if (*pkey == NULL)
+  if (!*pkey)
     {
       g_tls_certificate_gnutls_copy_free (*pcert, *pcert_length, *pkey);
 
diff --git a/tls/gnutls/gtlsconnection-gnutls.c b/tls/gnutls/gtlsconnection-gnutls.c
index 1023bfa..1ac803a 100644
--- a/tls/gnutls/gtlsconnection-gnutls.c
+++ b/tls/gnutls/gtlsconnection-gnutls.c
@@ -235,7 +235,7 @@ g_tls_connection_gnutls_initable_init (GInitable     *initable,
   gnutls_transport_set_ptr (priv->session, gnutls);
 
   /* GDatagramBased supports vectored I/O; GPollableOutputStream does not. */
-  if (base_socket != NULL)
+  if (base_socket)
     {
       gnutls_transport_set_vec_push_function (priv->session,
                                               g_tls_connection_gnutls_vec_push_func);
diff --git a/tls/gnutls/gtlsdatabase-gnutls.c b/tls/gnutls/gtlsdatabase-gnutls.c
index 7704d56..7064d15 100644
--- a/tls/gnutls/gtlsdatabase-gnutls.c
+++ b/tls/gnutls/gtlsdatabase-gnutls.c
@@ -92,7 +92,7 @@ bytes_multi_table_insert (GHashTable *table,
   GPtrArray *multi;
 
   multi = g_hash_table_lookup (table, key);
-  if (multi == NULL)
+  if (!multi)
     {
       multi = g_ptr_array_new_with_free_func ((GDestroyNotify)g_bytes_unref);
       g_hash_table_insert (table, g_bytes_ref (key), multi);
@@ -107,7 +107,7 @@ bytes_multi_table_lookup_ref_one (GHashTable *table,
   GPtrArray *multi;
 
   multi = g_hash_table_lookup (table, key);
-  if (multi == NULL)
+  if (!multi)
     return NULL;
 
   g_assert (multi->len > 0);
@@ -123,7 +123,7 @@ bytes_multi_table_lookup_ref_all (GHashTable *table,
   guint i;
 
   multi = g_hash_table_lookup (table, key);
-  if (multi == NULL)
+  if (!multi)
     return NULL;
 
   for (i = 0; i < multi->len; i++)
@@ -149,7 +149,7 @@ create_handles_array_unlocked (GTlsDatabaseGnutls *self,
     {
       g_assert (G_TLS_DATABASE_GNUTLS_GET_CLASS (self)->create_handle_for_certificate);
       handle = G_TLS_DATABASE_GNUTLS_GET_CLASS (self)->create_handle_for_certificate (self, der);
-      if (handle != NULL)
+      if (handle)
         g_hash_table_insert (handles, handle, g_bytes_ref (der));
     }
 
@@ -251,7 +251,7 @@ g_tls_database_gnutls_create_certificate_handle (GTlsDatabase    *database,
   gchar *handle = NULL;
 
   der = g_tls_certificate_gnutls_get_bytes (G_TLS_CERTIFICATE_GNUTLS (certificate));
-  g_return_val_if_fail (der != NULL, FALSE);
+  g_return_val_if_fail (der, FALSE);
 
   g_mutex_lock (&priv->mutex);
 
@@ -299,12 +299,12 @@ g_tls_database_gnutls_lookup_certificate_for_handle (GTlsDatabase             *d
     priv->handles = create_handles_array_unlocked (self, priv->complete);
 
   der = g_hash_table_lookup (priv->handles, handle);
-  if (der != NULL)
+  if (der)
     g_bytes_ref (der);
 
   g_mutex_unlock (&priv->mutex);
 
-  if (der == NULL)
+  if (!der)
     return NULL;
 
   datum.data = (unsigned char *)g_bytes_get_data (der, &length);
@@ -367,14 +367,14 @@ g_tls_database_gnutls_lookup_certificate_issuer (GTlsDatabase             *datab
     {
       issuer = NULL;
     }
-  else if (der != NULL)
+  else if (der)
     {
       datum.data = (unsigned char *)g_bytes_get_data (der, &length);
       datum.size = length;
       issuer = g_tls_certificate_gnutls_new (&datum, NULL);
     }
 
-  if (der != NULL)
+  if (der)
     g_bytes_unref (der);
   return issuer;
 }
@@ -412,7 +412,7 @@ g_tls_database_gnutls_lookup_certificates_issued_by (GTlsDatabase             *d
 
   g_bytes_unref (issuer);
 
-  for (l = ders; l != NULL; l = g_list_next (l))
+  for (l = ders; l; l = g_list_next (l))
     {
       if (g_cancellable_set_error_if_cancelled (cancellable, error))
         {
@@ -643,13 +643,13 @@ g_tls_database_gnutls_initable_init (GInitable     *initable,
     }
 
 out:
-  if (trust_list != NULL)
+  if (trust_list)
     gnutls_x509_trust_list_deinit (trust_list, 1);
-  if (subjects != NULL)
+  if (subjects)
     g_hash_table_unref (subjects);
-  if (issuers != NULL)
+  if (issuers)
     g_hash_table_unref (issuers);
-  if (complete != NULL)
+  if (complete)
     g_hash_table_unref (complete);
   return result;
 }
diff --git a/tls/openssl/gtlsbackend-openssl.c b/tls/openssl/gtlsbackend-openssl.c
index 6b700dd..81e5138 100644
--- a/tls/openssl/gtlsbackend-openssl.c
+++ b/tls/openssl/gtlsbackend-openssl.c
@@ -140,7 +140,7 @@ gtls_openssl_init (gpointer data)
 
   /* Leak the module to keep it from being unloaded. */
   plugin = g_type_get_plugin (G_TYPE_TLS_BACKEND_OPENSSL);
-  if (plugin != NULL)
+  if (plugin)
     g_type_plugin_use (plugin);
   return NULL;
 }
diff --git a/tls/openssl/gtlsbio.c b/tls/openssl/gtlsbio.c
index 4dfd058..b138432 100644
--- a/tls/openssl/gtlsbio.c
+++ b/tls/openssl/gtlsbio.c
@@ -69,13 +69,13 @@ gtls_bio_create (BIO *bio)
 static int
 gtls_bio_destroy (BIO *bio)
 {
-  if (bio == NULL)
+  if (!bio)
     return 0;
 
 #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER)
   if (bio->shutdown)
     {
-      if (bio->ptr != NULL)
+      if (bio->ptr)
         {
           free_gbio (bio->ptr);
           bio->ptr = NULL;
@@ -86,7 +86,7 @@ gtls_bio_destroy (BIO *bio)
 #else
   if (BIO_get_shutdown (bio))
     {
-      if (BIO_get_data (bio) != NULL)
+      if (BIO_get_data (bio))
         {
           free_gbio (BIO_get_data (bio));
           BIO_set_data (bio, NULL);
@@ -155,7 +155,7 @@ gtls_bio_write (BIO        *bio,
 #else
       !BIO_get_init (bio) ||
 #endif
-      in == NULL || inl == 0)
+      !in || inl == 0)
     return 0;
 
 #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER)
@@ -197,7 +197,7 @@ gtls_bio_read (BIO  *bio,
 #else
       !BIO_get_init (bio) ||
 #endif
-      out == NULL || outl == 0)
+      !out || outl == 0)
     return 0;
 
 #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER)
@@ -265,10 +265,10 @@ BIO_s_gtls (void)
 static const BIO_METHOD *
 BIO_s_gtls (void)
 {
-  if (methods_gtls == NULL)
+  if (!methods_gtls)
     {
       methods_gtls = BIO_meth_new (BIO_TYPE_SOURCE_SINK | BIO_get_new_index (), "gtls");
-      if (methods_gtls == NULL ||
+      if (!methods_gtls ||
           !BIO_meth_set_write (methods_gtls, gtls_bio_write) ||
           !BIO_meth_set_read (methods_gtls, gtls_bio_read) ||
           !BIO_meth_set_puts (methods_gtls, gtls_bio_puts) ||
@@ -289,7 +289,7 @@ g_tls_bio_new (GIOStream *io_stream)
   GTlsBio *gbio;
 
   ret = BIO_new(BIO_s_gtls ());
-  if (ret == NULL)
+  if (!ret)
     return NULL;
 
   gbio = g_new0 (GTlsBio, 1);
@@ -314,7 +314,7 @@ g_tls_bio_set_read_cancellable (BIO          *bio,
 {
   GTlsBio *gbio;
 
-  g_return_if_fail (bio != NULL);
+  g_return_if_fail (bio);
 
 #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER)
   gbio = (GTlsBio *)bio->ptr;
@@ -330,7 +330,7 @@ g_tls_bio_set_read_blocking (BIO      *bio,
 {
   GTlsBio *gbio;
 
-  g_return_if_fail (bio != NULL);
+  g_return_if_fail (bio);
 
 #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER)
   gbio = (GTlsBio *)bio->ptr;
@@ -346,7 +346,7 @@ g_tls_bio_set_read_error (BIO     *bio,
 {
   GTlsBio *gbio;
 
-  g_return_if_fail (bio != NULL);
+  g_return_if_fail (bio);
 
 #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER)
   gbio = (GTlsBio *)bio->ptr;
@@ -362,7 +362,7 @@ g_tls_bio_set_write_cancellable (BIO          *bio,
 {
   GTlsBio *gbio;
 
-  g_return_if_fail (bio != NULL);
+  g_return_if_fail (bio);
 
 #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER)
   gbio = (GTlsBio *)bio->ptr;
@@ -378,7 +378,7 @@ g_tls_bio_set_write_blocking (BIO          *bio,
 {
   GTlsBio *gbio;
 
-  g_return_if_fail (bio != NULL);
+  g_return_if_fail (bio);
 
 #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER)
   gbio = (GTlsBio *)bio->ptr;
@@ -394,7 +394,7 @@ g_tls_bio_set_write_error (BIO     *bio,
 {
   GTlsBio *gbio;
 
-  g_return_if_fail (bio != NULL);
+  g_return_if_fail (bio);
 
 #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER)
   gbio = (GTlsBio *)bio->ptr;
@@ -423,7 +423,7 @@ g_tls_bio_wait_available (BIO          *bio,
   GTlsBio *gbio;
   GSource *source;
 
-  g_return_if_fail (bio != NULL);
+  g_return_if_fail (bio);
 
 #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER)
   gbio = (GTlsBio *)bio->ptr;
diff --git a/tls/openssl/gtlscertificate-openssl.c b/tls/openssl/gtlscertificate-openssl.c
index 698aea1..b0e1ed8 100644
--- a/tls/openssl/gtlscertificate-openssl.c
+++ b/tls/openssl/gtlscertificate-openssl.c
@@ -161,7 +161,7 @@ g_tls_certificate_openssl_set_property (GObject      *object,
       /* see that we cannot use bytes->data directly since it will move the pointer */
       data = bytes->data;
       openssl->cert = d2i_X509 (NULL, (const unsigned char **)&data, bytes->len);
-      if (openssl->cert != NULL)
+      if (openssl->cert)
         openssl->have_cert = TRUE;
       else if (!openssl->construct_error)
         {
@@ -181,7 +181,7 @@ g_tls_certificate_openssl_set_property (GObject      *object,
       bio = BIO_new_mem_buf ((gpointer)string, -1);
       openssl->cert = PEM_read_bio_X509 (bio, NULL, NULL, NULL);
       BIO_free (bio);
-      if (openssl->cert != NULL)
+      if (openssl->cert)
         openssl->have_cert = TRUE;
       else if (!openssl->construct_error)
         {
@@ -200,7 +200,7 @@ g_tls_certificate_openssl_set_property (GObject      *object,
       bio = BIO_new_mem_buf (bytes->data, bytes->len);
       openssl->key = d2i_PrivateKey_bio (bio, NULL);
       BIO_free (bio);
-      if (openssl->key != NULL)
+      if (openssl->key)
         openssl->have_key = TRUE;
       else if (!openssl->construct_error)
         {
@@ -219,7 +219,7 @@ g_tls_certificate_openssl_set_property (GObject      *object,
       bio = BIO_new_mem_buf ((gpointer)string, -1);
       openssl->key = PEM_read_bio_PrivateKey (bio, NULL, NULL, NULL);
       BIO_free (bio);
-      if (openssl->key != NULL)
+      if (openssl->key)
         openssl->have_key = TRUE;
       else if (!openssl->construct_error)
         {
@@ -410,7 +410,7 @@ g_tls_certificate_openssl_set_data (GTlsCertificateOpenssl *openssl,
   data = (const unsigned char *)g_bytes_get_data (bytes, NULL);
   openssl->cert = d2i_X509 (NULL, &data, g_bytes_get_size (bytes));
 
-  if (openssl->cert != NULL)
+  if (openssl->cert)
     openssl->have_cert = TRUE;
 }
 
@@ -610,7 +610,7 @@ g_tls_certificate_openssl_build_chain (X509            *x,
   GTlsCertificateOpenssl *result;
   guint i, j;
 
-  g_return_val_if_fail (x != NULL, NULL);
+  g_return_val_if_fail (x, NULL);
   g_return_val_if_fail (chain, NULL);
 
   glib_certs = g_ptr_array_new_full (sk_X509_num (chain), g_object_unref);
diff --git a/tls/openssl/gtlsclientconnection-openssl.c b/tls/openssl/gtlsclientconnection-openssl.c
index 68f89a0..972ab09 100644
--- a/tls/openssl/gtlsclientconnection-openssl.c
+++ b/tls/openssl/gtlsclientconnection-openssl.c
@@ -250,11 +250,11 @@ verify_ocsp_response (GTlsClientConnectionOpenssl *openssl,
   len = SSL_get_tlsext_status_ocsp_resp (ssl, &p);
   /* Soft fail in case of no response is the best we can do
    * FIXME: this makes it security theater, why bother with OCSP at all? */
-  if (p == NULL)
+  if (!p)
     return 0;
 
   resp = d2i_OCSP_RESPONSE (NULL, (const unsigned char **)&p, len);
-  if (resp == NULL)
+  if (!resp)
     return G_TLS_CERTIFICATE_GENERIC_ERROR;
 
   database = g_tls_connection_get_database (G_TLS_CONNECTION (openssl));
@@ -349,7 +349,7 @@ retrieve_certificate (SSL       *ssl,
   g_object_notify (G_OBJECT (client), "accepted-cas");
 
   cert = g_tls_connection_get_certificate (G_TLS_CONNECTION (client));
-  if (cert == NULL)
+  if (!cert)
     {
       g_clear_error (g_tls_connection_base_get_certificate_error (tls));
 
@@ -357,7 +357,7 @@ retrieve_certificate (SSL       *ssl,
         cert = g_tls_connection_get_certificate (G_TLS_CONNECTION (client));
     }
 
-  if (cert != NULL)
+  if (cert)
     {
       EVP_PKEY *key;
 
@@ -403,7 +403,7 @@ set_cipher_list (GTlsClientConnectionOpenssl  *client,
   const gchar *cipher_list;
 
   cipher_list = g_getenv ("G_TLS_OPENSSL_CIPHER_LIST");
-  if (cipher_list == NULL)
+  if (!cipher_list)
     cipher_list = DEFAULT_CIPHER_LIST;
 
   if (!SSL_CTX_set_cipher_list (client->ssl_ctx, cipher_list))
@@ -424,7 +424,7 @@ set_signature_algorithm_list (GTlsClientConnectionOpenssl *client)
   const gchar *signature_algorithm_list;
 
   signature_algorithm_list = g_getenv ("G_TLS_OPENSSL_SIGNATURE_ALGORITHM_LIST");
-  if (signature_algorithm_list == NULL)
+  if (!signature_algorithm_list)
     return;
 
   SSL_CTX_set1_sigalgs_list (client->ssl_ctx, signature_algorithm_list);
@@ -438,7 +438,7 @@ set_curve_list (GTlsClientConnectionOpenssl *client)
   const gchar *curve_list;
 
   curve_list = g_getenv ("G_TLS_OPENSSL_CURVE_LIST");
-  if (curve_list == NULL)
+  if (!curve_list)
     return;
 
   SSL_CTX_set1_curves_list (client->ssl_ctx, curve_list);
@@ -448,7 +448,7 @@ set_curve_list (GTlsClientConnectionOpenssl *client)
 static gboolean
 use_ocsp (void)
 {
-  return g_getenv ("G_TLS_OPENSSL_OCSP_ENABLED") != NULL;
+  return !!g_getenv ("G_TLS_OPENSSL_OCSP_ENABLED");
 }
 
 static gboolean
@@ -463,7 +463,7 @@ g_tls_client_connection_openssl_initable_init (GInitable       *initable,
   client->session = SSL_SESSION_new ();
 
   client->ssl_ctx = SSL_CTX_new (SSLv23_client_method ());
-  if (client->ssl_ctx == NULL)
+  if (!client->ssl_ctx)
     {
       g_set_error (error, G_TLS_ERROR, G_TLS_ERROR_MISC,
                    _("Could not create TLS context: %s"),
@@ -516,7 +516,7 @@ g_tls_client_connection_openssl_initable_init (GInitable       *initable,
 #endif
 
   client->ssl = SSL_new (client->ssl_ctx);
-  if (client->ssl == NULL)
+  if (!client->ssl)
     {
       g_set_error (error, G_TLS_ERROR, G_TLS_ERROR_MISC,
                    _("Could not create TLS connection: %s"),
diff --git a/tls/openssl/gtlsconnection-openssl.c b/tls/openssl/gtlsconnection-openssl.c
index 889a45c..d3c39b1 100644
--- a/tls/openssl/gtlsconnection-openssl.c
+++ b/tls/openssl/gtlsconnection-openssl.c
@@ -189,7 +189,7 @@ end_openssl_io (GTlsConnectionOpenssl  *openssl,
       return G_TLS_CONNECTION_BASE_ERROR;
     }
 
-  if (my_error != NULL)
+  if (my_error)
     g_propagate_error (error, my_error);
   else
     /* FIXME: this is just for debug */
@@ -270,11 +270,11 @@ g_tls_connection_openssl_retrieve_peer_certificate (GTlsConnectionBase *tls)
   ssl = g_tls_connection_openssl_get_ssl (G_TLS_CONNECTION_OPENSSL (tls));
 
   peer = SSL_get_peer_certificate (ssl);
-  if (peer == NULL)
+  if (!peer)
     return NULL;
 
   certs = SSL_get_peer_cert_chain (ssl);
-  if (certs == NULL)
+  if (!certs)
     {
       X509_free (peer);
       return NULL;
@@ -531,12 +531,12 @@ g_tls_connection_openssl_initable_init (GInitable     *initable,
   g_object_get (tls,
                 "base-io-stream", &base_io_stream,
                 NULL);
-  g_return_val_if_fail (base_io_stream != NULL, FALSE);
+  g_return_val_if_fail (base_io_stream, FALSE);
 
   priv = g_tls_connection_openssl_get_instance_private (openssl);
 
   ssl = g_tls_connection_openssl_get_ssl (openssl);
-  g_assert (ssl != NULL);
+  g_assert (ssl);
 
   if (data_index == -1) {
       data_index = SSL_get_ex_new_index (0, (void *)"gtlsconnection", NULL, NULL, NULL);
@@ -577,7 +577,7 @@ g_tls_connection_openssl_get_ssl (GTlsConnectionOpenssl *openssl)
 GTlsConnectionOpenssl *
 g_tls_connection_openssl_get_connection_from_ssl (SSL *ssl)
 {
-  g_return_val_if_fail (ssl != NULL, NULL);
+  g_return_val_if_fail (ssl, NULL);
 
   return SSL_get_ex_data (ssl, data_index);
 }
diff --git a/tls/openssl/gtlsdatabase-openssl.c b/tls/openssl/gtlsdatabase-openssl.c
index 193565f..232bcef 100644
--- a/tls/openssl/gtlsdatabase-openssl.c
+++ b/tls/openssl/gtlsdatabase-openssl.c
@@ -58,7 +58,7 @@ g_tls_database_openssl_finalize (GObject *object)
 
   priv = g_tls_database_openssl_get_instance_private (self);
 
-  if (priv->store != NULL)
+  if (priv->store)
     X509_STORE_free (priv->store);
 
   g_mutex_clear (&priv->mutex);
@@ -251,7 +251,7 @@ g_tls_database_openssl_initable_init (GInitable    *initable,
     }
 
 out:
-  if (store != NULL)
+  if (store)
     X509_STORE_free (store);
 
   return result;
@@ -354,10 +354,10 @@ g_tls_database_openssl_verify_ocsp_response (GTlsDatabaseOpenssl *self,
     }
 
 end:
-  if (basic_resp != NULL)
+  if (basic_resp)
     OCSP_BASICRESP_free (basic_resp);
 
-  if (resp != NULL)
+  if (resp)
     OCSP_RESPONSE_free (resp);
 
 #endif
diff --git a/tls/openssl/gtlsfiledatabase-openssl.c b/tls/openssl/gtlsfiledatabase-openssl.c
index 9dc14ec..a65cbfd 100644
--- a/tls/openssl/gtlsfiledatabase-openssl.c
+++ b/tls/openssl/gtlsfiledatabase-openssl.c
@@ -98,7 +98,7 @@ bytes_multi_table_insert (GHashTable *table,
   GPtrArray *multi;
 
   multi = g_hash_table_lookup (table, &key);
-  if (multi == NULL)
+  if (!multi)
     {
       int *key_ptr;
 
@@ -117,7 +117,7 @@ bytes_multi_table_lookup_ref_one (GHashTable *table,
   GPtrArray *multi;
 
   multi = g_hash_table_lookup (table, &key);
-  if (multi == NULL)
+  if (!multi)
     return NULL;
 
   g_assert (multi->len > 0);
@@ -133,7 +133,7 @@ bytes_multi_table_lookup_ref_all (GHashTable *table,
   guint i;
 
   multi = g_hash_table_lookup (table, &key);
-  if (multi == NULL)
+  if (!multi)
     return NULL;
 
   for (i = 0; i < multi->len; i++)
@@ -201,7 +201,7 @@ load_anchor_file (GTlsFileDatabaseOpenssl  *file_database,
       issuer = X509_issuer_name_hash (x);
 
       der = g_tls_certificate_openssl_get_bytes (l->data);
-      g_return_val_if_fail (der != NULL, FALSE);
+      g_return_val_if_fail (der, FALSE);
 
       g_hash_table_insert (complete, g_bytes_ref (der),
                            g_bytes_ref (der));
@@ -301,7 +301,7 @@ g_tls_file_database_openssl_create_certificate_handle (GTlsDatabase    *database
   gchar *handle = NULL;
 
   der = g_tls_certificate_openssl_get_bytes (G_TLS_CERTIFICATE_OPENSSL (certificate));
-  g_return_val_if_fail (der != NULL, FALSE);
+  g_return_val_if_fail (der, FALSE);
 
   g_mutex_lock (&file_database->mutex);
 
@@ -376,10 +376,10 @@ g_tls_file_database_openssl_lookup_certificate_issuer (GTlsDatabase
 
   if (g_cancellable_set_error_if_cancelled (cancellable, error))
     issuer = NULL;
-  else if (der != NULL)
+  else if (der)
     issuer = g_tls_certificate_openssl_new (der, NULL);
 
-  if (der != NULL)
+  if (der)
     g_bytes_unref (der);
   return issuer;
 
@@ -408,7 +408,7 @@ g_tls_file_database_openssl_lookup_certificates_issued_by (GTlsDatabase
 
   in = issuer_raw_dn->data;
   x_name = d2i_X509_NAME (NULL, &in, issuer_raw_dn->len);
-  if (x_name != NULL)
+  if (x_name)
     {
       unsigned long issuer_hash;
       GList *ders, *l;
@@ -420,7 +420,7 @@ g_tls_file_database_openssl_lookup_certificates_issued_by (GTlsDatabase
       ders = bytes_multi_table_lookup_ref_all (file_database->issuers, issuer_hash);
       g_mutex_unlock (&file_database->mutex);
 
-      for (l = ders; l != NULL; l = g_list_next (l))
+      for (l = ders; l; l = g_list_next (l))
         {
           if (g_cancellable_set_error_if_cancelled (cancellable, error))
             {
@@ -502,13 +502,13 @@ g_tls_file_database_openssl_populate_trust_list (GTlsDatabaseOpenssl  *self,
       g_mutex_unlock (&file_database->mutex);
     }
 
-  if (subjects != NULL)
+  if (subjects)
     g_hash_table_unref (subjects);
-  if (issuers != NULL)
+  if (issuers)
     g_hash_table_unref (issuers);
-  if (complete != NULL)
+  if (complete)
     g_hash_table_unref (complete);
-  if (certs_by_handle != NULL)
+  if (certs_by_handle)
     g_hash_table_unref (certs_by_handle);
   return result;
 }
diff --git a/tls/openssl/gtlsserverconnection-openssl.c b/tls/openssl/gtlsserverconnection-openssl.c
index a42294a..77d50ca 100644
--- a/tls/openssl/gtlsserverconnection-openssl.c
+++ b/tls/openssl/gtlsserverconnection-openssl.c
@@ -84,7 +84,7 @@ ssl_set_certificate (SSL              *ssl,
 
   key = g_tls_certificate_openssl_get_key (G_TLS_CERTIFICATE_OPENSSL (cert));
 
-  if (key == NULL)
+  if (!key)
     {
       g_set_error_literal (error, G_TLS_ERROR, G_TLS_ERROR_BAD_CERTIFICATE,
                            _("Certificate has no private key"));
@@ -117,7 +117,7 @@ ssl_set_certificate (SSL              *ssl,
 
   /* Add all the issuers to create the full certificate chain */
   for (issuer = g_tls_certificate_get_issuer (G_TLS_CERTIFICATE (cert));
-       issuer != NULL;
+       issuer;
        issuer = g_tls_certificate_get_issuer (issuer))
     {
       X509 *issuer_x;
@@ -279,7 +279,7 @@ set_cipher_list (GTlsServerConnectionOpenssl  *server,
   const gchar *cipher_list;
 
   cipher_list = g_getenv ("G_TLS_OPENSSL_CIPHER_LIST");
-  if (cipher_list == NULL)
+  if (!cipher_list)
     cipher_list = DEFAULT_CIPHER_LIST;
 
   if (!SSL_CTX_set_cipher_list (server->ssl_ctx, cipher_list))
@@ -300,7 +300,7 @@ set_signature_algorithm_list (GTlsServerConnectionOpenssl *server)
   const gchar *signature_algorithm_list;
 
   signature_algorithm_list = g_getenv ("G_TLS_OPENSSL_SIGNATURE_ALGORITHM_LIST");
-  if (signature_algorithm_list == NULL)
+  if (!signature_algorithm_list)
     return;
 
   SSL_CTX_set1_sigalgs_list (server->ssl_ctx, signature_algorithm_list);
@@ -314,7 +314,7 @@ set_curve_list (GTlsServerConnectionOpenssl *server)
   const gchar *curve_list;
 
   curve_list = g_getenv ("G_TLS_OPENSSL_CURVE_LIST");
-  if (curve_list == NULL)
+  if (!curve_list)
     return;
 
   SSL_CTX_set1_curves_list (server->ssl_ctx, curve_list);
@@ -333,7 +333,7 @@ g_tls_server_connection_openssl_initable_init (GInitable       *initable,
   server->session = SSL_SESSION_new ();
 
   server->ssl_ctx = SSL_CTX_new (SSLv23_server_method ());
-  if (server->ssl_ctx == NULL)
+  if (!server->ssl_ctx)
     {
       g_set_error (error, G_TLS_ERROR, G_TLS_ERROR_MISC,
                    _("Could not create TLS context: %s"),
@@ -381,7 +381,7 @@ g_tls_server_connection_openssl_initable_init (GInitable       *initable,
     EC_KEY *ecdh;
 
     ecdh = EC_KEY_new_by_curve_name (NID_X9_62_prime256v1);
-    if (ecdh != NULL)
+    if (ecdh)
       {
         SSL_CTX_set_tmp_ecdh (server->ssl_ctx, ecdh);
         EC_KEY_free (ecdh);
@@ -393,7 +393,7 @@ g_tls_server_connection_openssl_initable_init (GInitable       *initable,
 #endif
 
   server->ssl = SSL_new (server->ssl_ctx);
-  if (server->ssl == NULL)
+  if (!server->ssl)
     {
       g_set_error (error, G_TLS_ERROR, G_TLS_ERROR_MISC,
                    _("Could not create TLS connection: %s"),
@@ -402,7 +402,7 @@ g_tls_server_connection_openssl_initable_init (GInitable       *initable,
     }
 
   cert = g_tls_connection_get_certificate (G_TLS_CONNECTION (initable));
-  if (cert != NULL && !ssl_set_certificate (server->ssl, cert, error))
+  if (cert && !ssl_set_certificate (server->ssl, cert, error))
     return FALSE;
 
   SSL_set_accept_state (server->ssl);
diff --git a/tls/tests/file-database.c b/tls/tests/file-database.c
index ba1da86..ee954ad 100644
--- a/tls/tests/file-database.c
+++ b/tls/tests/file-database.c
@@ -249,12 +249,12 @@ load_certificate_chain (const char  *filename,
   GList *l;
 
   certificates = g_tls_certificate_list_new_from_file (filename, error);
-  if (certificates == NULL)
+  if (!certificates)
     return NULL;
 
   backend = g_tls_backend_get_default ();
   certificates = g_list_reverse (certificates);
-  for (l = certificates; l != NULL; l = g_list_next (l))
+  for (l = certificates; l; l = g_list_next (l))
     {
       prev_chain = chain;
       g_object_get (l->data, "certificate", &der, NULL);
@@ -274,7 +274,7 @@ static gboolean
 is_certificate_in_chain (GTlsCertificate *chain,
                          GTlsCertificate *cert)
 {
-  while (chain != NULL)
+  while (chain)
     {
       if (g_tls_certificate_is_same (chain, cert))
         return TRUE;
@@ -452,7 +452,7 @@ certificate_is_in_list (GList *certificates,
   cert = g_tls_certificate_new_from_file (filename, &error);
   g_assert_no_error (error);
 
-  for (l = certificates; l != NULL; l = g_list_next (l))
+  for (l = certificates; l; l = g_list_next (l))
     {
       if (g_tls_certificate_is_same (l->data, cert))
         break;
@@ -461,7 +461,7 @@ certificate_is_in_list (GList *certificates,
   g_object_unref (cert);
 
   /* Had an early break from loop */
-  return l != NULL;
+  return !!l;
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]