[glib: 1/3] guri: Remove unnecessary NULL pointer check




commit f19cb44b988d6c523ad8409cfb7fc8e4fec1033a
Author: Philip Withnall <withnall endlessm com>
Date:   Tue Sep 8 09:59:24 2020 +0100

    guri: Remove unnecessary NULL pointer check
    
    `uri` is always non-`NULL` by the time the `fail` label is reached, so
    drop the `NULL` pointer check. Inline the `fail` code since it’s only
    used from two places.
    
    Coverity CID: #1430970
    Signed-off-by: Philip Withnall <withnall endlessm com>

 glib/guri.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/glib/guri.c b/glib/guri.c
index ad467987b..dc885a5d6 100644
--- a/glib/guri.c
+++ b/glib/guri.c
@@ -1257,13 +1257,17 @@ g_uri_parse_relative (GUri         *base_uri,
                              &uri->host, &uri->port,
                              &uri->path, &uri->query, &uri->fragment,
                              error))
-    goto fail;
+    {
+      g_uri_unref (uri);
+      return NULL;
+    }
 
   if (!uri->scheme && !base_uri)
     {
       g_set_error_literal (error, G_URI_ERROR, G_URI_ERROR_FAILED,
                            _("URI is not absolute, and no base URI was provided"));
-      goto fail;
+      g_uri_unref (uri);
+      return NULL;
     }
 
   if (base_uri)
@@ -1326,11 +1330,6 @@ g_uri_parse_relative (GUri         *base_uri,
     }
 
   return g_steal_pointer (&uri);
-
- fail:
-  if (uri)
-    g_uri_unref (uri);
-  return NULL;
 }
 
 /**


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