05bba0
From 9a2e25a1a72443b00a54fb1660c818856c2569c6 Mon Sep 17 00:00:00 2001
05bba0
From: Markus Armbruster <armbru@redhat.com>
05bba0
Date: Tue, 8 Sep 2015 18:06:22 +0200
05bba0
Subject: [PATCH 4/7] util/uri: uri_new() can't fail, drop dead error handling
05bba0
05bba0
Message-id: <1441735585-23432-5-git-send-email-armbru@redhat.com>
05bba0
Patchwork-id: 67703
05bba0
O-Subject: [RHEL-7.2 qemu-kvm PATCH 4/7] util/uri: uri_new() can't fail, drop dead error handling
05bba0
Bugzilla: 1218919
05bba0
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
05bba0
RH-Acked-by: Fam Zheng <famz@redhat.com>
05bba0
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
05bba0
05bba0
Signed-off-by: Markus Armbruster <armbru@redhat.com>
05bba0
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
05bba0
(cherry picked from commit c89c6e80a66aac16d7b14ff21e0aaeb99ebfe165)
05bba0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
05bba0
---
05bba0
 util/uri.c | 36 +++++++++++-------------------------
05bba0
 1 file changed, 11 insertions(+), 25 deletions(-)
05bba0
05bba0
diff --git a/util/uri.c b/util/uri.c
05bba0
index 918d235..aa39694 100644
05bba0
--- a/util/uri.c
05bba0
+++ b/util/uri.c
05bba0
@@ -928,12 +928,10 @@ uri_parse(const char *str) {
05bba0
     if (str == NULL)
05bba0
 	return(NULL);
05bba0
     uri = uri_new();
05bba0
-    if (uri != NULL) {
05bba0
-	ret = rfc3986_parse_uri_reference(uri, str);
05bba0
-        if (ret) {
05bba0
-	    uri_free(uri);
05bba0
-	    return(NULL);
05bba0
-	}
05bba0
+    ret = rfc3986_parse_uri_reference(uri, str);
05bba0
+    if (ret) {
05bba0
+        uri_free(uri);
05bba0
+        return(NULL);
05bba0
     }
05bba0
     return(uri);
05bba0
 }
05bba0
@@ -974,15 +972,13 @@ uri_parse_raw(const char *str, int raw) {
05bba0
     if (str == NULL)
05bba0
 	return(NULL);
05bba0
     uri = uri_new();
05bba0
-    if (uri != NULL) {
05bba0
-        if (raw) {
05bba0
-	    uri->cleanup |= 2;
05bba0
-	}
05bba0
-	ret = uri_parse_into(uri, str);
05bba0
-        if (ret) {
05bba0
-	    uri_free(uri);
05bba0
-	    return(NULL);
05bba0
-	}
05bba0
+    if (raw) {
05bba0
+        uri->cleanup |= 2;
05bba0
+    }
05bba0
+    ret = uri_parse_into(uri, str);
05bba0
+    if (ret) {
05bba0
+        uri_free(uri);
05bba0
+        return(NULL);
05bba0
     }
05bba0
     return(uri);
05bba0
 }
05bba0
@@ -1675,8 +1671,6 @@ uri_resolve(const char *uri, const char *base) {
05bba0
     else {
05bba0
 	if (*uri) {
05bba0
 	    ref = uri_new();
05bba0
-	    if (ref == NULL)
05bba0
-		goto done;
05bba0
 	    ret = uri_parse_into(ref, uri);
05bba0
 	}
05bba0
 	else
05bba0
@@ -1695,8 +1689,6 @@ uri_resolve(const char *uri, const char *base) {
05bba0
 	ret = -1;
05bba0
     else {
05bba0
 	bas = uri_new();
05bba0
-	if (bas == NULL)
05bba0
-	    goto done;
05bba0
 	ret = uri_parse_into(bas, base);
05bba0
     }
05bba0
     if (ret != 0) {
05bba0
@@ -1727,8 +1719,6 @@ uri_resolve(const char *uri, const char *base) {
05bba0
      *    document.
05bba0
      */
05bba0
     res = uri_new();
05bba0
-    if (res == NULL)
05bba0
-	goto done;
05bba0
     if ((ref->scheme == NULL) && (ref->path == NULL) &&
05bba0
 	((ref->authority == NULL) && (ref->server == NULL))) {
05bba0
         res->scheme = g_strdup(bas->scheme);
05bba0
@@ -1933,8 +1923,6 @@ uri_resolve_relative (const char *uri, const char * base)
05bba0
      * First parse URI into a standard form
05bba0
      */
05bba0
     ref = uri_new ();
05bba0
-    if (ref == NULL)
05bba0
-	return NULL;
05bba0
     /* If URI not already in "relative" form */
05bba0
     if (uri[0] != '.') {
05bba0
 	ret = uri_parse_into (ref, uri);
05bba0
@@ -1951,8 +1939,6 @@ uri_resolve_relative (const char *uri, const char * base)
05bba0
 	goto done;
05bba0
     }
05bba0
     bas = uri_new ();
05bba0
-    if (bas == NULL)
05bba0
-	goto done;
05bba0
     if (base[0] != '.') {
05bba0
 	ret = uri_parse_into (bas, base);
05bba0
 	if (ret != 0)
05bba0
-- 
05bba0
1.8.3.1
05bba0