From nobody Thu Apr 25 14:46:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1641542452; cv=none; d=zohomail.com; s=zohoarc; b=ZrWTmtX79wynkFw7RANN6SQrj6fUsuz+lCAyJ+WTtKkybb074Uh6MsPwUWLLXr9PZjG3+t+B6/tFM9tq1yMwUbnD0XNWPcKQo5qwJJbpRufT2yxz9pqlj58UrTb+O1heV9toiNaqyRTo8NaQaWTWtNHfaudTzRlgoq4ZAKU+gUA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641542452; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=9RLiNx6u1UTyJkyAJNZaSOMNbcWkCiXeOjWe/UJVJu8=; b=a4cVURfIUTWEtKgKjGf1Gze+DAUwHXhoZPowQZZQCQPj6Q9mDcYVBgVNVUkdaUCubZK4OWKtGYKJV6TasbCCF+ye0E7oRvOT9arWDz/mMnTXUDE9nmSGAkj/LEAwKn4zNvoczMBEho9Ikh3uL+LszKRUjnP/Bc0AQYTq8UnxuoE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1641542452026267.16870991027974; Fri, 7 Jan 2022 00:00:52 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-442-XYF9_YDEOKCh7Vuljv2cDg-1; Fri, 07 Jan 2022 03:00:42 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 948BA36393; Fri, 7 Jan 2022 08:00:37 +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 485727316D; Fri, 7 Jan 2022 08:00: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 2C64E4BB7C; Fri, 7 Jan 2022 08:00:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 2077wLkp032024 for ; Fri, 7 Jan 2022 02:58:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id E1DC76E213; Fri, 7 Jan 2022 07:58:21 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.205]) by smtp.corp.redhat.com (Postfix) with ESMTP id 65CB36E20E for ; Fri, 7 Jan 2022 07:58:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641542451; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=9RLiNx6u1UTyJkyAJNZaSOMNbcWkCiXeOjWe/UJVJu8=; b=hQmOPQu089GPRLrHAJOiTh1P/uLy79k/6nk/MRHZbm2PdR8F9HoGrzrdB27t2xQxrfRA2k iaf2LGyFT5LXrWtTNUDvFYLxikNJyvT9KHnOpi4c40xFbMc/qG4nwFnlOqzZsG/qyx/hcZ jpipXioXxcsI5ahJqvBmPIMaC9xhi2s= X-MC-Unique: XYF9_YDEOKCh7Vuljv2cDg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] src: Don't check for retval of some glib functions Date: Fri, 7 Jan 2022 08:58:18 +0100 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.13 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) X-ZM-MESSAGEID: 1641542453181100001 Content-Type: text/plain; charset="utf-8" There are a few glib functions that abort on OOM and thus there's no point in checking their retval against NULL. Nevertheless, we do have those checks in a few places. Remove them. Generated using the following spatch: @@ expression x; identifier n; expression r; @@ ( x =3D g_strdup_printf(...); | x =3D g_strdup_vprintf(...); | x =3D g_strdup(...); | x =3D g_strndup(...); | x =3D g_new0(...); | x =3D g_realloc(...); ) ... when !=3D x - if(!x) ( - return r; | - goto n; ) Signed-off-by: Michal Privoznik --- src/hyperv/hyperv_driver.c | 14 -------------- src/util/virprocess.c | 2 -- 2 files changed, 16 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 3327f0132e..7b684e04ba 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -482,8 +482,6 @@ hypervDomainAddVirtualDiskParent(virDomainPtr domain, parent__PATH =3D g_strdup_printf("\\\\%s\\Root\\Virtualization\\V2:" "Msvm_ResourceAllocationSettingData.Ins= tanceID=3D\"%s\"", hostname, parentInstanceIDEscaped); - if (!parent__PATH) - return -1; =20 if (hypervSetEmbeddedProperty(controllerResource, "Parent", parent__PA= TH) < 0) return -1; @@ -529,9 +527,6 @@ hypervDomainAddVirtualHardDisk(virDomainPtr domain, "Msvm_ResourceAllocationSettingData.Instan= ceID=3D\"%s\"", hostname, vhdInstanceIdEscaped); =20 - if (!vhd__PATH) - return -1; - if (hypervSetEmbeddedProperty(volumeResource, "Parent", vhd__PATH) < 0) return -1; =20 @@ -660,8 +655,6 @@ hypervDomainAttachPhysicalDisk(virDomainPtr domain, controller__PATH =3D g_strdup_printf("\\\\%s\\Root\\Virtualization\\V2= :" "Msvm_ResourceAllocationSettingData= .InstanceID=3D\"%s\"", hostname, controllerInstanceIdEscap= ed); - if (!controller__PATH) - return -1; =20 if (hypervSetEmbeddedProperty(diskResource, "Parent", controller__PATH= ) < 0) return -1; @@ -711,8 +704,6 @@ hypervDomainAddOpticalDrive(virDomainPtr domain, parent__PATH =3D g_strdup_printf("\\\\%s\\Root\\Virtualization\\V2:" "Msvm_ResourceAllocationSettingData.Ins= tanceID=3D\"%s\"", hostname, parentInstanceIDEscaped); - if (!parent__PATH) - return -1; =20 if (hypervSetEmbeddedProperty(driveResource, "Parent", parent__PATH) <= 0) return -1; @@ -756,8 +747,6 @@ hypervDomainAddOpticalDisk(virDomainPtr domain, vhd__PATH =3D g_strdup_printf("\\\\%s\\Root\\Virtualization\\V2:" "Msvm_ResourceAllocationSettingData.Instan= ceID=3D\"%s\"", hostname, vhdInstanceIdEscaped); - if (!vhd__PATH) - return -1; =20 if (hypervSetEmbeddedProperty(volumeResource, "Parent", vhd__PATH) < 0) return -1; @@ -829,9 +818,6 @@ hypervDomainAttachFloppy(virDomainPtr domain, "Msvm_ResourceAllocationSettingData.Instan= ceID=3D\"%s\"", hostname, vhdInstanceIdEscaped); =20 - if (!vfd__PATH) - return -1; - if (hypervSetEmbeddedProperty(volumeResource, "Parent", vfd__PATH) < 0) return -1; =20 diff --git a/src/util/virprocess.c b/src/util/virprocess.c index c74bd16fe6..66b20b0a33 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -1826,8 +1826,6 @@ virProcessGetSchedInfo(unsigned long long *cpuWait, proc =3D g_strdup_printf("/proc/%d/task/%d/sched", (int) pid, (int= ) tid); else proc =3D g_strdup_printf("/proc/%d/sched", (int) pid); - if (!proc) - return -1; =20 /* The file is not guaranteed to exist (needs CONFIG_SCHED_DEBUG) */ if (access(proc, R_OK) < 0) { --=20 2.34.1