From patchwork Thu Aug 9 13:38:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 176097 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 292BE2C00E3 for ; Thu, 9 Aug 2012 23:39:41 +1000 (EST) Received: from localhost ([::1]:60159 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzSxf-0002CQ-4s for incoming@patchwork.ozlabs.org; Thu, 09 Aug 2012 09:39:39 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:x-mailer:in-reply-to :references; bh=NQF8nUIEtiMfv2ruDoNZwUHcXJ+jQRDHyJBeWsiWVqc=; b=ki4sNdZTVgEOv+hDaytzLv+afBnTgytFsOY9Ex302Cl2HfxS3jESPtVDuPpPvYY8EG 2DN9hnSJdM64/J7s0Nq1yLrjETxjDgTrArP91CboZhVSI2SkHTMRO9hmn9xx7XVc6ERW CrOzHH8bw/9J/IOthNaLJt8Op95zG7f51TDKp3dvXp1c/zsuuAlG3e4Bj2tGP6s9o8iu eDF/25bsq2xWtS8RGQ73vsSJs0OKBEQaessCx7LVGZjzCijA26MVOC9Xu/Q7UtH3VDh0 WccjLGXcbPucmwkuuJ05l+CBfGOltYArOSx2CPj2XJ1OmYbmKAP2tZFALNWHk3wo3aqK LNjw== Received: by 10.66.76.231 with SMTP id n7mr8737534paw.68.1344519562193; Thu, 09 Aug 2012 06:39:22 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-169-1.ip50.fastwebnet.it. [93.34.169.1]) by mx.google.com with ESMTPS id qa2sm788320pbb.21.2012.08.09.06.39.19 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 09 Aug 2012 06:39:21 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 9 Aug 2012 15:38:26 +0200 Message-Id: <1344519511-18147-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <1344519511-18147-1-git-send-email-pbonzini@redhat.com> References: <1344519511-18147-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.173 Subject: [Qemu-devel] [PATCH 2/7] iscsi: reorganize code for parse_initiator_name X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@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); } /*