From nobody Sun Feb 8 23:57: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=1642011088; cv=none; d=zohomail.com; s=zohoarc; b=SLEpW6oY5dS/uE6XlMJjIy6PazaZx0MHVZPILUr1lP3MrI0KH65HYgzQaJBd9UhUqB0Merhx3gdkFYeJviuf9nyVmApnIJLennEAj+M0hd8vbNPwa0FpPK9VLku4YW3yCLZpg7Qg5ohDHjG59BeTN5OzJo3mUoh6gHG58CqoOyM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642011088; 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=Fk/FzvF5pL2uytkA2y7V034+LSZPtWDpARHCHB7ErGk=; b=R6F6wGd6kH4TdPUvWFUqETSOnpANkvbgUAM3A+GsOnOfrzdmhON+4f5vKTkeloM3Bdx/TAZ3GZtmXCx0mR9j79oXVIUoBnaFMgBdg4zI8nM2Wxu5wp/XEUyj5y4FfhHjYhMCmSGNZOqqId2Dn/nxBQiNU+JHCdM/zJ2vIy6cMZM= 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 1642011088464546.7207474678534; Wed, 12 Jan 2022 10:11:28 -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-488-9j-tVyDWMj-dADIJsGxSaQ-1; Wed, 12 Jan 2022 13:11:26 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B7872874991; Wed, 12 Jan 2022 18:11:19 +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 9468F105C89D; Wed, 12 Jan 2022 18:11:19 +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 31BA94A7C8; Wed, 12 Jan 2022 18:11:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20CIAUj0002998 for ; Wed, 12 Jan 2022 13:10:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id B42ED8AD01; Wed, 12 Jan 2022 18:10:30 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1ED498AD18 for ; Wed, 12 Jan 2022 18:10:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642011087; 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=Fk/FzvF5pL2uytkA2y7V034+LSZPtWDpARHCHB7ErGk=; b=c7GloUA34p568mEy8XSKkyetnRbljl+oBGIWqLnKqXDtAdmHTeYKa2rFpkO3PgH6KHZTWm sKNKK3kb5elbwDVfUC4pyvpb1dqx2cE4srv5uPXQs9bC4P1xX9xvCF2QmD1Y3mlCqdEnlN kTOodkPsYZ76W2aBqsTIRE9fkQMPPQE= X-MC-Unique: 9j-tVyDWMj-dADIJsGxSaQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/17] virDomainMomentAssignDef: Simplify error handling Date: Wed, 12 Jan 2022 19:10:03 +0100 Message-Id: <4eea5056d110ed9770024359ed74f8bc1bad539c.1642010887.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.84 on 10.5.11.22 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: 1642011088882100001 Content-Type: text/plain; charset="utf-8" Remove error handling from the call to 'virDomainMomentObjNew' as it can't return NULL and replace 'virHashAddEntry' by 'g_hash_table_insert' as we've already checked that snapshot with such name doesn't exist in the hash table. This removes handling for two impossible errors. Signed-off-by: Peter Krempa --- src/conf/virdomainmomentobjlist.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/conf/virdomainmomentobjlist.c b/src/conf/virdomainmomentob= jlist.c index 8993c2310b..2f2467d13f 100644 --- a/src/conf/virdomainmomentobjlist.c +++ b/src/conf/virdomainmomentobjlist.c @@ -245,14 +245,9 @@ virDomainMomentAssignDef(virDomainMomentObjList *momen= ts, return NULL; } - if (!(moment =3D virDomainMomentObjNew())) - return NULL; - - if (virHashAddEntry(moments->objs, def->name, moment) < 0) { - VIR_FREE(moment); - return NULL; - } + moment =3D virDomainMomentObjNew(); moment->def =3D def; + g_hash_table_insert(moments->objs, g_strdup(def->name), moment); return moment; } --=20 2.31.1