Patchwork [2/7] iscsi: reorganize code for parse_initiator_name

login
register
mail settings
Submitter Paolo Bonzini
Date Aug. 9, 2012, 1:38 p.m.
Message ID <1344519511-18147-3-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/176097/
State New
Headers show

Comments

Paolo Bonzini - Aug. 9, 2012, 1:38 p.m.
Merge the occurrences of the "iqn.2008-11.org.linux-kvm" string
to avoid duplication.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block/iscsi.c | 21 +++++++++------------
 1 file modificato, 9 inserzioni(+), 12 rimozioni(-)

Patch

diff --git a/block/iscsi.c b/block/iscsi.c
index 94063ab..fd954d4 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -898,24 +898,21 @@  static char *parse_initiator_name(const char *target)
     const char *name = NULL;
 
     list = qemu_find_opts("iscsi");
-    if (!list) {
-        return g_strdup("iqn.2008-11.org.linux-kvm");
-    }
-
-    opts = qemu_opts_find(list, target);
-    if (opts == NULL) {
-        opts = QTAILQ_FIRST(&list->head);
+    if (list) {
+        opts = qemu_opts_find(list, target);
         if (!opts) {
-            return g_strdup("iqn.2008-11.org.linux-kvm");
+            opts = QTAILQ_FIRST(&list->head);
+        }
+        if (opts) {
+            name = qemu_opt_get(opts, "initiator-name");
         }
     }
 
-    name = qemu_opt_get(opts, "initiator-name");
-    if (!name) {
+    if (name) {
+        return g_strdup(name);
+    } else {
         return g_strdup("iqn.2008-11.org.linux-kvm");
     }
-
-    return g_strdup(name);
 }
 
 /*