From nobody Fri Dec 19 08:07:21 2025 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=1634654769; cv=none; d=zohomail.com; s=zohoarc; b=OLKVAAHxY+1PhgEcOU4KYsMHk3f9YvlcX0EQsSNzFSAlvHYnKOK5rlM3KxD3G90Jd7tJXSgZTvSNIto7LBIkA4Y4z/DDDs38trb9J2KVqUj59I7yP6WPSpxldKkW9Q59pPuTH0rWMmCP4ea9cr78I8UNyAJCpZdOU9mxDJ8U+aY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634654769; 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=nLusOQE1Vz0M79MxEMChn4PK1bLn50rvXJoqp3L+oWY=; b=XleppzpBn/1e/9HsEmxq3BWyxXdldvuC+RI+iv2C9In+CUnhtpzJIM7iTkkhAUJHUvBzymmPRhGyfBx9k6J/tdMWXtxrA/W5C8OeXz3swiw07xLWiYkkppFDdYuSinOpPaMbkLshDd4f7OcJ4awwBsmFvbCPgOV7WlG/IYfL9vg= 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 16346547696891015.5279240621659; Tue, 19 Oct 2021 07:46:09 -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-150-0xognFbjNESYXMZF_Q1s_Q-1; Tue, 19 Oct 2021 10:44:18 -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 7CA8E180831B; Tue, 19 Oct 2021 14:44:13 +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 5C7451017CE7; Tue, 19 Oct 2021 14:44:13 +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 1A4F81832DD5; Tue, 19 Oct 2021 14:44:13 +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 19JEhKak031698 for ; Tue, 19 Oct 2021 10:43:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 42C571972E; Tue, 19 Oct 2021 14:43:20 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9CFAE19C79 for ; Tue, 19 Oct 2021 14:43:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634654768; 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=nLusOQE1Vz0M79MxEMChn4PK1bLn50rvXJoqp3L+oWY=; b=WJSdIn1SwWldvSrzhttqzZw8/J921HDljq7zjW3iI+C9sLznaq1Gq8pzEuCcqfVGxzz62S vHmiHPX74DVoynBTOIVH/fMLXQ1ueOufs+DpbBq/O0yiZJOZftZpji0jEh87EEuKTeeKpK WEKLj2xeaa5oGQQT3H6dYIANO243qt0= X-MC-Unique: 0xognFbjNESYXMZF_Q1s_Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/8] qemuMonitorJSONBlockStatsUpdateCapacity: Refactor cleanup Date: Tue, 19 Oct 2021 16:43:10 +0200 Message-Id: <0f6ceb7b02b3267b1ced83e8fe8111c388643095.1634654476.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: 1634654770441100002 Content-Type: text/plain; charset="utf-8" Use automatic memory clearing for the temporary variable and remove the cleanup section. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor_json.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 579d986e02..af6e918e06 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2660,9 +2660,8 @@ qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitor *= mon, GHashTable *stats, bool backingChain) { - int ret =3D -1; size_t i; - virJSONValue *devices; + g_autoptr(virJSONValue) devices =3D NULL; if (!(devices =3D qemuMonitorJSONQueryBlock(mon))) return -1; @@ -2674,10 +2673,10 @@ qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitor= *mon, const char *dev_name; if (!(dev =3D qemuMonitorJSONGetBlockDev(devices, i))) - goto cleanup; + return -1; if (!(dev_name =3D qemuMonitorJSONGetBlockDevDevice(dev))) - goto cleanup; + return -1; /* drive may be empty */ if (!(inserted =3D virJSONValueObjectGetObject(dev, "inserted")) || @@ -2687,14 +2686,10 @@ qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitor= *mon, if (qemuMonitorJSONBlockStatsUpdateCapacityOne(image, dev_name, 0, stats, backingChain) < 0) - goto cleanup; + return -1; } - ret =3D 0; - - cleanup: - virJSONValueFree(devices); - return ret; + return 0; } --=20 2.31.1