05bba0
From beb312b86b7ee776bbaea14d3c7625ec8d2d8402 Mon Sep 17 00:00:00 2001
05bba0
From: Markus Armbruster <armbru@redhat.com>
05bba0
Date: Tue, 8 Sep 2015 18:06:19 +0200
05bba0
Subject: [PATCH 1/7] Drop superfluous conditionals around g_strdup()
05bba0
05bba0
Message-id: <1441735585-23432-2-git-send-email-armbru@redhat.com>
05bba0
Patchwork-id: 67708
05bba0
O-Subject: [RHEL-7.2 qemu-kvm PATCH 1/7] Drop superfluous conditionals around g_strdup()
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
Reviewed-by: Fam Zheng <famz@redhat.com>
05bba0
Reviewed-by: Eric Blake <eblake@redhat.com>
05bba0
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
05bba0
(cherry picked from commit 24588100ab39afead7b9a0e9c61182a02320a1b9)
05bba0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
05bba0
---
05bba0
 backends/rng-random.c    |  6 +-----
05bba0
 hw/tpm/tpm_passthrough.c |  4 +---
05bba0
 util/uri.c               | 43 +++++++++++++++++--------------------------
05bba0
 3 files changed, 19 insertions(+), 34 deletions(-)
05bba0
05bba0
diff --git a/backends/rng-random.c b/backends/rng-random.c
05bba0
index 68dfc8a..573a64e 100644
05bba0
--- a/backends/rng-random.c
05bba0
+++ b/backends/rng-random.c
05bba0
@@ -88,11 +88,7 @@ static char *rng_random_get_filename(Object *obj, Error **errp)
05bba0
 {
05bba0
     RndRandom *s = RNG_RANDOM(obj);
05bba0
 
05bba0
-    if (s->filename) {
05bba0
-        return g_strdup(s->filename);
05bba0
-    }
05bba0
-
05bba0
-    return NULL;
05bba0
+    return g_strdup(s->filename);
05bba0
 }
05bba0
 
05bba0
 static void rng_random_set_filename(Object *obj, const char *filename,
05bba0
diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c
05bba0
index 56e9e0f..2bf3c6f 100644
05bba0
--- a/hw/tpm/tpm_passthrough.c
05bba0
+++ b/hw/tpm/tpm_passthrough.c
05bba0
@@ -400,9 +400,7 @@ static int tpm_passthrough_handle_device_opts(QemuOpts *opts, TPMBackend *tb)
05bba0
     const char *value;
05bba0
 
05bba0
     value = qemu_opt_get(opts, "cancel-path");
05bba0
-    if (value) {
05bba0
-        tb->cancel_path = g_strdup(value);
05bba0
-    }
05bba0
+    tb->cancel_path = g_strdup(value);
05bba0
 
05bba0
     value = qemu_opt_get(opts, "path");
05bba0
     if (!value) {
05bba0
diff --git a/util/uri.c b/util/uri.c
05bba0
index e348c17..bbf2832 100644
05bba0
--- a/util/uri.c
05bba0
+++ b/util/uri.c
05bba0
@@ -1736,24 +1736,21 @@ uri_resolve(const char *uri, const char *base) {
05bba0
 	goto done;
05bba0
     if ((ref->scheme == NULL) && (ref->path == NULL) &&
05bba0
 	((ref->authority == NULL) && (ref->server == NULL))) {
05bba0
-	if (bas->scheme != NULL)
05bba0
-	    res->scheme = g_strdup(bas->scheme);
05bba0
+        res->scheme = g_strdup(bas->scheme);
05bba0
 	if (bas->authority != NULL)
05bba0
 	    res->authority = g_strdup(bas->authority);
05bba0
 	else if (bas->server != NULL) {
05bba0
-	    res->server = g_strdup(bas->server);
05bba0
-	    if (bas->user != NULL)
05bba0
-		res->user = g_strdup(bas->user);
05bba0
-	    res->port = bas->port;
05bba0
+            res->server = g_strdup(bas->server);
05bba0
+            res->user = g_strdup(bas->user);
05bba0
+            res->port = bas->port;
05bba0
 	}
05bba0
-	if (bas->path != NULL)
05bba0
-	    res->path = g_strdup(bas->path);
05bba0
-	if (ref->query != NULL)
05bba0
+        res->path = g_strdup(bas->path);
05bba0
+        if (ref->query != NULL) {
05bba0
 	    res->query = g_strdup (ref->query);
05bba0
-	else if (bas->query != NULL)
05bba0
-	    res->query = g_strdup(bas->query);
05bba0
-	if (ref->fragment != NULL)
05bba0
-	    res->fragment = g_strdup(ref->fragment);
05bba0
+        } else {
05bba0
+            res->query = g_strdup(bas->query);
05bba0
+        }
05bba0
+        res->fragment = g_strdup(ref->fragment);
05bba0
 	goto step_7;
05bba0
     }
05bba0
 
05bba0
@@ -1767,13 +1764,10 @@ uri_resolve(const char *uri, const char *base) {
05bba0
 	val = uri_to_string(ref);
05bba0
 	goto done;
05bba0
     }
05bba0
-    if (bas->scheme != NULL)
05bba0
-	res->scheme = g_strdup(bas->scheme);
05bba0
+    res->scheme = g_strdup(bas->scheme);
05bba0
 
05bba0
-    if (ref->query != NULL)
05bba0
-	res->query = g_strdup(ref->query);
05bba0
-    if (ref->fragment != NULL)
05bba0
-	res->fragment = g_strdup(ref->fragment);
05bba0
+    res->query = g_strdup(ref->query);
05bba0
+    res->fragment = g_strdup(ref->fragment);
05bba0
 
05bba0
     /*
05bba0
      * 4) If the authority component is defined, then the reference is a
05bba0
@@ -1787,20 +1781,17 @@ uri_resolve(const char *uri, const char *base) {
05bba0
 	    res->authority = g_strdup(ref->authority);
05bba0
 	else {
05bba0
 	    res->server = g_strdup(ref->server);
05bba0
-	    if (ref->user != NULL)
05bba0
-		res->user = g_strdup(ref->user);
05bba0
+            res->user = g_strdup(ref->user);
05bba0
             res->port = ref->port;
05bba0
 	}
05bba0
-	if (ref->path != NULL)
05bba0
-	    res->path = g_strdup(ref->path);
05bba0
+        res->path = g_strdup(ref->path);
05bba0
 	goto step_7;
05bba0
     }
05bba0
     if (bas->authority != NULL)
05bba0
 	res->authority = g_strdup(bas->authority);
05bba0
     else if (bas->server != NULL) {
05bba0
-	res->server = g_strdup(bas->server);
05bba0
-	if (bas->user != NULL)
05bba0
-	    res->user = g_strdup(bas->user);
05bba0
+        res->server = g_strdup(bas->server);
05bba0
+        res->user = g_strdup(bas->user);
05bba0
 	res->port = bas->port;
05bba0
     }
05bba0
 
05bba0
-- 
05bba0
1.8.3.1
05bba0