From nobody Sun Feb 8 14:30:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1635159486; cv=none; d=zohomail.com; s=zohoarc; b=WIsE0sYH74b3BbTIw6rLd2sLfAl5/sxZlhi/9c0Ld3/+4joE1qPjnmFX/LHzNd2Go6ur2+f8JZ8axY9HT4y6BXxucxolOdKsW3tzlPWVz/Nzz/GBKeKC6UPK4VR6lvmtSf+FT/90wO4mMDm4BLfCKGFiD1p2TuC/OcEh0oPXxto= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635159486; 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=+BoHxrc5+2CDQFsNHe0bzj/42+tbUSetdoxTyECFJGo=; b=Jo6EyppzbfWCPRXJ0Xqvbxj4hwU+3X+MoGtzeqfCxdg2qXrsDsoKpPR83rzppEBJJtFCWIY5diazW6g6MRO3WukF15JMzsGa9sFnERhcapxImiAQrzf8SjQqZhbFirl4rclyDt7WihpP+kx6ZvHgXB4IIGRAYp8ZS0wJMYMZjvU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1635159486752624.6132180084618; Mon, 25 Oct 2021 03:58:06 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-107-gp-JDWnVMk6CJj6JK15MHw-1; Mon, 25 Oct 2021 06:58:01 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C73DE1014514; Mon, 25 Oct 2021 10:57:56 +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 A489819724; Mon, 25 Oct 2021 10:57:56 +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 6AB981832DD5; Mon, 25 Oct 2021 10:57:56 +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 19PAvqH0016868 for ; Mon, 25 Oct 2021 06:57:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id CDFE4ADCD; Mon, 25 Oct 2021 10:57:52 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 560545DAA5 for ; Mon, 25 Oct 2021 10:57:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635159483; 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=+BoHxrc5+2CDQFsNHe0bzj/42+tbUSetdoxTyECFJGo=; b=awRyhbv92ep9iFFBNuZ6gxW5atVxGAX741nExVqcE3qKwFSpPkurGHKC/qKbg7bFjWqGFm J0dC7Ovdb1Rtmf0/EskFNHuZ/jDjorSv+zWwLd3rSko1o5w9YzTZCmitMK3LPwMEYsHFAT qtGDFDujWpRyWS2YoALIf79WfRRPQaY= X-MC-Unique: gp-JDWnVMk6CJj6JK15MHw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 05/13] qemuMonitorJSONQueryRxFilterParse: Set *filter only on success Date: Mon, 25 Oct 2021 12:57:29 +0200 Message-Id: <8bff82ce053f4b1c747fee32f9502e3632bd413d.1635159386.git.mprivozn@redhat.com> 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 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.23 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: 1635159487715100001 Content-Type: text/plain; charset="utf-8" The qemuMonitorJSONQueryRxFilterParse() function is called to parse the output of 'query-rx-filter' and store results into passed virNetDevRxFilter structure. However, it is doing so in a bit clumsy way - the return pointer is set in all cases (i.e. even in case of error) and thus the cleanup label is more complicated than it needs to be. With a help of g_autoptr() and g_steal_pointer() the return pointer can be set only in case of success - which is what callers expect anyway. The same applies to qemuMonitorJSONQueryRxFilter(). Signed-off-by: Michal Privoznik --- src/qemu/qemu_monitor_json.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index bcbb4e59ab..26cbb8cedc 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4035,7 +4035,7 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg, virJSONValue *element; size_t nTable; size_t i; - virNetDevRxFilter *fil =3D virNetDevRxFilterNew(); + g_autoptr(virNetDevRxFilter) fil =3D virNetDevRxFilterNew(); =20 if (!fil) goto cleanup; @@ -4187,13 +4187,9 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg, } fil->vlan.nTable =3D nTable; =20 + *filter =3D g_steal_pointer(&fil); ret =3D 0; cleanup: - if (ret < 0) { - virNetDevRxFilterFree(fil); - fil =3D NULL; - } - *filter =3D fil; return ret; } =20 @@ -4222,10 +4218,6 @@ qemuMonitorJSONQueryRxFilter(qemuMonitor *mon, const= char *alias, =20 ret =3D 0; cleanup: - if (ret < 0) { - virNetDevRxFilterFree(*filter); - *filter =3D NULL; - } virJSONValueFree(cmd); virJSONValueFree(reply); return ret; --=20 2.32.0