From nobody Mon Feb 9 06:02:29 2026 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=1672936236; cv=none; d=zohomail.com; s=zohoarc; b=X1b4L6EyN4e0HrfgDypG5EW5IRq5Mw3M2+ixwLKeIUWaGHDXZq7EO1y7zfn1KIKXHNkCbZY1YuCmMMkhDq59OvYcla/s3pgv7HwHyvptxR3erjrok3cXBKD/RmnfAdIuhdFaolTT6wPPZo9V9F1110nCRblxlCTqeQ4TUshy4ps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672936236; 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=7GRm8+ho/SZ51cyNMDlzkXhuQ9QV1sZhOsJST8/zitM=; b=Yq+GFLFguoqCzQPdp4yugGuLu0bqlivPhaPO31dqwlTR6aJmoMfcZUbM3c5PKIfH4vEDcUEcutEbJJJHt2mGgBWfZ8WgCXa201xSyfHTaxzZ2xr6ZJxZ6AlBsQWvs0jlmlQf/TKa73iJI8D0dPS5NmyC1AnocT36hdbTc3r+DO8= 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 1672936236580877.9648041316844; Thu, 5 Jan 2023 08:30:36 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-298-NnxLgWSVNUeD8m8INi5JoQ-1; Thu, 05 Jan 2023 11:30:32 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 37693858F0E; Thu, 5 Jan 2023 16:30:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2015539D6D; Thu, 5 Jan 2023 16:30:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DB3B01946589; Thu, 5 Jan 2023 16:30:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AC6E01946586 for ; Thu, 5 Jan 2023 16:30:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 813B72166B31; Thu, 5 Jan 2023 16:30:28 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 958482166B30 for ; Thu, 5 Jan 2023 16:30:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672936235; 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=7GRm8+ho/SZ51cyNMDlzkXhuQ9QV1sZhOsJST8/zitM=; b=PAmOlR4AhDJ8Cg59tAkghTMtPTrthtbt8ZT5cGGXgcPICeBfTN0RqAF2ZuSdLp08CLoTQB hR/fWNv3qn8JQSFQP1pQu+EspMXxVH4rOIPOvIs43EQ9ALHJzjuPLWqkfR0IqgHBx1KrPZ DD4lp+YhOhQxK7QOpP7W4OIuFb0I2Fo= X-MC-Unique: NnxLgWSVNUeD8m8INi5JoQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/36] datatypes: Simplify error path of 'virGetDomain' Date: Thu, 5 Jan 2023 17:29:50 +0100 Message-Id: <093af0a98e645bc3f17b91f38bce57248d4fcd1c.1672935969.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: 1672936237429100001 Content-Type: text/plain; charset="utf-8" 'virObjectNew' can't return NULL. If we pre-check the arguments we don't need a cleanup label. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: Pavel Hrdina --- src/datatypes.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/datatypes.c b/src/datatypes.c index da8a9970f1..c83a74edd5 100644 --- a/src/datatypes.c +++ b/src/datatypes.c @@ -292,13 +292,11 @@ virGetDomain(virConnectPtr conn, if (virDataTypesInitialize() < 0) return NULL; - virCheckConnectGoto(conn, error); - virCheckNonNullArgGoto(name, error); - virCheckNonNullArgGoto(uuid, error); - - if (!(ret =3D virObjectNew(virDomainClass))) - goto error; + virCheckConnectReturn(conn, NULL); + virCheckNonNullArgReturn(name, NULL); + virCheckNonNullArgReturn(uuid, NULL); + ret =3D virObjectNew(virDomainClass); ret->name =3D g_strdup(name); ret->conn =3D virObjectRef(conn); @@ -306,10 +304,6 @@ virGetDomain(virConnectPtr conn, memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN); return ret; - - error: - virObjectUnref(ret); - return NULL; } /** --=20 2.38.1