From nobody Mon Feb 9 01:11:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1607359386; cv=none; d=zohomail.com; s=zohoarc; b=kLCdnIUHkyODLs7S4aIWQmzYmpc3HJkKq0zdiZyJc4M3ybdLqUtROyLLXoPeIJDJRw08ml3eDCQ8nQjzsKuVSEaMTUWhkGjrg1ofbVh8EHaRWM91G5ohcSTjMn37RQoVqK95QVUa5Uzqq7DBja2EVlv8IlqzLBC0A11QmeBQUjc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607359386; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ucS5GzOUVeQeKgvsa8FpyEO2tvHJTnFdHBSrb2EGMG4=; b=Cjmz9jWZg9Gi+is6XFxKpEmkWQaz1GlssKSgeUmNhRZQlRNQhrfd/V6sflxWdnNzffjUVws4exnpaQDmj/5dDuo7EKZ5AfsJiA2zWuj9r9cU4JnJbvo82mly973kzIRYnuLERRn+ENaTJyugbBC11RXAyHhq2TpMMBLSSnAcDWo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1607359385596603.8815711051564; Mon, 7 Dec 2020 08:43:05 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-249-a6mglfHNMSytGJ2kvQtEfA-1; Mon, 07 Dec 2020 11:34:51 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C797C107ACE8; Mon, 7 Dec 2020 16:34:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 57D9A5D9E8; Mon, 7 Dec 2020 16:34:44 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1EFFC5002D; Mon, 7 Dec 2020 16:34:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B7GYNUu029079 for ; Mon, 7 Dec 2020 11:34:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 758375D6AD; Mon, 7 Dec 2020 16:34:23 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB5D15D6AB for ; Mon, 7 Dec 2020 16:34:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607358894; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ucS5GzOUVeQeKgvsa8FpyEO2tvHJTnFdHBSrb2EGMG4=; b=cJxugTdQTvG189EMGmegVN1u2JEtrTFb+5NiJWuRzw+JKumTdujJwraL5JFw4xsopM9C2Z SKqiNECSiNH0GSR+ScOh4WbWGGCn4ukb99JoBgc0zJOMQQg0kmUODbaLx3XQaNT5tQrIaa 1cpiNGkzZLJR3AwwSlwyZgupk9qhC/0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607359139; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ucS5GzOUVeQeKgvsa8FpyEO2tvHJTnFdHBSrb2EGMG4=; b=O2/6CzRROKJpvpWdMurTMpnUdy+B5rf6RcPlJyRwmqCaQBUmhup7pw88IwxILFKBYIpFlt LlUn+g0VYJgcsMpjF3Nnq6NKGHPDYzQ74db9Tpk979ZhzsY26V5XLPYTWvOkrLtMW+ENmo SHQ9KK1VflUrbehwzQAzgBiVc+JpTi0= X-MC-Unique: a6mglfHNMSytGJ2kvQtEfA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/8] qemuDomainDiskLookupByNodename: Simplify node name lookup Date: Mon, 7 Dec 2020 17:34:10 +0100 Message-Id: <9d7be0eef1511211058bb0c1311777f8e62afc74.1607358804.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use dummy variable to fill 'src' so that access to it doesn't need to be conditionalized and use temporary variable for 'disk' rather than dereferencing the array multiple times. Signed-off-by: Peter Krempa --- src/qemu/qemu_domain.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2275c83aa8..f5d4e468ce 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9911,24 +9911,18 @@ qemuDomainDiskLookupByNodename(virDomainDefPtr def, size_t i; virStorageSourcePtr tmp =3D NULL; - if (src) - *src =3D NULL; + if (!src) + src =3D &tmp; for (i =3D 0; i < def->ndisks; i++) { - if ((tmp =3D virStorageSourceFindByNodeName(def->disks[i]->src, no= dename))) { - if (src) - *src =3D tmp; + virDomainDiskDefPtr domdisk =3D def->disks[i]; - return def->disks[i]; - } - - if (def->disks[i]->mirror && - (tmp =3D virStorageSourceFindByNodeName(def->disks[i]->mirror,= nodename))) { - if (src) - *src =3D tmp; + if ((*src =3D virStorageSourceFindByNodeName(domdisk->src, nodenam= e))) + return domdisk; - return def->disks[i]; - } + if (domdisk->mirror && + (*src =3D virStorageSourceFindByNodeName(domdisk->mirror, node= name))) + return domdisk; } return NULL; --=20 2.28.0