From nobody Tue Feb 10 01:59:49 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=1649775490; cv=none; d=zohomail.com; s=zohoarc; b=EMeGVdJ8ZSqlG/pyO1vhTLNJpISdgJSru9XUET5NL1wmw3AjcyVYCl47JpdIzVom4KVNySoWdS1tND8gQcezSwKlhb3c348sIbBw5I0R1hq3fO8GqW/TPbssOBZx0xI4PK7sr3AksU2a9KaoVl2ldEPiPy3PNkPXlQiup5P8Ui4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649775490; h=Content-Type:Content-Transfer-Encoding:Cc: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=Q/naSVd8di90dWGEDbMAJq+whWbWipu6da/v9LLB1Zk=; b=MWsZcBpggrzNU3iGjsB0U/F0YNvmZFCRDxoa0yYf4f1z7rMnrPhYpfke3s3yJJj01ynTtf35l5k7U+aqIPF1OF2+IOtVSIhQiDzX2uTALkB3HHUACtPiUoU593SaCMRXm1BnD0AxBGjTdKRt7ymJo4RWrPxCofrHX1xDUUNPytg= 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 1649775490006360.0034376813454; Tue, 12 Apr 2022 07:58:10 -0700 (PDT) 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-508-b4xHJXicPc2wWQPUaTtSYg-1; Tue, 12 Apr 2022 10:58:05 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 76CD08853DF; Tue, 12 Apr 2022 14:57:33 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C25A482CFE; Tue, 12 Apr 2022 14:57:33 +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 E9B65194036A; Tue, 12 Apr 2022 14:57:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E300C1940365 for ; Tue, 12 Apr 2022 14:57:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C45BD416378; Tue, 12 Apr 2022 14:57:30 +0000 (UTC) Received: from work.redhat.com (unknown [10.39.194.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43403432036; Tue, 12 Apr 2022 14:57:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649775489; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Q/naSVd8di90dWGEDbMAJq+whWbWipu6da/v9LLB1Zk=; b=VW9VKWR/zEQBtY+4D82FENcP+OmnSWUYIVfxEhfM0oyxwQeuyy84L61wO3GKA90iNAibFN lCdWhptcD2gxtbBvuZidfaAWH5eTuJpnrA/7uoR5J2ftkB0SDJYS0iQLvxo9TtZuaxxt21 uftT5e6NY0KU0qz+rKSNbyOiYR5E8zM= X-MC-Unique: b4xHJXicPc2wWQPUaTtSYg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 02/10] virStoragePoolObjAddVol: Simplify error path Date: Tue, 12 Apr 2022 16:57:19 +0200 Message-Id: <20220412145727.69564-3-twiederh@redhat.com> In-Reply-To: <20220412145727.69564-1-twiederh@redhat.com> References: <20220412145727.69564-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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: , Cc: Tim Wiederhake Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: 1649775491290100004 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Tim Wiederhake --- src/conf/virstorageobj.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 99aee9ffb4..1ecf35640c 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -636,14 +636,18 @@ virStoragePoolObjAddVol(virStoragePoolObj *obj, =20 virObjectRWLockWrite(volumes); =20 - if (!(volobj =3D virStorageVolObjNew())) - goto error; - if (!voldef->key || !voldef->name || !voldef->target.path || g_hash_table_contains(volumes->objsKey, voldef->key) || g_hash_table_contains(volumes->objsName, voldef->name) || - g_hash_table_contains(volumes->objsPath, voldef->target.path)) - goto error; + g_hash_table_contains(volumes->objsPath, voldef->target.path)) { + virObjectRWUnlock(volumes); + return -1; + } + + if (!(volobj =3D virStorageVolObjNew())) { + virObjectRWUnlock(volumes); + return -1; + } =20 g_hash_table_insert(volumes->objsKey, g_strdup(voldef->key), volobj); virObjectRef(volobj); @@ -655,14 +659,10 @@ virStoragePoolObjAddVol(virStoragePoolObj *obj, virObjectRef(volobj); =20 volobj->voldef =3D voldef; - virObjectRWUnlock(volumes); - virStorageVolObjEndAPI(&volobj); - return 0; =20 - error: virStorageVolObjEndAPI(&volobj); virObjectRWUnlock(volumes); - return -1; + return 0; } =20 =20 --=20 2.31.1