From nobody Sun May 19 21:29:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1575625547; cv=none; d=zohomail.com; s=zohoarc; b=KxhKGdPDeM0lYCOyq4EHquwzvFopNj1d62spNTOdH1NsA74FWdzwWrlPdX9nHRIbK3B2BlQmwWhWQgubbtHp/ysk70o2qCp2j0IkmKHBxeQNncFxNid50pbjmT5QlUcjObNRZLaGzFUwl7PkhlBRXq5PbL+itc0g+S4c3dLOUSM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575625547; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=IqyrnkwfMDYC20R7XBfEeibdsuZVl60lkFjEDSAVceI=; b=fDkU2v2RGEbjZVLQubG0QZcQh3ZEgrov8TgcBIkyf3+hJ5uPdA1VIdP9codyMomroBOdEyhkWgMGNVW5uYrHvsIDXRJkyF8+WsKxLWaSL1E3pM+llom5sOp6U7CuXAoaLCGZSYJ9Sd1ZAxJwcpUqQfVTJjPqgNqlu1TdJDMZ+18= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 157562554723187.06869309177125; Fri, 6 Dec 2019 01:45:47 -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-111-XblWBlzGNLuGKrzM84yFXg-1; Fri, 06 Dec 2019 04:45:44 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A1A6E64A7F; Fri, 6 Dec 2019 09:45:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C838F60167; Fri, 6 Dec 2019 09:45:37 +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 A0B8918089CE; Fri, 6 Dec 2019 09:45:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB69jW2s027813 for ; Fri, 6 Dec 2019 04:45:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id 13B135C545; Fri, 6 Dec 2019 09:45:32 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id 400675C219; Fri, 6 Dec 2019 09:45:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575625546; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=IqyrnkwfMDYC20R7XBfEeibdsuZVl60lkFjEDSAVceI=; b=Xak/azPp44rPNP6UNPfp9qkZ6LKcyb+nR3D5aAThTynzVbvWGzWXvWqsY2E1XyArQlHtKB tvTzQmBB4p55tZp6R0e1Lhe8/JXI9BEw8B/DqWa8tZQJmHNKVZje08k0Ui6TEg3BoT6bcC Rcr+BHgGQQS7Q6pIB+pHBtd97U4dVE4= From: Pavel Mores To: libvir-list@redhat.com Date: Fri, 6 Dec 2019 10:45:27 +0100 Message-Id: <20191206094527.15965-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Pavel Mores , crobinso@redhat.com Subject: [libvirt] [PATCH] qemu: remove nested branching to enhance readability 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.11 X-MC-Unique: XblWBlzGNLuGKrzM84yFXg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This is a follow-up to patch series posted in https://www.redhat.com/archives/libvir-list/2019-November/msg01180.html It implements a suggestion made by Cole in https://www.redhat.com/archives/libvir-list/2019-November/msg01207.html and discussed in follow-up messages as there were no objections to the change. The aim is to make the code more readable by replacing nested branching with a flat structure. Signed-off-by: Pavel Mores Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/qemu/qemu_domain.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d1596a28ca..5e4eede3c2 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7914,19 +7914,16 @@ static int qemuDomainDefaultVideoDevice(const virDomainDef *def, virQEMUCapsPtr qemuCaps) { - if (ARCH_IS_PPC64(def->os.arch)) { + if (ARCH_IS_PPC64(def->os.arch)) return VIR_DOMAIN_VIDEO_TYPE_VGA; - } else if (qemuDomainIsARMVirt(def) || - qemuDomainIsRISCVVirt(def) || - ARCH_IS_S390(def->os.arch)) { + if (qemuDomainIsARMVirt(def) || qemuDomainIsRISCVVirt(def) || + ARCH_IS_S390(def->os.arch)) return VIR_DOMAIN_VIDEO_TYPE_VIRTIO; - } else { - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_CIRRUS_VGA)) - return VIR_DOMAIN_VIDEO_TYPE_CIRRUS; - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VGA)) - return VIR_DOMAIN_VIDEO_TYPE_VGA; - return VIR_DOMAIN_VIDEO_TYPE_DEFAULT; - } + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_CIRRUS_VGA)) + return VIR_DOMAIN_VIDEO_TYPE_CIRRUS; + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VGA)) + return VIR_DOMAIN_VIDEO_TYPE_VGA; + return VIR_DOMAIN_VIDEO_TYPE_DEFAULT; } =20 =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list