From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38073) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzSxQ-0001wf-8M for qemu-devel@nongnu.org; Thu, 09 Aug 2012 09:39:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SzSxP-0003rE-4X for qemu-devel@nongnu.org; Thu, 09 Aug 2012 09:39:24 -0400 Received: from mail-gh0-f173.google.com ([209.85.160.173]:50913) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzSxP-0003r8-0D for qemu-devel@nongnu.org; Thu, 09 Aug 2012 09:39:23 -0400 Received: by ghrr17 with SMTP id r17so412872ghr.4 for ; Thu, 09 Aug 2012 06:39:22 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 9 Aug 2012 15:38:26 +0200 Message-Id: <1344519511-18147-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1344519511-18147-1-git-send-email-pbonzini@redhat.com> References: <1344519511-18147-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 2/7] iscsi: reorganize code for parse_initiator_name List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Merge the occurrences of the "iqn.2008-11.org.linux-kvm" string to avoid duplication. Signed-off-by: Paolo Bonzini --- block/iscsi.c | 21 +++++++++------------ 1 file modificato, 9 inserzioni(+), 12 rimozioni(-) 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); } /* -- 1.7.11.2