From nobody Mon Feb 9 05:01:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1616089233; cv=none; d=zohomail.com; s=zohoarc; b=Z0YwZhGNuyIP/bc1n3WHJYaRwpYI4yoMpQa6vdi9V7TWdctKK4n53IVSY2nDvjMDO0nlAT3ZQq1vY23TD92beyDdVD/c90D6ffymhe0xy6qvgCXs+dvwBRKA9SSrqBDuD8YDmko+msshtvocLOBy0urlbbvsMnw6HHD6QNLLK3M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616089233; 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=Y0EnLGI4pApgIK5pgjLLya05tFgXMRnvTUaZXHbUeRw=; b=lmx21yDFpIxv+LIpHZyaP+0AztY7VP7nIIJUMT5xY52CT7+3NP/723AAd5W63fCtP2OdmE4HbN8pYmVs1b8PGESzxBPuGCc9i9MPsi4SRbEVxZV/P8wX4D3EVkCaJuH+23GKyOsCtlxMfmEvZSC5WUFxFVxY/PXn06TqksdzEdU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1616089233307288.9548453529384; Thu, 18 Mar 2021 10:40:33 -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-571-K48yxkYeNDC2E3dz5B7wNA-1; Thu, 18 Mar 2021 13:40:30 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1E9E083DD20; Thu, 18 Mar 2021 17:40:23 +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 E8F4150DD0; Thu, 18 Mar 2021 17:40:22 +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 7F36D4A7C9; Thu, 18 Mar 2021 17:40:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12IHeJg3011146 for ; Thu, 18 Mar 2021 13:40:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id A9B0837DD; Thu, 18 Mar 2021 17:40:19 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 16764610F1 for ; Thu, 18 Mar 2021 17:40:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616089232; 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=Y0EnLGI4pApgIK5pgjLLya05tFgXMRnvTUaZXHbUeRw=; b=Rqbn9dIfYTq2S4nFi5Ks04BtLZrE4RmY9PZC+yk1+5UCdGJNo/NQbgNJdJylY1/gxQR+yg CZPdNa9z7/F1EHl0fGtHFVBPEfrShVxYqdTXakrHYU0g6LWvTHlJPLM6k4RXsbRVNNtyL1 UebUPTGNvxWRk5ordL1PnWIoFubdkvI= X-MC-Unique: K48yxkYeNDC2E3dz5B7wNA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/3] qemuMonitorJSONGetStatus: Refactor cleanup Date: Thu, 18 Mar 2021 18:40:11 +0100 Message-Id: <8f5692f6f796f24cccc58201c52d0c628abafb6c.1616089186.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.11 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" Use g_autofree for the JSON values to remove cleanup label and ret variable. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_monitor_json.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index b669630bc8..e62adcb5b5 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -1729,10 +1729,9 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon, bool *running, virDomainPausedReason *reason) { - int ret =3D -1; const char *status; - virJSONValuePtr cmd; - virJSONValuePtr reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValuePtr data; if (reason) @@ -1742,17 +1741,17 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon, return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) - goto cleanup; + return -1; data =3D virJSONValueObjectGetObject(reply, "return"); if (virJSONValueObjectGetBoolean(data, "running", running) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("query-status reply was missing running state")); - goto cleanup; + return -1; } if ((status =3D virJSONValueObjectGetString(data, "status"))) { @@ -1762,12 +1761,7 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon, VIR_DEBUG("query-status reply was missing status details"); } - ret =3D 0; - - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; + return 0; } --=20 2.29.2