From nobody Mon Feb 9 11:34:28 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=1623752870; cv=none; d=zohomail.com; s=zohoarc; b=arLfNu+tQpXfUbHnyM7y0kARtJjzUgdItJSgKpnoclIwH+tDh/zkj8k45fE2a4ZiGhhPLury1tE903g+yxpqKtYfAWgfYe91AsUWq18kjOoZXNNordu7b92NpmyWeZdqOPZu2cVARPIjBX4UwJDHKtiIzuTExjaBrlTQyWLcWH0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623752870; 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=sa6FVMG5CheexXIn/dw1K6SlgYKBdpU6pBHE/Q6CJL0=; b=fCio4Ibmeuw5spqfKJP0RdsGT3ix2yzGPl+gD1m5OYY4PJs3qIcsG9jDcmjcJmVwUADGxlKigQlYk6SAhAZ9JwIrR6Zl3b58g0rg/DnBTJU6qPU9Ae7BFZ03Q5tS7GnwfXsHngpX5KxJwBr3PTk/VtUqhNp2fprnjuqufgUSwq0= 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 16237528704422.242363672351644; Tue, 15 Jun 2021 03:27:50 -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-479-Ecx6KqJ4N46ho1l0OzJiiw-1; Tue, 15 Jun 2021 06:27:48 -0400 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 DFF641084F4B; Tue, 15 Jun 2021 10:27:41 +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 B92B81000358; Tue, 15 Jun 2021 10:27:41 +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 75F841806D0C; Tue, 15 Jun 2021 10:27:41 +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 15FARafZ019654 for ; Tue, 15 Jun 2021 06:27:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 935C7189BB; Tue, 15 Jun 2021 10:27:36 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED2A3620DE for ; Tue, 15 Jun 2021 10:27:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623752869; 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=sa6FVMG5CheexXIn/dw1K6SlgYKBdpU6pBHE/Q6CJL0=; b=Ec6fUDxslO1TheBg67R9ii3CCi3I3fy580se877oTtMXR7kJaFYKUh2WjkwL7mQIYuTIoN Cx6+SmkaKfQaXfB+MuxiD31TbPVTxnN8dTs5Xf6Y6qhouFUv8caBMu62dlvJpwPP3Z76l+ 7TSNHfxb3yR1Pe7GcxUjphzT6FLuBWA= X-MC-Unique: Ecx6KqJ4N46ho1l0OzJiiw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/13] qemuMonitorJSONGetStringArray: Refactor cleanup Date: Tue, 15 Jun 2021 12:27:18 +0200 Message-Id: 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.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) Content-Type: text/plain; charset="utf-8" Use automatic memory clearing to simplify the control flow. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor_json.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 683b389670..c25e282d51 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -7201,12 +7201,12 @@ qemuMonitorJSONBlockExportAdd(qemuMonitor *mon, static int -qemuMonitorJSONGetStringArray(qemuMonitor *mon, const char *qmpCmd, +qemuMonitorJSONGetStringArray(qemuMonitor *mon, + const char *qmpCmd, char ***array) { - int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; *array =3D NULL; @@ -7214,25 +7214,18 @@ qemuMonitorJSONGetStringArray(qemuMonitor *mon, con= st char *qmpCmd, return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; - if (qemuMonitorJSONHasError(reply, "CommandNotFound")) { - ret =3D 0; - goto cleanup; - } + if (qemuMonitorJSONHasError(reply, "CommandNotFound")) + return 0; if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) - goto cleanup; + return -1; if (!(*array =3D virJSONValueObjectGetStringArray(reply, "return"))) - goto cleanup; - - ret =3D g_strv_length(*array); + return -1; - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; + return g_strv_length(*array); } int qemuMonitorJSONGetTPMModels(qemuMonitor *mon, --=20 2.31.1