From nobody Tue Feb 10 10:59:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1613152643; cv=none; d=zohomail.com; s=zohoarc; b=nDRBpej0chg6vOSnuPSQEW0iVcQTdPcecaNPd68G0T9DPZeuiHB6U3IH79YEN1S3ogkw0HIch6nVFbiTM8zAARYw7OZhsRTexhxeq8hh6bxUYyvqpJGS03U+wfszfEpCifKl+r5HN63BFA7o28o0UdQFMMnRtkpWIy1URnBHQVQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613152643; 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=hLHdoxAEM4AtSNtad8eOgq+LHERsjSOKksebvGAp+xE=; b=RbAgUlfdY1IVmdRGhLqai9RysXB9rzV11fenHONBPx1+3rlMVTuhcu6iWZcqyeKXU1fxmxm4jawL069wDVNvDNf9Ln5JXM/EqePrsVa5wXRAXRNNt7d2l35FIY3ne7cv+SIITbo4n0sKupyKsDncTCyPknI5reiRjrh50aHE5G8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1613152643561779.2985105942583; Fri, 12 Feb 2021 09:57:23 -0800 (PST) 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-548-ku9JChpTPQ697ULOEU82xQ-1; Fri, 12 Feb 2021 12:57:15 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8F2AE81473C; Fri, 12 Feb 2021 17:56: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 655565D9FC; Fri, 12 Feb 2021 17:56: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 2A5A757DFD; Fri, 12 Feb 2021 17:56:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11CHuY0f010849 for ; Fri, 12 Feb 2021 12:56:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id B8EF47DA4D; Fri, 12 Feb 2021 17:56:33 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id E375A76606 for ; Fri, 12 Feb 2021 17:56:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613152639; 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=hLHdoxAEM4AtSNtad8eOgq+LHERsjSOKksebvGAp+xE=; b=PiZ9t7EOSScbDKZPb8HYcVI9aDi3Eny7m50ypdxLeT09yS2RhiRDwNrFrnNFuLCeaVgv9Y 7ZPCDKCgxSD/+xNBmGi4b/UtOeO4EAApkwSZjJ4ufCmlj+FxscnzeHoUfH/VRu4iHHA6d9 we2rYLhHdGlnrPeRpWzdIH9DGeQqnNg= X-MC-Unique: ku9JChpTPQ697ULOEU82xQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/25] qemuAgentMakeCommand: Refactor memory cleanup Date: Fri, 12 Feb 2021 18:55:23 +0100 Message-Id: <4c324e1b1f6602f34c7c78cab7bac8bef732e539.1613152441.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.14 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) Content-Type: text/plain; charset="utf-8" Switch to using the 'g_auto*' helpers. Signed-off-by: Peter Krempa --- src/qemu/qemu_agent.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 51cc00c618..4712aeb529 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1149,31 +1149,26 @@ static virJSONValuePtr G_GNUC_NULL_TERMINATED qemuAgentMakeCommand(const char *cmdname, ...) { - virJSONValuePtr obj =3D virJSONValueNewObject(); - virJSONValuePtr jargs =3D NULL; + g_autoptr(virJSONValue) obj =3D NULL; + g_autoptr(virJSONValue) jargs =3D NULL; va_list args; va_start(args, cmdname); - if (virJSONValueObjectAppendString(obj, "execute", cmdname) < 0) - goto error; - - if (virJSONValueObjectCreateVArgs(&jargs, args) < 0) - goto error; - - if (jargs && - virJSONValueObjectAppend(obj, "arguments", jargs) < 0) - goto error; + if (virJSONValueObjectCreateVArgs(&jargs, args) < 0) { + va_end(args); + return NULL; + } va_end(args); - return obj; + if (virJSONValueObjectCreate(&obj, + "s:execute", cmdname, + "A:arguments", &jargs, + NULL) < 0) + return NULL; - error: - virJSONValueFree(obj); - virJSONValueFree(jargs); - va_end(args); - return NULL; + return g_steal_pointer(&obj); } static virJSONValuePtr --=20 2.29.2