From nobody Mon Feb 9 10:57:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1569514435; cv=none; d=zoho.com; s=zohoarc; b=lIQJ4EITSaHWe3yS4Kf4iVmREk1doa47rbi30F8WQMYw1btF1NsejSpgxJj9SSAdwRqvTWGkWpGg7BIwJyf1ZDHfY8MChTnNVXffWbjw0wSke5FOECso+Am+IkvRa9vPNX2AdPfxIIdvl0KzzZdpKvgv7O2oFZCLjzaxPlJrShU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569514435; 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:ARC-Authentication-Results; bh=LHjj08MylIdUXyEfyMpCz08E1S9lAnoaSN9rn7Klono=; b=ZwyN4UJ/8+SNcM3nJ1/zLeiYG/A0BzgE/FGM0eNjCxfvaMflFtUwJ2o+zwrw/89lB486qL/tgD9eITxPoUObKuZPs3DbYSA0IP6/ZPJojHHojpefC9IKk5ZoapSpxnoyn7FlPQNYF+d6QZszdepM2xg5+bvT+QcZsIM9J3iHiDs= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1569514435477831.8051577335099; Thu, 26 Sep 2019 09:13:55 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B3F1B316D791; Thu, 26 Sep 2019 16:13:53 +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 8EE4161F40; Thu, 26 Sep 2019 16:13:53 +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 4D988180B761; Thu, 26 Sep 2019 16:13:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8QGDnGc003299 for ; Thu, 26 Sep 2019 12:13:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6F9B05D9DC; Thu, 26 Sep 2019 16:13:49 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC11D5D9D5 for ; Thu, 26 Sep 2019 16:13:44 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 26 Sep 2019 18:12:04 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 08/39] qemu_domain: Drop few useless checks in qemuDomainGetHostdevPath 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 26 Sep 2019 16:13:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" There are three cases where vir*DeviceGetPath() returns a const string. In these cases, the string is initialized in corresponding vir*DeviceNew() calls which fail if string couldn't be allocated. There's no point in checking the second time if the string is NULL. Signed-off-by: Michal Privoznik Reviewed-by: Cole Robinson --- src/qemu/qemu_domain.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 02b6e590cd..ca6de24e68 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -12915,8 +12915,7 @@ qemuDomainGetHostdevPath(virDomainDefPtr def, if (!usb) goto cleanup; =20 - if (!(tmpPath =3D (char *)virUSBDeviceGetPath(usb))) - goto cleanup; + tmpPath =3D (char *)virUSBDeviceGetPath(usb); perm =3D VIR_CGROUP_DEVICE_RW; break; =20 @@ -12937,8 +12936,7 @@ qemuDomainGetHostdevPath(virDomainDefPtr def, if (!scsi) goto cleanup; =20 - if (!(tmpPath =3D (char *)virSCSIDeviceGetPath(scsi))) - goto cleanup; + tmpPath =3D (char *)virSCSIDeviceGetPath(scsi); perm =3D virSCSIDeviceGetReadonly(scsi) ? VIR_CGROUP_DEVICE_READ : VIR_CGROUP_DEVICE_RW; } @@ -12950,8 +12948,7 @@ qemuDomainGetHostdevPath(virDomainDefPtr def, if (!(host =3D virSCSIVHostDeviceNew(hostsrc->wwpn))) goto cleanup; =20 - if (!(tmpPath =3D (char *)virSCSIVHostDeviceGetPath(host))) - goto cleanup; + tmpPath =3D (char *)virSCSIVHostDeviceGetPath(host); perm =3D VIR_CGROUP_DEVICE_RW; } break; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list