From nobody Mon Feb 9 00:06:58 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=1628780226; cv=none; d=zohomail.com; s=zohoarc; b=lz2/dG2uw9iwR/9BA8X/IK+msYojBEHav5ovxcJItOLwLig+rQJr4dR9rpdO/AYU//bCzje1glhPwFkR3CIIzq6SOaDulbcudwvLUIfN3+PnobTubdRW8ez66lUs5cG7KTg/94iZ2vr0krX+TWl/Q4qWAe/8DdTDdTb/cbGuzrg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628780226; 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=LC1YdmeAf8fK+Bq4hcEFL6bWoxfop5odewTyO2DA3/s=; b=EEAqhU027RIXSJIAdMJ4x6c8GljhHWxHFjdhluSkfdG2/HNIAKVV8O+3eMBbvU11tETWRZXyNApnF3JN/mkN871sYtT1fex5PAhXkZn5PxkECacdydgC9lDQGZpfBdUydgyyXFbWR5rhZtSOHJj0I4HbvRsApTYRXlRXH3GzfE0= 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 1628780226236115.83911036102086; Thu, 12 Aug 2021 07:57: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-31-hNBtZhZXObukw5kAkrtC4g-1; Thu, 12 Aug 2021 10:56:37 -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 F0F0818C89C4; Thu, 12 Aug 2021 14:56:31 +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 CD07D10631F7; Thu, 12 Aug 2021 14:56:31 +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 99F25181A3F5; Thu, 12 Aug 2021 14:56:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17CEnYbb008500 for ; Thu, 12 Aug 2021 10:49:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 95A7319D9F; Thu, 12 Aug 2021 14:49:34 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id EFB9519C44 for ; Thu, 12 Aug 2021 14:49:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628780225; 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=LC1YdmeAf8fK+Bq4hcEFL6bWoxfop5odewTyO2DA3/s=; b=eAHyD3kweE1LrLqBEVsvdmXg28hQR1fJOlVGtir0zDK6lru4iTX4Z3OhVbQ1SVn+qwGQc0 CeF9m9vG+/9VshqLefOl4BRiOb1FADnhR1j1fObJTg92Iprz39IYozr7gGLZVH/FFX5otJ e2VOJabcP/j5Ax5PSReIiwzuoErB/uw= X-MC-Unique: hNBtZhZXObukw5kAkrtC4g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/22] qemuMonitorJSONSetBlockIoThrottle: Refactor cleanup Date: Thu, 12 Aug 2021 16:49:05 +0200 Message-Id: <1cdf8f639f39a8fdf2c5b2dca85fd31a7a20d223.1628778754.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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) X-ZM-MESSAGEID: 1628780226827100001 Content-Type: text/plain; charset="utf-8" Switch to automatic memory freeing and remove the cleanup section. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor_json.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 14dca96afc..9931313baa 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5428,10 +5428,9 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitor *m= on, bool supportGroupNameOption, bool supportMaxLengthOptions) { - int ret =3D -1; - virJSONValue *cmd =3D NULL; - virJSONValue *result =3D NULL; - virJSONValue *args =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) result =3D NULL; + g_autoptr(virJSONValue) args =3D NULL; const char *errdev =3D drivealias; if (!errdev) @@ -5450,7 +5449,7 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitor *mo= n, "U:iops_rd", info->read_iops_sec, "U:iops_wr", info->write_iops_sec, NULL) < 0) - goto cleanup; + return -1; if (supportMaxOptions && virJSONValueObjectAdd(args, @@ -5462,13 +5461,13 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitor *= mon, "U:iops_wr_max", info->write_iops_sec_max, "U:iops_size", info->size_iops_sec, NULL) < 0) - goto cleanup; + return -1; if (supportGroupNameOption && virJSONValueObjectAdd(args, "S:group", info->group_name, NULL) < 0) - goto cleanup; + return -1; if (supportMaxLengthOptions && virJSONValueObjectAdd(args, @@ -5485,13 +5484,13 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitor *= mon, "P:iops_wr_max_length", info->write_iops_sec_max_length, NULL) < 0) - goto cleanup; + return -1; if (virJSONValueObjectAppend(cmd, "arguments", &args) < 0) - goto cleanup; + return -1; if (qemuMonitorJSONCommand(mon, cmd, &result) < 0) - goto cleanup; + return -1; if (virJSONValueObjectHasKey(result, "error")) { if (qemuMonitorJSONHasError(result, "DeviceNotActive")) { @@ -5507,15 +5506,10 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitor *= mon, qemuMonitorJSONCommandName(cmd), qemuMonitorJSONStringifyError(error)); } - goto cleanup; + return -1; } - ret =3D 0; - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(result); - virJSONValueFree(args); - return ret; + return 0; } int qemuMonitorJSONGetBlockIoThrottle(qemuMonitor *mon, --=20 2.31.1