From nobody Sat May 11 20:12:04 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1698848606769505.6802698574983; Wed, 1 Nov 2023 07:23:26 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4069217D5; Wed, 1 Nov 2023 10:23:25 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id D9F1B17B6; Wed, 1 Nov 2023 10:22:21 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 2170B17B6; Wed, 1 Nov 2023 10:22:19 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id A06B717AD for ; Wed, 1 Nov 2023 10:22:18 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-575-pRCxfH-wPR6YYtGoY2F9Bg-1; Wed, 01 Nov 2023 10:22:16 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7D176810FC7 for ; Wed, 1 Nov 2023 14:22:16 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.225.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id 270CA2026D4C for ; Wed, 1 Nov 2023 14:22:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: pRCxfH-wPR6YYtGoY2F9Bg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: devel@lists.libvirt.org Subject: [libvirt PATCH] conf: virDomainDiskSourceFormat: check for srcpool presence correctly Date: Wed, 1 Nov 2023 15:22:12 +0100 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: BSEBZAKZWIXLVM3WFE7ZK2VFR2H25QCD X-Message-ID-Hash: BSEBZAKZWIXLVM3WFE7ZK2VFR2H25QCD X-MailFrom: jtomko@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZM-MESSAGEID: 1698848607999100001 Content-Type: text/plain; charset="utf-8" As a guard against programming errors, one part of the condition only dereferences srcpool if it exists, other one does not. Move the check up one level so that it actually has a chance to do something useful. Fixes: 19b1c0d31988a3a10c4694c10c27eb15c018f450 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Andrea Bolognani --- src/conf/domain_conf.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 80f467ae7a..99f9d56f07 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -22357,14 +22357,12 @@ virDomainDiskSourceFormat(virBuffer *buf, g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); =20 - if (src->type =3D=3D VIR_STORAGE_TYPE_VOLUME) { - if (src->srcpool) { - virBufferEscapeString(&attrBuf, " pool=3D'%s'", src->srcpool->= pool); - virBufferEscapeString(&attrBuf, " volume=3D'%s'", src->srcpool= ->volume); - if (src->srcpool->mode) - virBufferAsprintf(&attrBuf, " mode=3D'%s'", - virStorageSourcePoolModeTypeToString(src= ->srcpool->mode)); - } + if (src->type =3D=3D VIR_STORAGE_TYPE_VOLUME && src->srcpool) { + virBufferEscapeString(&attrBuf, " pool=3D'%s'", src->srcpool->pool= ); + virBufferEscapeString(&attrBuf, " volume=3D'%s'", src->srcpool->vo= lume); + if (src->srcpool->mode) + virBufferAsprintf(&attrBuf, " mode=3D'%s'", + virStorageSourcePoolModeTypeToString(src->sr= cpool->mode)); =20 if (flags & VIR_DOMAIN_DEF_FORMAT_VOLUME_TRANSLATED && src->srcpool->actualtype !=3D VIR_STORAGE_TYPE_NONE) { --=20 2.41.0