From nobody Mon Feb 9 00:55:42 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=1623752866; cv=none; d=zohomail.com; s=zohoarc; b=NVLyWIvj3KDoLH6ZHEeBv4LxPmxp0QpQzHKRCqBl7R2hhRBYXNqpU7cz84GzOz9o8hFp5jIdofdIoGcMkdqkToCUWUDiurEGCFUMi3xZa9ak8W3ABuA421hjKlQXc6YgOShxuIwjtcpdInN4u66DLcNdPTo17JuBohy2ZZDxAHo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623752866; 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=0E9aVY58DoFjs6L1PnnIB7RyVlKzfmvJbDpFARveKZI=; b=XesFF+8yr8C+6Y/Y/eREHQnzBuwYg/uOXztI1vkV/+X4tmGRO2AgwHajTrQSBidzfjUUG6wNHbQeg9ucVW6bS7j7zsP6C3qAvyRNub/m9rHgcewfidvjzPkcyN95K0t11s/RPwBNzfUJNeEjXdrefn+yVufKKjW4W/uCM4HlWKE= 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) 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 1623752866781177.993348396506; Tue, 15 Jun 2021 03:27:46 -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-95-C_YK_4RTNyi5aWbT03U_Ig-1; Tue, 15 Jun 2021 06:27:44 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D43B1801FCD; Tue, 15 Jun 2021 10:27:38 +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 B0FBF5C1C2; Tue, 15 Jun 2021 10:27:38 +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 792DA1809CAD; Tue, 15 Jun 2021 10:27:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15FARZBW019639 for ; Tue, 15 Jun 2021 06:27:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8C47B189CE; Tue, 15 Jun 2021 10:27:35 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id EEF2E189BB for ; Tue, 15 Jun 2021 10:27:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623752865; 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=0E9aVY58DoFjs6L1PnnIB7RyVlKzfmvJbDpFARveKZI=; b=GFl9L+QghSfOMqTGsWchs3X4a/tQLYXCbvQ9MwdXVyIohkDmhLOB230ZtQ3ZU8oEMuh30S DJLYkL0Fz8p5RsY0rLYDPwdNz2cno+YiCZpz0zh0v02WVdFP4JJLzVdNSRKj9zNVeg+tDy Pc4o6GBZh97brCmGwLPACPddTrB1QhI= X-MC-Unique: C_YK_4RTNyi5aWbT03U_Ig-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/13] qemuMonitorJSONGetCommands: Refactor cleanup Date: Tue, 15 Jun 2021 12:27:17 +0200 Message-Id: <65f5d31d5c8b79cb4a14825e3e4ecd7843636cf3.1623752803.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.16 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 automatic memory freeing to simplify the control flow. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor_json.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index f0d67f8f20..683b389670 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -6159,11 +6159,10 @@ qemuMonitorJSONGetCPUModelComparison(qemuMonitor *m= on, int qemuMonitorJSONGetCommands(qemuMonitor *mon, char ***commands) { - int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data; - char **commandlist =3D NULL; + g_auto(GStrv) commandlist =3D NULL; size_t n =3D 0; size_t i; @@ -6173,10 +6172,10 @@ int qemuMonitorJSONGetCommands(qemuMonitor *mon, return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) - goto cleanup; + return -1; data =3D virJSONValueObjectGetArray(reply, "return"); n =3D virJSONValueArraySize(data); @@ -6191,21 +6190,14 @@ int qemuMonitorJSONGetCommands(qemuMonitor *mon, if (!(tmp =3D virJSONValueObjectGetString(child, "name"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("query-commands reply data was missing 'name'= ")); - goto cleanup; + return -1; } commandlist[i] =3D g_strdup(tmp); } - ret =3D n; *commands =3D g_steal_pointer(&commandlist); - - - cleanup: - g_strfreev(commandlist); - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; + return n; } --=20 2.31.1