From nobody Fri May 3 11:16:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1635159481; cv=none; d=zohomail.com; s=zohoarc; b=Exd1AwzsAB1cxXEVZ52FGXREdX649SVWI1D4VaqnVi7PIhPM6h3koZwBjMMAhfihy5pDJqVDzk2+1ybvVenjRtEwwojvpf+0samGGdkbeS6H3GkF5SHcTj4EulsMkuHwXXDML76oHTyyrpcsKLM34J0gPqOPCkHgKdjDDghIcaY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635159481; 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=SU8RHggLLXaGrfgpi64FXiJnrmo25h/qnpgI4xstCyI=; b=nbMu26ofvzjT73SJaOwXW5+z5g3BPmQ0Y9kjEcOpE7UOO/sQrsnwvecpnEkidX43qXMJHYpaxi7sBRS/orQvkOHkTuRmN3GDvzWBMA72CEdOp1KC49ENscc/dXoG9SFyNvVuJRUHMQKxJtdCH3pvgV53/iFQBZ/hF+zwsmM4Tew= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1635159481515692.190422436133; Mon, 25 Oct 2021 03:58:01 -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-510-iS7K9_qZM26ME4qYu65b4A-1; Mon, 25 Oct 2021 06:57:58 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DC340806718; Mon, 25 Oct 2021 10:57:53 +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 B4DEF60CC4; Mon, 25 Oct 2021 10:57:53 +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 724311819AC2; Mon, 25 Oct 2021 10:57:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19PAvnhd016838 for ; Mon, 25 Oct 2021 06:57:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9536C5DAA5; Mon, 25 Oct 2021 10:57:49 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C3325DD68 for ; Mon, 25 Oct 2021 10:57:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635159480; 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=SU8RHggLLXaGrfgpi64FXiJnrmo25h/qnpgI4xstCyI=; b=OLhiPnEr/Prb0JJnvMqXgnawH1pXNj7KsuDQ+VsbCNBLtmHuEcxup7eNSFFv4K9XJh/K5m BkabZ7M1MFqAkbNUV4L91pRW3Cxs9+mY56aOuvHiFkLm4nUU1Y0ESH8yofZZ/ImRJ4IEnJ UPahCKRuCSR0t0XkeRpQqoKxio4+bqg= X-MC-Unique: iS7K9_qZM26ME4qYu65b4A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 01/13] qemu_monitor_json: Don't check for qemuMonitorNextCommandID() retval Date: Mon, 25 Oct 2021 12:57:25 +0200 Message-Id: <019b7d88f465becf29f9e5873acfd6f00a3fa812.1635159386.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.12 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: 1635159483230100001 Content-Type: text/plain; charset="utf-8" The qemuMonitorNextCommandID() function can never fail. There's no need to check for its retval then. Moreover, the temporary variable used to hold the retval can be declared in the inner most block. Signed-off-by: Michal Privoznik Reviewed-by: Tim Wiederhake --- src/qemu/qemu_monitor_json.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index a7a980fccd..dcf9186191 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -302,15 +302,14 @@ qemuMonitorJSONCommandWithFd(qemuMonitor *mon, int ret =3D -1; qemuMonitorMessage msg; g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; - char *id =3D NULL; =20 *reply =3D NULL; =20 memset(&msg, 0, sizeof(msg)); =20 if (virJSONValueObjectHasKey(cmd, "execute") =3D=3D 1) { - if (!(id =3D qemuMonitorNextCommandID(mon))) - goto cleanup; + g_autofree char *id =3D qemuMonitorNextCommandID(mon); + if (virJSONValueObjectAppendString(cmd, "id", id) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unable to append command 'id' string")); @@ -339,7 +338,6 @@ qemuMonitorJSONCommandWithFd(qemuMonitor *mon, } =20 cleanup: - VIR_FREE(id); VIR_FREE(msg.txBuffer); =20 return ret; --=20 2.32.0 From nobody Fri May 3 11:16:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1635159482; cv=none; d=zohomail.com; s=zohoarc; b=VpwN2a6C/VEdceO8YGGbrUPbAFwbHGtEnwDPJ6BCUNi/QtDRybNCqpGFMRZKc/pkKNWNlUzMcevraFBBsUt+V7WWTlY7FGg2A7EZqEPBsCbv2fc5XNMCHhGy7srE8YhGNUtJw053zMPKRVRUndrkjIrg4t469Kwj81emC7AvQ5k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635159482; 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=uj+BUybpTVjAlrm/dVSFSHFFneAsoDa6e/FAQJN1qoA=; b=Qy3wV7DitdZTlSdCQN1sdgZlRju94RIa3dWz/POD4C2SnzW/9VrAUlua+uO0cPorA0xZZFi78nHNLMOB7Y61EElkcKZRKkztYBv1UMCRxrFneXlmoFjFQ9Im5kDNArwl+7LeDK2GxQFWpd7ANhJATGUq03UMHmXTZYv2k/Xr0Uo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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 [170.10.129.124]) by mx.zohomail.com with SMTPS id 1635159482782334.8948734847098; Mon, 25 Oct 2021 03:58:02 -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-143-eaC4RHbxNC-fnb1pbuXnQQ-1; Mon, 25 Oct 2021 06:57:57 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 812CC9F92D; Mon, 25 Oct 2021 10:57:52 +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 6425960862; Mon, 25 Oct 2021 10:57:52 +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 2BDA51801241; Mon, 25 Oct 2021 10:57:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19PAvopK016846 for ; Mon, 25 Oct 2021 06:57:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6641D5DD68; Mon, 25 Oct 2021 10:57:50 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id E23195DAA5 for ; Mon, 25 Oct 2021 10:57:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635159481; 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=uj+BUybpTVjAlrm/dVSFSHFFneAsoDa6e/FAQJN1qoA=; b=OusfX12xTXa136ZtuIuRXIBQQ07/sUOaibpA1SVJsZyYl7qvFZVGO9RPMaKoj9to0z3WWR Bwj+2OG6+Rt9GyyN72mtO6lj/Fj6Sh1CoMrmHIISC/MdOxDnN1OBsT62VONqTzWBrag8Tu nmr9kBm4HtkHRsiyTiS2fy9m03EyUbQ= X-MC-Unique: eaC4RHbxNC-fnb1pbuXnQQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 02/13] qemu_monitor_json: Don't transfer ownership to @msg Date: Mon, 25 Oct 2021 12:57:26 +0200 Message-Id: <0ec5f072e9c444fb57b190576ba8d1e752951ebe.1635159386.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.13 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: 1635160384268100001 Content-Type: text/plain; charset="utf-8" In qemuMonitorJSONCommandWithFd() given command (represented by virJSONValue struct) is translated to string (represented by virBuffer). The ownership of the string is then transferred to the message which is then sent. The downside of this approach is we have to have an explicit call to free the string from the message. But if the message just "borrowed" the string (which it can safely do because it is just reading from the string) then automatic free of the buffer takes care of freeing the string. Signed-off-by: Michal Privoznik Reviewed-by: Tim Wiederhake --- src/qemu/qemu_monitor.c | 2 +- src/qemu/qemu_monitor.h | 2 +- src/qemu/qemu_monitor_json.c | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 81d9087839..908ee0d302 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -420,7 +420,7 @@ static int qemuMonitorIOWrite(qemuMonitor *mon) { int done; - char *buf; + const char *buf; size_t len; =20 /* If no active message, or fully transmitted, the no-op */ diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index f452d0d306..2508e89503 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -39,7 +39,7 @@ typedef struct _qemuMonitorMessage qemuMonitorMessage; struct _qemuMonitorMessage { int txFD; =20 - char *txBuffer; + const char *txBuffer; int txOffset; int txLength; =20 diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index dcf9186191..6d8ccd91e8 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -322,7 +322,7 @@ qemuMonitorJSONCommandWithFd(qemuMonitor *mon, virBufferAddLit(&cmdbuf, "\r\n"); =20 msg.txLength =3D virBufferUse(&cmdbuf); - msg.txBuffer =3D virBufferContentAndReset(&cmdbuf); + msg.txBuffer =3D virBufferCurrentContent(&cmdbuf); msg.txFD =3D scm_fd; =20 ret =3D qemuMonitorSend(mon, &msg); @@ -338,8 +338,6 @@ qemuMonitorJSONCommandWithFd(qemuMonitor *mon, } =20 cleanup: - VIR_FREE(msg.txBuffer); - return ret; } =20 --=20 2.32.0 From nobody Fri May 3 11:16:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1635159483; cv=none; d=zohomail.com; s=zohoarc; b=J+nJi5gY90sRSb9oUwM/FMlgACzWb/30k3jL8aPu2lAaQRhxS4xoIws6D0zKMdkZHT/gZjdJ/HuhBfYWDDzgBrDHmw6AXENnS3OVNWAKYqEMVsoRN+aIX9mAArjg1LxDRWHkP28R5/lRE03cLsoc3k+4W2Ez7yZd4m0zr6FQ59c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635159483; 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=spYOI+SX84CSE9nYjA2Imq6C7V1osizHwOIM/QuR+VA=; b=hsjL+R+DCd/qdUw3JXrwhZkKQ07pdUDWFl9OosDdfT5PiUDYWW0vC6lBM1Dszt9HiPrHsqBs61ghLHwBQ2AbwZCGA1MQ62b3c0nuOkaSaTmlqL1NYODm0sIDu1NNZKR9P5SW/IDKG/n0XqxyXk4+1RCnHxUHm3JDzKqgvqk+Ldk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1635159483964880.5592797914607; Mon, 25 Oct 2021 03:58:03 -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-6-pxEQ-pf1PZ2LWHQ33j015w-1; Mon, 25 Oct 2021 06:57:59 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2FA139F952; Mon, 25 Oct 2021 10:57:54 +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 0F1D45DD68; Mon, 25 Oct 2021 10:57:54 +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 C57FD181A1D0; Mon, 25 Oct 2021 10:57:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19PAvpfI016853 for ; Mon, 25 Oct 2021 06:57:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3834CADCD; Mon, 25 Oct 2021 10:57:51 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3B055DAA5 for ; Mon, 25 Oct 2021 10:57:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635159483; 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=spYOI+SX84CSE9nYjA2Imq6C7V1osizHwOIM/QuR+VA=; b=Gb2sxndnE3bckhzRwaErMAyXzMx2Bi5WoyfePCrLL1j9W9H5ddmDE7N8CszfAoTA09M7TU zIRZJoCpdKnbRoMqLXyZ+9jbPZezHKeqIqdZTolkLlkIZYfO4GJlen9LOlPjF/YDlfn0mG r11XsMQ22nenrGtxvZJv38XMcaFzejs= X-MC-Unique: pxEQ-pf1PZ2LWHQ33j015w-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 03/13] qemuMonitorJSONHumanCommand: Require @reply_str Date: Mon, 25 Oct 2021 12:57:27 +0200 Message-Id: <14d62f1b60d5cb770cd5c940fe657c71daba4b89.1635159386.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.14 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: 1635159485374100005 Content-Type: text/plain; charset="utf-8" All callers of qemuMonitorJSONHumanCommand() pass a non-NULL pointer as @reply_str therefore there's no need to check whether it is NULL. NB, the sister function (qemuMonitorJSONArbitraryCommand()) doesn't check for NULL either. Signed-off-by: Michal Privoznik Reviewed-by: Tim Wiederhake --- src/qemu/qemu_monitor_json.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 6d8ccd91e8..7833038a06 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -1470,6 +1470,7 @@ qemuMonitorJSONHumanCommand(qemuMonitor *mon, virJSONValue *cmd =3D NULL; virJSONValue *reply =3D NULL; virJSONValue *obj; + const char *data; int ret =3D -1; =20 cmd =3D qemuMonitorJSONMakeCommand("human-monitor-command", @@ -1490,13 +1491,8 @@ qemuMonitorJSONHumanCommand(qemuMonitor *mon, goto cleanup; =20 obj =3D virJSONValueObjectGet(reply, "return"); - - if (reply_str) { - const char *data; - - data =3D virJSONValueGetString(obj); - *reply_str =3D g_strdup(NULLSTR_EMPTY(data)); - } + data =3D virJSONValueGetString(obj); + *reply_str =3D g_strdup(NULLSTR_EMPTY(data)); =20 ret =3D 0; =20 --=20 2.32.0 From nobody Fri May 3 11:16:03 2024 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=1635159487; cv=none; d=zohomail.com; s=zohoarc; b=N7Mr5NO14wTC7qLfQlnSgrNJeuC1P2oGziZvw1GCgLBcOl5nEGT47Gt0EEL7+gGGRW4cbA6tA9cB40m0N1M97qs/n4lnz1Y4GS5/xAmKNqzt+3xcNaotcJNcLg8KiPnKd6+Ia+qbt4/3dDa6g1a6OgCH6xwzXAy+R6E8VXkX2tU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635159487; 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=fWen/VjASsFnx33sTTQjIOYmkoBffx25N12Su6dDptg=; b=XqPMTbjk4kavcqlPAuBaaZyGOulUnozjFPqzGr52ANrinW9Is3ocToqGWm50f7LEH0b2i5poHlARATFlh7usv9JwdPwHRh+JTRKIwq2ShbiZ6g6wzycDhLkCHbM2kZRKg6bEbYb1dO4SCUE0hVOj/tCFvH3ZcnFyVJAb6QCC448= 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 1635159487715486.72741416825124; Mon, 25 Oct 2021 03:58:07 -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-421-CzDjKuBfN-SlmGVkgW1-BQ-1; Mon, 25 Oct 2021 06:58:03 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 10379A0CB0; Mon, 25 Oct 2021 10:57:57 +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 E5C8C70871; Mon, 25 Oct 2021 10:57:56 +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 B23FD4E58E; Mon, 25 Oct 2021 10:57:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19PAvqHG016861 for ; Mon, 25 Oct 2021 06:57:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 08D525DAA5; Mon, 25 Oct 2021 10:57:52 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84FB75DD68 for ; Mon, 25 Oct 2021 10:57:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635159486; 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=fWen/VjASsFnx33sTTQjIOYmkoBffx25N12Su6dDptg=; b=dWPshO07QhdxOWYTY1lwZMKJmn+HgYcJPSB0tjG9iZ4ziovfr66/0oy1u4S0pTG3tGDglT 821x2szP6jINH/JVEe1gz+tgc77+Gt/mzXhlornanh1EXLTsLMHafTOsHbTYTPxRoAU2X5 Y84cx2bvWtjA/rBQjAqdYJok2i9fows= X-MC-Unique: CzDjKuBfN-SlmGVkgW1-BQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 04/13] qemuMonitorJSONGetMigrationStats: Don't clear @stats on failure Date: Mon, 25 Oct 2021 12:57:28 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.13 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: 1635159489877100003 Content-Type: text/plain; charset="utf-8" In the qemuMonitorJSONGetMigrationStats() there's a code under cleanup label that's clearing returned @stats if the function returns with an error. However, transitively there's just one caller - qemuMigrationAnyFetchStats() - and it doesn't care for this behaviour. Drop the code to simplify the cleanup label. Signed-off-by: Michal Privoznik Reviewed-by: Tim Wiederhake --- src/qemu/qemu_monitor_json.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 7833038a06..bcbb4e59ab 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3542,8 +3542,6 @@ int qemuMonitorJSONGetMigrationStats(qemuMonitor *mon, =20 ret =3D 0; cleanup: - if (ret < 0) - memset(stats, 0, sizeof(*stats)); virJSONValueFree(cmd); virJSONValueFree(reply); return ret; --=20 2.32.0 From nobody Fri May 3 11:16:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1635159486; cv=none; d=zohomail.com; s=zohoarc; b=WIsE0sYH74b3BbTIw6rLd2sLfAl5/sxZlhi/9c0Ld3/+4joE1qPjnmFX/LHzNd2Go6ur2+f8JZ8axY9HT4y6BXxucxolOdKsW3tzlPWVz/Nzz/GBKeKC6UPK4VR6lvmtSf+FT/90wO4mMDm4BLfCKGFiD1p2TuC/OcEh0oPXxto= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635159486; 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=+BoHxrc5+2CDQFsNHe0bzj/42+tbUSetdoxTyECFJGo=; b=Jo6EyppzbfWCPRXJ0Xqvbxj4hwU+3X+MoGtzeqfCxdg2qXrsDsoKpPR83rzppEBJJtFCWIY5diazW6g6MRO3WukF15JMzsGa9sFnERhcapxImiAQrzf8SjQqZhbFirl4rclyDt7WihpP+kx6ZvHgXB4IIGRAYp8ZS0wJMYMZjvU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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 [170.10.129.124]) by mx.zohomail.com with SMTPS id 1635159486752624.6132180084618; Mon, 25 Oct 2021 03:58: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-107-gp-JDWnVMk6CJj6JK15MHw-1; Mon, 25 Oct 2021 06:58:01 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C73DE1014514; Mon, 25 Oct 2021 10:57:56 +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 A489819724; Mon, 25 Oct 2021 10:57:56 +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 6AB981832DD5; Mon, 25 Oct 2021 10:57:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19PAvqH0016868 for ; Mon, 25 Oct 2021 06:57:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id CDFE4ADCD; Mon, 25 Oct 2021 10:57:52 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 560545DAA5 for ; Mon, 25 Oct 2021 10:57:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635159483; 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=+BoHxrc5+2CDQFsNHe0bzj/42+tbUSetdoxTyECFJGo=; b=awRyhbv92ep9iFFBNuZ6gxW5atVxGAX741nExVqcE3qKwFSpPkurGHKC/qKbg7bFjWqGFm J0dC7Ovdb1Rtmf0/EskFNHuZ/jDjorSv+zWwLd3rSko1o5w9YzTZCmitMK3LPwMEYsHFAT qtGDFDujWpRyWS2YoALIf79WfRRPQaY= X-MC-Unique: gp-JDWnVMk6CJj6JK15MHw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 05/13] qemuMonitorJSONQueryRxFilterParse: Set *filter only on success Date: Mon, 25 Oct 2021 12:57:29 +0200 Message-Id: <8bff82ce053f4b1c747fee32f9502e3632bd413d.1635159386.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.23 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: 1635159487715100001 Content-Type: text/plain; charset="utf-8" The qemuMonitorJSONQueryRxFilterParse() function is called to parse the output of 'query-rx-filter' and store results into passed virNetDevRxFilter structure. However, it is doing so in a bit clumsy way - the return pointer is set in all cases (i.e. even in case of error) and thus the cleanup label is more complicated than it needs to be. With a help of g_autoptr() and g_steal_pointer() the return pointer can be set only in case of success - which is what callers expect anyway. The same applies to qemuMonitorJSONQueryRxFilter(). Signed-off-by: Michal Privoznik Reviewed-by: Tim Wiederhake --- src/qemu/qemu_monitor_json.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index bcbb4e59ab..26cbb8cedc 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4035,7 +4035,7 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg, virJSONValue *element; size_t nTable; size_t i; - virNetDevRxFilter *fil =3D virNetDevRxFilterNew(); + g_autoptr(virNetDevRxFilter) fil =3D virNetDevRxFilterNew(); =20 if (!fil) goto cleanup; @@ -4187,13 +4187,9 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg, } fil->vlan.nTable =3D nTable; =20 + *filter =3D g_steal_pointer(&fil); ret =3D 0; cleanup: - if (ret < 0) { - virNetDevRxFilterFree(fil); - fil =3D NULL; - } - *filter =3D fil; return ret; } =20 @@ -4222,10 +4218,6 @@ qemuMonitorJSONQueryRxFilter(qemuMonitor *mon, const= char *alias, =20 ret =3D 0; cleanup: - if (ret < 0) { - virNetDevRxFilterFree(*filter); - *filter =3D NULL; - } virJSONValueFree(cmd); virJSONValueFree(reply); return ret; --=20 2.32.0 From nobody Fri May 3 11:16:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1635159555; cv=none; d=zohomail.com; s=zohoarc; b=SK8h6t2lllIcWy/JPIQZkjnrG2s94VHe0Agj1IGr4sQkyIqD+us4vf2w9h065SMaRJ9KR/MK/8a+FWY60e0USXF5/vHiJ4+wlG2xBy/SQkuxewNwoC5hXsE1BKE4XvtUUqXu84QLGWMChtEdYd7wYKDX4E10bFwjaQCI39+Oa7A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635159555; 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=sECqwqMS0ZD/MzgBaAM7LHwKcYwjhWxSg1c7NWtWMeA=; b=KJaTaBe3cQz+EPNRNWu3OyYGsjyT2l56MaXht1FkHfLdiuYV9bxkc4qC9s+9DoW0GOBPeTCx/o9UAPSQ2N/HXMlLrtN/ObBfBNVjn+FhJI2kEELoQMbzU4qOBc8BawgOull3lTzI7WHDa/mZKic7OJ+qQOoSiPFD25+/cIhJnxc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1635159555112131.99821370614734; Mon, 25 Oct 2021 03:59:15 -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-453-zXUFNno1NUSLgnyicEy2sw-1; Mon, 25 Oct 2021 06:58:06 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 105E4101B4A7; Mon, 25 Oct 2021 10:58:00 +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 E4F7A5DAA5; Mon, 25 Oct 2021 10:57:59 +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 B29CF4EA29; Mon, 25 Oct 2021 10:57:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19PAvrwQ016874 for ; Mon, 25 Oct 2021 06:57:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id A0B8A5DAA5; Mon, 25 Oct 2021 10:57:53 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2767C5DD68 for ; Mon, 25 Oct 2021 10:57:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635159554; 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=sECqwqMS0ZD/MzgBaAM7LHwKcYwjhWxSg1c7NWtWMeA=; b=DuP+ZDf6eHL5+gfI1NUWZhuV8rF6cqV84tORmq6GK5HC9WmV68YmglVrJRIN/5Me1QjpFl lQe3DUmUw3BCqL8dRi56j0wViYrr7JCYy/uTxJUIYDZS6YuzsNzDVSeMK7zzHR8lrwDwFD v0R/KH1W7XvxmM+EVKVIzjWbQLFtqdo= X-MC-Unique: zXUFNno1NUSLgnyicEy2sw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 06/13] qemu_monitor: Declare and use g_autoptr for qemuMonitorEventPanicInfo Date: Mon, 25 Oct 2021 12:57:30 +0200 Message-Id: <402e52653a3953444bc2eaa3ab8151a051195cd6.1635159386.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.14 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: 1635159556579100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik Reviewed-by: Tim Wiederhake --- src/qemu/qemu_monitor.h | 1 + src/qemu/qemu_monitor_json.c | 22 ++++++---------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 2508e89503..8214c2fd9f 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -194,6 +194,7 @@ struct _qemuMonitorJobInfo { =20 char *qemuMonitorGuestPanicEventInfoFormatMsg(qemuMonitorEventPanicInfo *i= nfo); void qemuMonitorEventPanicInfoFree(qemuMonitorEventPanicInfo *info); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuMonitorEventPanicInfo, qemuMonitorEventP= anicInfoFree); void qemuMonitorEventRdmaGidStatusFree(qemuMonitorRdmaGidStatus *info); void qemuMonitorMemoryDeviceSizeChangeFree(qemuMonitorMemoryDeviceSizeChan= ge *info); =20 diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 26cbb8cedc..655d2a022f 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -605,9 +605,7 @@ static void qemuMonitorJSONHandleResume(qemuMonitor *mo= n, virJSONValue *data G_G static qemuMonitorEventPanicInfo * qemuMonitorJSONGuestPanicExtractInfoHyperv(virJSONValue *data) { - qemuMonitorEventPanicInfo *ret; - - ret =3D g_new0(qemuMonitorEventPanicInfo, 1); + g_autoptr(qemuMonitorEventPanicInfo) ret =3D g_new0(qemuMonitorEventPa= nicInfo, 1); =20 ret->type =3D QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_HYPERV; =20 @@ -618,20 +616,16 @@ qemuMonitorJSONGuestPanicExtractInfoHyperv(virJSONVal= ue *data) virJSONValueObjectGetNumberUlong(data, "arg5", &ret->data.hyperv.a= rg5) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed hyperv panic data")); - goto error; + return NULL; } =20 - return ret; - - error: - qemuMonitorEventPanicInfoFree(ret); - return NULL; + return g_steal_pointer(&ret); } =20 static qemuMonitorEventPanicInfo * qemuMonitorJSONGuestPanicExtractInfoS390(virJSONValue *data) { - qemuMonitorEventPanicInfo *ret; + g_autoptr(qemuMonitorEventPanicInfo) ret =3D NULL; int core; unsigned long long psw_mask, psw_addr; const char *reason =3D NULL; @@ -645,7 +639,7 @@ qemuMonitorJSONGuestPanicExtractInfoS390(virJSONValue *= data) virJSONValueObjectGetNumberUlong(data, "psw-addr", &psw_addr) < 0 = || !(reason =3D virJSONValueObjectGetString(data, "reason"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed s390 pan= ic data")); - goto error; + return NULL; } =20 ret->data.s390.core =3D core; @@ -654,11 +648,7 @@ qemuMonitorJSONGuestPanicExtractInfoS390(virJSONValue = *data) =20 ret->data.s390.reason =3D g_strdup(reason); =20 - return ret; - - error: - qemuMonitorEventPanicInfoFree(ret); - return NULL; + return g_steal_pointer(&ret); } =20 static qemuMonitorEventPanicInfo * --=20 2.32.0 From nobody Fri May 3 11:16:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1635159492; cv=none; d=zohomail.com; s=zohoarc; b=A7czUV4oalZ9ep4lGbUjUTu1Ea/yffmG/cfD400pe8vmv5Cq8K1QaWhAf6J5Yif3KIR4VeY4ytEUFSKPRsaw9KK4DJYUnaHW/4m/sXbEXRamILNFCRdLldHY/Pfn1TKBBakD6+N4YOoVBY6A3J2/uINxA6Ff9GIzgibB5nGkLrc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635159492; 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=adbXTynd/33wTSECI3hoCAxBRT4YTuVx1Vh+cgU/C28=; b=nhvyrIeWmK8fzvpPd7ftfdw/fg7SA+8D6iG+Dj0quCXSZX/7et76BMLU6fie8+YsMMAwdOtpA5G3hB5QQQgxBuD63N5pr7O/n3BCz0bUz8NseaW7g0/kUI2gtmueo5laK5FHRg+2VxpnbqfozxgCuSRW4T4TVBwW0L2xOyO04jY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1635159492502474.02868210542124; Mon, 25 Oct 2021 03:58:12 -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-438-iSQv4hZqNEyWhHE2HzvKOw-1; Mon, 25 Oct 2021 06:58:07 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4B58A802B78; Mon, 25 Oct 2021 10:58:03 +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 261F55D705; Mon, 25 Oct 2021 10:58:03 +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 E780C1832DD6; Mon, 25 Oct 2021 10:58:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19PAvsS9016879 for ; Mon, 25 Oct 2021 06:57:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 72905ADCD; Mon, 25 Oct 2021 10:57:54 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id EED885DAA5 for ; Mon, 25 Oct 2021 10:57:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635159491; 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=adbXTynd/33wTSECI3hoCAxBRT4YTuVx1Vh+cgU/C28=; b=GMR4IQSmuRGtHcB++avil9IkcpE1l+d0jJfubiEAOAvDA4QHk1EQdI3ih90qCUgavF2kZR qFIlS7ZJd17LgHO4JhBaPg9w4Qm7vDUMfSjO5URdfPCtoY8pJWIHRBo7WA0w3pIZu4+0cG 5hh1Wk6utm5ELXs0RiH/UkAL3ZPY+1k= X-MC-Unique: iSQv4hZqNEyWhHE2HzvKOw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 07/13] qemu_monitor_json: Use g_autoptr() for virCPUData Date: Mon, 25 Oct 2021 12:57:31 +0200 Message-Id: <7dc7712c4da771a0974522a55e4e04c05c5b4fef.1635159386.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.15 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: 1635159494175100001 Content-Type: text/plain; charset="utf-8" We have g_autoptr() for virCPUData struct defined already. Let's use it in qemu_monitor_json.c and drop explicit free calls. Signed-off-by: Michal Privoznik Reviewed-by: Tim Wiederhake --- src/qemu/qemu_monitor_json.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 655d2a022f..3d89afa6c6 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -7288,7 +7288,7 @@ qemuMonitorJSONParseCPUx86FeatureWord(virJSONValue *d= ata, static virCPUData * qemuMonitorJSONParseCPUx86Features(virJSONValue *data) { - virCPUData *cpudata =3D NULL; + g_autoptr(virCPUData) cpudata =3D NULL; virCPUx86DataItem item =3D { 0 }; size_t i; =20 @@ -7303,10 +7303,9 @@ qemuMonitorJSONParseCPUx86Features(virJSONValue *dat= a) goto error; } =20 - return cpudata; + return g_steal_pointer(&cpudata); =20 error: - virCPUDataFree(cpudata); return NULL; } =20 @@ -7418,8 +7417,8 @@ qemuMonitorJSONGetGuestCPUx86(qemuMonitor *mon, virCPUData **data, virCPUData **disabled) { - virCPUData *cpuEnabled =3D NULL; - virCPUData *cpuDisabled =3D NULL; + g_autoptr(virCPUData) cpuEnabled =3D NULL; + g_autoptr(virCPUData) cpuDisabled =3D NULL; int rc; =20 if ((rc =3D qemuMonitorJSONCheckCPUx86(mon)) < 0) @@ -7436,14 +7435,12 @@ qemuMonitorJSONGetGuestCPUx86(qemuMonitor *mon, &cpuDisabled) < 0) goto error; =20 - *data =3D cpuEnabled; + *data =3D g_steal_pointer(&cpuEnabled); if (disabled) - *disabled =3D cpuDisabled; + *disabled =3D g_steal_pointer(&cpuDisabled); return 0; =20 error: - virCPUDataFree(cpuEnabled); - virCPUDataFree(cpuDisabled); return -1; } =20 @@ -7554,8 +7551,8 @@ qemuMonitorJSONGetGuestCPU(qemuMonitor *mon, virCPUData **enabled, virCPUData **disabled) { - virCPUData *cpuEnabled =3D NULL; - virCPUData *cpuDisabled =3D NULL; + g_autoptr(virCPUData) cpuEnabled =3D NULL; + g_autoptr(virCPUData) cpuDisabled =3D NULL; int ret =3D -1; =20 if (!(cpuEnabled =3D virCPUDataNew(arch)) || @@ -7576,8 +7573,6 @@ qemuMonitorJSONGetGuestCPU(qemuMonitor *mon, ret =3D 0; =20 cleanup: - virCPUDataFree(cpuEnabled); - virCPUDataFree(cpuDisabled); return ret; } =20 --=20 2.32.0 From nobody Fri May 3 11:16:03 2024 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=1635159547; cv=none; d=zohomail.com; s=zohoarc; b=hWQR/Ak/ptQ+3yB9V3zjLwtKpIOVmXT2u2QtsSbFRKQi/0goXaud7v7croSnv6f+EW+56a62Gv6mT9jthSrKj2dmxJCdlyCme8zj16dk7EJMOHoVQlXyZxKRNI7bhEJvmWWybeJcUbvW6rnVyfmoAwOQyXtX9glcakJFLn/a7fk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635159547; 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=aVaPYoSbfdEp1Yvm3lmoat8NIUoF4WjcCgdd90zum1w=; b=NhN7E1vgIeoxdO+zKBvQ5NqHvOQzzaL6pn2z0CMwu2jzf5B+NuCQbqJAi3Dh/UaGzmFrcEn+8mElrWqRpyD9zUpZ8+rQno6HqdU2SljYgaGuAcc6VXDqTWG8HqD75v50ASgWD/htpeaAn8w0YaJF9rAqyWHuN6lidfdsxTXeSHA= 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 163515954709380.87434245302097; Mon, 25 Oct 2021 03:59:07 -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-581-30oQr-UMPoOMe9N2J4ME0g-1; Mon, 25 Oct 2021 06:58:11 -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 6F5611B2C984; Mon, 25 Oct 2021 10:58:06 +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 52E5757CA4; Mon, 25 Oct 2021 10:58:06 +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 1C57B1832DDA; Mon, 25 Oct 2021 10:58:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19PAvtmp016887 for ; Mon, 25 Oct 2021 06:57:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4427C5DAA5; Mon, 25 Oct 2021 10:57:55 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id C01AB5DD68 for ; Mon, 25 Oct 2021 10:57:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635159546; 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=aVaPYoSbfdEp1Yvm3lmoat8NIUoF4WjcCgdd90zum1w=; b=HjRo0U1niYEdEQZjF1vUiTBa6abAQYE1dgKxXBURHo1/VY44xScqsHQlKLkAbuU+p1I9Jy ETfbwA6bveloMHescbJbxsCoxnCVO8GAyJ8F1/CZ28kxktgWTZnQRbs2/LZ2wOt21UgYrL kjTyVaDssCMk7+V7xaNxD3U7ySOTCPM= X-MC-Unique: 30oQr-UMPoOMe9N2J4ME0g-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 08/13] qemu_monitor_json: Use g_autoptr() for qemuMonitorCPUModelInfo Date: Mon, 25 Oct 2021 12:57:32 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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) X-ZM-MESSAGEID: 1635159548223100006 Content-Type: text/plain; charset="utf-8" There's one place (specifically qemuMonitorJSONParseCPUModel()) where we can avoid explicit free call for qemuMonitorCPUModelInfo struct. Signed-off-by: Michal Privoznik Reviewed-by: Tim Wiederhake --- src/qemu/qemu_monitor_json.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 3d89afa6c6..f59688dfd5 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5693,7 +5693,7 @@ qemuMonitorJSONParseCPUModel(const char *cpu_name, virJSONValue *cpu_props, qemuMonitorCPUModelInfo **model_info) { - qemuMonitorCPUModelInfo *machine_model =3D NULL; + g_autoptr(qemuMonitorCPUModelInfo) machine_model =3D NULL; int ret =3D -1; =20 machine_model =3D g_new0(qemuMonitorCPUModelInfo, 1); @@ -5714,7 +5714,6 @@ qemuMonitorJSONParseCPUModel(const char *cpu_name, ret =3D 0; =20 cleanup: - qemuMonitorCPUModelInfoFree(machine_model); return ret; } =20 --=20 2.32.0 From nobody Fri May 3 11:16:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1635159546; cv=none; d=zohomail.com; s=zohoarc; b=HJyjFLIiKR7PcxuWaSTEcYsSjUfc6ARHSB9HNGP+0M9DZqz7K3F34yLV/6OcSyZvHJsKgyJ/JHnd9q4dWiDB3xVKc/I7GW9gqqr1BtK1wiSX1pTqA8NVOg+WItDmIKyLqkG4m3Z25WK6L66Q+/j7kAOLxf90uScrOUZ8z0Syzpo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635159546; 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=zU8SCxpwOIh9DyPG+cYSSY/3EN7KRdjUtwFn12e+PU8=; b=EEJtI7t/vWFQmjR+WmOLqGCY57jIcQrJz4RbwuaymgdOc+LV4tNCpLh327cXjLtAnhFT78MOLnlDIULGwbcTRAQIRQrC82KNBSKOYezyV/e/K/bA7gDhLahcPG3NgpmHZVZ4Itol3PkJ/o1ca6qZivN/QRA7YFrZkX5f4JqlXto= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1635159546962641.899378192347; Mon, 25 Oct 2021 03:59: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-277-5eb0dL2jNZukn6E_croTZw-1; Mon, 25 Oct 2021 06:58:14 -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 2BD7680A5C5; Mon, 25 Oct 2021 10:58:09 +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 0EC011054FFF; Mon, 25 Oct 2021 10:58:09 +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 C89684EA31; Mon, 25 Oct 2021 10:58:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19PAvu5B016897 for ; Mon, 25 Oct 2021 06:57:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 165CC17CE1; Mon, 25 Oct 2021 10:57:56 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9176D5DAA5 for ; Mon, 25 Oct 2021 10:57:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635159546; 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=zU8SCxpwOIh9DyPG+cYSSY/3EN7KRdjUtwFn12e+PU8=; b=IpHd2VN8uJ1dXgZR56b4TpO0Ac3NzJ5tzVNdJxgXfZLaOUAbemRXk0+cOyoWrXLUJkwhbT 6mYM9vl1KAARD6pjCmzCgVmmoq0tP69darjn1x+L7Wf3Fk/hugqWbO4J3d4/pBlkA+uBBA IQajjVdL1ti8Haa3M163jjH0btqUPh0= X-MC-Unique: 5eb0dL2jNZukn6E_croTZw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 09/13] qemuMonitorJSONExtractPRManagerInfo: Declare @entry inside the loop Date: Mon, 25 Oct 2021 12:57:33 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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: 1635159548190100005 Content-Type: text/plain; charset="utf-8" The reason why @entry variable in qemuMonitorJSONExtractPRManagerInfo() was declared at the top most level was that the variable is used under the cleanup label. However, if declared using g_autofree then the variable can be declared inside the loop it is used in. Signed-off-by: Michal Privoznik Reviewed-by: Tim Wiederhake --- src/qemu/qemu_monitor_json.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index f59688dfd5..f7bc680035 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8622,7 +8622,6 @@ static int qemuMonitorJSONExtractPRManagerInfo(virJSONValue *reply, GHashTable *info) { - qemuMonitorPRManagerInfo *entry =3D NULL; virJSONValue *data; int ret =3D -1; size_t i; @@ -8630,6 +8629,7 @@ qemuMonitorJSONExtractPRManagerInfo(virJSONValue *rep= ly, data =3D virJSONValueObjectGetArray(reply, "return"); =20 for (i =3D 0; i < virJSONValueArraySize(data); i++) { + g_autofree qemuMonitorPRManagerInfo *entry =3D NULL; virJSONValue *prManager =3D virJSONValueArrayGet(data, i); const char *alias; =20 @@ -8652,7 +8652,6 @@ qemuMonitorJSONExtractPRManagerInfo(virJSONValue *rep= ly, =20 ret =3D 0; cleanup: - VIR_FREE(entry); return ret; =20 malformed: --=20 2.32.0 From nobody Fri May 3 11:16:03 2024 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=1635159502; cv=none; d=zohomail.com; s=zohoarc; b=MIDNYWXDbnQnZvp+vhOm659TfzmIaatOPQjLGGlV9KbNLokZh4G+ywxpEjWOmqPn/cZ/M+MLUpie0honMVg2oA4v9AjL2PENNpT0tFQRB78TUx/Bhhi/F5EHRvuXiUAlfkHIMZYylotlwrNBlHyVamuoMisVP6qfMkX2pQwcKkc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635159502; 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=IMV7Kdm+uNeDwGBU4XiYht1/zrSUB3MgGVSavGFoXxM=; b=MGJzcj7f/pLSnmGkn7ESJjQr4jzDG/A/m5aSLuIGhmiOvdI/ncFXFA7/KEg884OQ9betAZTwAuXkYG9H//IbUjWoQx4+wu4e7miEyi2JfK1esKGU7/P7kxF0V2lqBXGFBS8XtqrUsjmp3S64NkSLCHkc3XybmaRRGRhADxYchb0= 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 1635159502335733.6177705507796; Mon, 25 Oct 2021 03:58:22 -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-245-IDFFFZUkPd6GBJHzXLshQw-1; Mon, 25 Oct 2021 06:58:17 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 81DA680A5C7; Mon, 25 Oct 2021 10:58:12 +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 609455DAA5; Mon, 25 Oct 2021 10:58:12 +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 29B0F4EA3D; Mon, 25 Oct 2021 10:58:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19PAvwtQ016909 for ; Mon, 25 Oct 2021 06:57:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6969D5DAA5; Mon, 25 Oct 2021 10:57:58 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 979455DD68 for ; Mon, 25 Oct 2021 10:57:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635159501; 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=IMV7Kdm+uNeDwGBU4XiYht1/zrSUB3MgGVSavGFoXxM=; b=GPXygFZuh5H6uKqRRJu46rdYAhInapgVDWyglHzwbGct+PX9YErAtxvtAExZoeGMv37+YY rV+DUyVHRHuJSnARTUFS9b0tEVMChHONchjmSBxWioS5dtcbfcjB9oMju8VPDLODkvtVjc UyeUqNGLlC85UTGFwLq3Q9uox7fhOU8= X-MC-Unique: IDFFFZUkPd6GBJHzXLshQw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 10/13] qemu_monitor_json: Use g_autoptr() for virJSONValue Date: Mon, 25 Oct 2021 12:57:34 +0200 Message-Id: <291121e2d8812cc5cb1209ec43542062344d4c59.1635159386.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.14 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: 1635159502880100002 Content-Type: text/plain; charset="utf-8" A lot of explicit free calls can be saved when virJSONValue variables are declared with g_autoptr(). There's one caveat: there was a slight deviation from our usual pattern such that @cmd variable was not initialized to NULL but as the very first step it was assigned a value using qemuMonitorJSONMakeCommand(). While this works in theory it upset my GCC-11.2 (but only when building with -O2). So I had to initialize the variable in such case too. Signed-off-by: Michal Privoznik Reviewed-by: Tim Wiederhake --- src/qemu/qemu_monitor_json.c | 623 +++++++++++++---------------------- 1 file changed, 227 insertions(+), 396 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index f7bc680035..1eb0b3b54c 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -216,7 +216,7 @@ qemuMonitorJSONIOProcessLine(qemuMonitor *mon, const char *line, qemuMonitorMessage *msg) { - virJSONValue *obj =3D NULL; + g_autoptr(virJSONValue) obj =3D NULL; int ret =3D -1; =20 VIR_DEBUG("Line [%s]", line); @@ -254,7 +254,6 @@ qemuMonitorJSONIOProcessLine(qemuMonitor *mon, } =20 cleanup: - virJSONValueFree(obj); return ret; } =20 @@ -1457,8 +1456,8 @@ qemuMonitorJSONHumanCommand(qemuMonitor *mon, const char *cmd_str, char **reply_str) { - virJSONValue *cmd =3D NULL; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *obj; const char *data; int ret =3D -1; @@ -1487,8 +1486,6 @@ qemuMonitorJSONHumanCommand(qemuMonitor *mon, ret =3D 0; =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -1517,14 +1514,15 @@ int qemuMonitorJSONStartCPUs(qemuMonitor *mon) { int ret; - virJSONValue *cmd =3D qemuMonitorJSONMakeCommand("cont", NULL); - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("cont", NUL= L); size_t i =3D 0; int timeout =3D 3; if (!cmd) return -1; =20 do { + g_autoptr(virJSONValue) reply =3D NULL; + ret =3D qemuMonitorJSONCommand(mon, cmd, &reply); =20 if (ret !=3D 0) @@ -1539,13 +1537,9 @@ qemuMonitorJSONStartCPUs(qemuMonitor *mon) if (!qemuMonitorJSONHasError(reply, "MigrationExpected")) break; =20 - virJSONValueFree(reply); - reply =3D NULL; g_usleep(250000); } while (++i <=3D timeout); =20 - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -1554,8 +1548,9 @@ int qemuMonitorJSONStopCPUs(qemuMonitor *mon) { int ret =3D -1; - virJSONValue *cmd =3D qemuMonitorJSONMakeCommand("stop", NULL); - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("stop", NUL= L); + g_autoptr(virJSONValue) reply =3D NULL; + if (!cmd) return -1; =20 @@ -1567,8 +1562,6 @@ qemuMonitorJSONStopCPUs(qemuMonitor *mon) =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -1617,8 +1610,9 @@ qemuMonitorJSONGetStatus(qemuMonitor *mon, int qemuMonitorJSONSystemPowerdown(qemuMonitor *mon) { int ret =3D -1; - virJSONValue *cmd =3D qemuMonitorJSONMakeCommand("system_powerdown", N= ULL); - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("system_pow= erdown", NULL); + g_autoptr(virJSONValue) reply =3D NULL; + if (!cmd) return -1; =20 @@ -1630,8 +1624,6 @@ int qemuMonitorJSONSystemPowerdown(qemuMonitor *mon) =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -1640,11 +1632,11 @@ int qemuMonitorJSONSetLink(qemuMonitor *mon, virDomainNetInterfaceLinkState state) { int ret =3D -1; - virJSONValue *reply =3D NULL; - virJSONValue *cmd =3D qemuMonitorJSONMakeCommand("set_link", - "s:name", name, - "b:up", state !=3D VI= R_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN, - NULL); + g_autoptr(virJSONValue) reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("set_link", + "s:name", nam= e, + "b:up", state= !=3D VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN, + NULL); =20 if (!cmd) return -1; @@ -1657,16 +1649,15 @@ int qemuMonitorJSONSetLink(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 int qemuMonitorJSONSystemReset(qemuMonitor *mon) { int ret =3D -1; - virJSONValue *cmd =3D qemuMonitorJSONMakeCommand("system_reset", NULL); - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("system_res= et", NULL); + g_autoptr(virJSONValue) reply =3D NULL; + if (!cmd) return -1; =20 @@ -1678,8 +1669,6 @@ int qemuMonitorJSONSystemReset(qemuMonitor *mon) =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -1857,8 +1846,8 @@ qemuMonitorJSONQueryCPUs(qemuMonitor *mon, bool fast) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data; =20 if (fast) @@ -1883,8 +1872,6 @@ qemuMonitorJSONQueryCPUs(qemuMonitor *mon, ret =3D qemuMonitorJSONExtractCPUInfo(data, entries, nentries, fast); =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -2008,9 +1995,9 @@ qemuMonitorJSONGetBalloonInfo(qemuMonitor *mon, int ret =3D -1; virJSONValue *data; unsigned long long mem; - virJSONValue *cmd =3D qemuMonitorJSONMakeCommand("query-balloon", - NULL); - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("query-ball= oon", + NULL); + g_autoptr(virJSONValue) reply =3D NULL; =20 *currmem =3D 0; =20 @@ -2042,8 +2029,6 @@ qemuMonitorJSONGetBalloonInfo(qemuMonitor *mon, *currmem =3D (mem/1024); ret =3D 1; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -2091,8 +2076,8 @@ int qemuMonitorJSONGetMemoryStats(qemuMonitor *mon, unsigned int nr_stats) { int ret =3D -1; - virJSONValue *cmd =3D NULL; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data; virJSONValue *statsdata; unsigned long long mem; @@ -2164,8 +2149,6 @@ int qemuMonitorJSONGetMemoryStats(qemuMonitor *mon, =20 ret =3D got; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } #undef GET_BALLOON_STATS @@ -2220,8 +2203,8 @@ qemuMonitorJSONSetDBusVMStateIdList(qemuMonitor *mon, static virJSONValue * qemuMonitorJSONQueryBlock(qemuMonitor *mon) { - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *devices =3D NULL; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("query-block", NULL))) @@ -2234,8 +2217,6 @@ qemuMonitorJSONQueryBlock(qemuMonitor *mon) devices =3D virJSONValueObjectStealArray(reply, "return"); =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return devices; } =20 @@ -2305,8 +2286,7 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitor *mon, { int ret =3D -1; size_t i; - - virJSONValue *devices; + g_autoptr(virJSONValue) devices =3D NULL; =20 if (!(devices =3D qemuMonitorJSONQueryBlock(mon))) return -1; @@ -2373,7 +2353,6 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(devices); return ret; } =20 @@ -2686,7 +2665,7 @@ int qemuMonitorJSONBlockStatsUpdateCapacityBlockdev(qemuMonitor *mon, GHashTable *stats) { - virJSONValue *nodes; + g_autoptr(virJSONValue) nodes =3D NULL; int ret =3D -1; =20 if (!(nodes =3D qemuMonitorJSONQueryNamedBlockNodes(mon, false))) @@ -2700,7 +2679,6 @@ qemuMonitorJSONBlockStatsUpdateCapacityBlockdev(qemuM= onitor *mon, ret =3D 0; =20 cleanup: - virJSONValueFree(nodes); return ret; } =20 @@ -2873,8 +2851,8 @@ int qemuMonitorJSONBlockResize(qemuMonitor *mon, unsigned long long size) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 cmd =3D qemuMonitorJSONMakeCommand("block_resize", "S:device", device, @@ -2892,8 +2870,6 @@ int qemuMonitorJSONBlockResize(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -2904,12 +2880,13 @@ int qemuMonitorJSONSetPassword(qemuMonitor *mon, const char *action_if_connected) { int ret =3D -1; - virJSONValue *cmd =3D qemuMonitorJSONMakeCommand("set_password", - "s:protocol", protoco= l, - "s:password", passwor= d, - "s:connected", action= _if_connected, - NULL); - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("set_passwo= rd", + "s:protocol",= protocol, + "s:password",= password, + "s:connected"= , action_if_connected, + NULL); + g_autoptr(virJSONValue) reply =3D NULL; + if (!cmd) return -1; =20 @@ -2921,8 +2898,6 @@ int qemuMonitorJSONSetPassword(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -2931,11 +2906,12 @@ int qemuMonitorJSONExpirePassword(qemuMonitor *mon, const char *expire_time) { int ret =3D -1; - virJSONValue *cmd =3D qemuMonitorJSONMakeCommand("expire_password", - "s:protocol", protoco= l, - "s:time", expire_time, - NULL); - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("expire_pas= sword", + "s:protocol",= protocol, + "s:time", exp= ire_time, + NULL); + g_autoptr(virJSONValue) reply =3D NULL; + if (!cmd) return -1; =20 @@ -2947,8 +2923,6 @@ int qemuMonitorJSONExpirePassword(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -2958,10 +2932,11 @@ qemuMonitorJSONSetBalloon(qemuMonitor *mon, unsigned long long newmem) { int ret =3D -1; - virJSONValue *cmd =3D qemuMonitorJSONMakeCommand("balloon", - "U:value", newmem * 1= 024, - NULL); - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("balloon", + "U:value", ne= wmem * 1024, + NULL); + g_autoptr(virJSONValue) reply =3D NULL; + if (!cmd) return -1; =20 @@ -2982,8 +2957,6 @@ qemuMonitorJSONSetBalloon(qemuMonitor *mon, /* Real success */ ret =3D 1; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -2992,8 +2965,8 @@ int qemuMonitorJSONSetCPU(qemuMonitor *mon, int cpu, bool online) { int ret =3D -1; - virJSONValue *cmd =3D NULL; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 if (online) { cmd =3D qemuMonitorJSONMakeCommand("cpu-add", @@ -3013,8 +2986,6 @@ int qemuMonitorJSONSetCPU(qemuMonitor *mon, ret =3D qemuMonitorJSONCheckError(cmd, reply); =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -3031,11 +3002,12 @@ int qemuMonitorJSONEjectMedia(qemuMonitor *mon, bool force) { int ret =3D -1; - virJSONValue *cmd =3D qemuMonitorJSONMakeCommand("eject", - "s:device", dev_name, - "b:force", force ? 1 = : 0, - NULL); - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("eject", + "s:device", d= ev_name, + "b:force", fo= rce ? 1 : 0, + NULL); + g_autoptr(virJSONValue) reply =3D NULL; + if (!cmd) return -1; =20 @@ -3047,8 +3019,6 @@ int qemuMonitorJSONEjectMedia(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -3059,8 +3029,8 @@ int qemuMonitorJSONChangeMedia(qemuMonitor *mon, const char *format) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 cmd =3D qemuMonitorJSONMakeCommand("change", "s:device", dev_name, @@ -3079,8 +3049,6 @@ int qemuMonitorJSONChangeMedia(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -3092,12 +3060,13 @@ static int qemuMonitorJSONSaveMemory(qemuMonitor *m= on, const char *path) { int ret =3D -1; - virJSONValue *cmd =3D qemuMonitorJSONMakeCommand(cmdtype, - "U:val", offset, - "U:size", length, - "s:filename", path, - NULL); - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand(cmdtype, + "U:val", offs= et, + "U:size", len= gth, + "s:filename",= path, + NULL); + g_autoptr(virJSONValue) reply =3D NULL; + if (!cmd) return -1; =20 @@ -3109,8 +3078,6 @@ static int qemuMonitorJSONSaveMemory(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -3136,8 +3103,9 @@ int qemuMonitorJSONSetMigrationSpeed(qemuMonitor *mon, unsigned long bandwidth) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; + cmd =3D qemuMonitorJSONMakeCommand("migrate_set_speed", "U:value", bandwidth * 1024ULL * 1024= ULL, NULL); @@ -3152,8 +3120,6 @@ int qemuMonitorJSONSetMigrationSpeed(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -3162,8 +3128,8 @@ int qemuMonitorJSONSetMigrationDowntime(qemuMonitor *= mon, unsigned long long downtime) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 cmd =3D qemuMonitorJSONMakeCommand("migrate_set_downtime", "d:value", downtime / 1000.0, @@ -3179,8 +3145,6 @@ int qemuMonitorJSONSetMigrationDowntime(qemuMonitor *= mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -3190,8 +3154,8 @@ qemuMonitorJSONGetMigrationCacheSize(qemuMonitor *mon, unsigned long long *cacheSize) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 *cacheSize =3D 0; =20 @@ -3213,8 +3177,6 @@ qemuMonitorJSONGetMigrationCacheSize(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -3224,8 +3186,8 @@ qemuMonitorJSONSetMigrationCacheSize(qemuMonitor *mon, unsigned long long cacheSize) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 cmd =3D qemuMonitorJSONMakeCommand("migrate-set-cache-size", "U:value", cacheSize, @@ -3241,8 +3203,6 @@ qemuMonitorJSONSetMigrationCacheSize(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -3252,8 +3212,8 @@ qemuMonitorJSONGetMigrationParams(qemuMonitor *mon, virJSONValue **params) { int ret =3D -1; - virJSONValue *cmd =3D NULL; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 *params =3D NULL; =20 @@ -3270,8 +3230,6 @@ qemuMonitorJSONGetMigrationParams(qemuMonitor *mon, ret =3D 0; =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -3512,9 +3470,9 @@ int qemuMonitorJSONGetMigrationStats(qemuMonitor *mon, char **error) { int ret =3D -1; - virJSONValue *cmd =3D qemuMonitorJSONMakeCommand("query-migrate", - NULL); - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("query-migr= ate", + NULL); + g_autoptr(virJSONValue) reply =3D NULL; =20 memset(stats, 0, sizeof(*stats)); =20 @@ -3532,8 +3490,6 @@ int qemuMonitorJSONGetMigrationStats(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -3543,14 +3499,14 @@ int qemuMonitorJSONMigrate(qemuMonitor *mon, const char *uri) { int ret =3D -1; - virJSONValue *cmd =3D + g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("migrate", "b:detach", flags & QEMU_MONITOR_MIGRATE_= BACKGROUND ? 1 : 0, "b:blk", flags & QEMU_MONITOR_MIGRATE_NON= _SHARED_DISK ? 1 : 0, "b:inc", flags & QEMU_MONITOR_MIGRATE_NON= _SHARED_INC ? 1 : 0, "s:uri", uri, NULL); - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 if (!cmd) return -1; @@ -3563,16 +3519,14 @@ int qemuMonitorJSONMigrate(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 int qemuMonitorJSONMigrateCancel(qemuMonitor *mon) { int ret =3D -1; - virJSONValue *cmd =3D qemuMonitorJSONMakeCommand("migrate_cancel", NUL= L); - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("migrate_ca= ncel", NULL); + g_autoptr(virJSONValue) reply =3D NULL; if (!cmd) return -1; =20 @@ -3584,8 +3538,6 @@ int qemuMonitorJSONMigrateCancel(qemuMonitor *mon) =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -3603,8 +3555,8 @@ int qemuMonitorJSONQueryDump(qemuMonitor *mon, qemuMonitorDumpStats *stats) { - virJSONValue *cmd =3D qemuMonitorJSONMakeCommand("query-dump", NULL); - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("query-dump= ", NULL); + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *result =3D NULL; int ret =3D -1; =20 @@ -3622,8 +3574,6 @@ qemuMonitorJSONQueryDump(qemuMonitor *mon, ret =3D qemuMonitorJSONExtractDumpStats(result, stats); =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -3633,8 +3583,8 @@ qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMonit= or *mon, const char *capability) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *caps; virJSONValue *formats; size_t i; @@ -3674,8 +3624,6 @@ qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMonit= or *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -3686,8 +3634,8 @@ qemuMonitorJSONDump(qemuMonitor *mon, bool detach) { int ret =3D -1; - virJSONValue *cmd =3D NULL; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 cmd =3D qemuMonitorJSONMakeCommand("dump-guest-memory", "b:paging", false, @@ -3706,8 +3654,6 @@ qemuMonitorJSONDump(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -3719,15 +3665,16 @@ int qemuMonitorJSONGraphicsRelocate(qemuMonitor *mo= n, const char *tlsSubject) { int ret =3D -1; - virJSONValue *cmd =3D qemuMonitorJSONMakeCommand("client_migrate_info", - "s:protocol", - (type =3D=3D VIR_DOMA= IN_GRAPHICS_TYPE_SPICE ? "spice" : "vnc"), - "s:hostname", hostnam= e, - "i:port", port, - "i:tls-port", tlsPort, - "S:cert-subject", tls= Subject, - NULL); - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("client_mig= rate_info", + "s:protocol", + (type =3D=3D = VIR_DOMAIN_GRAPHICS_TYPE_SPICE ? "spice" : "vnc"), + "s:hostname",= hostname, + "i:port", por= t, + "i:tls-port",= tlsPort, + "S:cert-subje= ct", tlsSubject, + NULL); + g_autoptr(virJSONValue) reply =3D NULL; + if (!cmd) return -1; =20 @@ -3739,8 +3686,6 @@ int qemuMonitorJSONGraphicsRelocate(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -3925,10 +3870,11 @@ int qemuMonitorJSONSendFileHandle(qemuMonitor *mon, int fd) { int ret =3D -1; - virJSONValue *cmd =3D qemuMonitorJSONMakeCommand("getfd", - "s:fdname", fdname, - NULL); - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("getfd", + "s:fdname", f= dname, + NULL); + g_autoptr(virJSONValue) reply =3D NULL; + if (!cmd) return -1; =20 @@ -3940,8 +3886,6 @@ int qemuMonitorJSONSendFileHandle(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -3950,10 +3894,11 @@ int qemuMonitorJSONCloseFileHandle(qemuMonitor *mon, const char *fdname) { int ret =3D -1; - virJSONValue *cmd =3D qemuMonitorJSONMakeCommand("closefd", - "s:fdname", fdname, - NULL); - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("closefd", + "s:fdname", f= dname, + NULL); + g_autoptr(virJSONValue) reply =3D NULL; + if (!cmd) return -1; =20 @@ -3965,8 +3910,6 @@ int qemuMonitorJSONCloseFileHandle(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -4189,10 +4132,10 @@ qemuMonitorJSONQueryRxFilter(qemuMonitor *mon, cons= t char *alias, virNetDevRxFilter **filter) { int ret =3D -1; - virJSONValue *cmd =3D qemuMonitorJSONMakeCommand("query-rx-filter", - "s:name", alias, - NULL); - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("query-rx-f= ilter", + "s:name", ali= as, + NULL); + g_autoptr(virJSONValue) reply =3D NULL; =20 if (!cmd) goto cleanup; @@ -4208,8 +4151,6 @@ qemuMonitorJSONQueryRxFilter(qemuMonitor *mon, const = char *alias, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -4298,9 +4239,9 @@ qemuMonitorJSONGetChardevInfo(qemuMonitor *mon, =20 { int ret =3D -1; - virJSONValue *cmd =3D qemuMonitorJSONMakeCommand("query-chardev", - NULL); - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("query-char= dev", + NULL); + g_autoptr(virJSONValue) reply =3D NULL; =20 if (!cmd) return -1; @@ -4313,8 +4254,6 @@ qemuMonitorJSONGetChardevInfo(qemuMonitor *mon, =20 ret =3D qemuMonitorJSONExtractChardevInfo(reply, info); cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -4323,8 +4262,8 @@ int qemuMonitorJSONDelDevice(qemuMonitor *mon, const char *devalias) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 cmd =3D qemuMonitorJSONMakeCommand("device_del", "s:id", devalias, @@ -4345,8 +4284,6 @@ int qemuMonitorJSONDelDevice(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -4494,8 +4431,8 @@ int qemuMonitorJSONTransaction(qemuMonitor *mon, virJSONValue **actions) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 cmd =3D qemuMonitorJSONMakeCommand("transaction", "a:actions", actions, @@ -4511,8 +4448,6 @@ qemuMonitorJSONTransaction(qemuMonitor *mon, virJSONV= alue **actions) =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -4532,8 +4467,8 @@ qemuMonitorJSONBlockCommit(qemuMonitor *mon, unsigned long long speed) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virTristateBool autofinalize =3D VIR_TRISTATE_BOOL_ABSENT; virTristateBool autodismiss =3D VIR_TRISTATE_BOOL_ABSENT; =20 @@ -4565,8 +4500,6 @@ qemuMonitorJSONBlockCommit(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -4611,7 +4544,7 @@ qemuMonitorJSONDiskNameLookup(qemuMonitor *mon, virStorageSource *target) { char *ret =3D NULL; - virJSONValue *devices; + g_autoptr(virJSONValue) devices =3D NULL; size_t i; =20 if (!(devices =3D qemuMonitorJSONQueryBlock(mon))) @@ -4645,8 +4578,6 @@ qemuMonitorJSONDiskNameLookup(qemuMonitor *mon, device); =20 cleanup: - virJSONValueFree(devices); - return ret; } =20 @@ -4655,8 +4586,8 @@ int qemuMonitorJSONArbitraryCommand(qemuMonitor *mon, const char *cmd_str, char **reply_str) { - virJSONValue *cmd =3D NULL; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; int ret =3D -1; =20 if (!(cmd =3D virJSONValueFromString(cmd_str))) @@ -4671,16 +4602,14 @@ int qemuMonitorJSONArbitraryCommand(qemuMonitor *mo= n, ret =3D 0; =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 int qemuMonitorJSONInjectNMI(qemuMonitor *mon) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 cmd =3D qemuMonitorJSONMakeCommand("inject-nmi", NULL); if (!cmd) @@ -4694,8 +4623,6 @@ int qemuMonitorJSONInjectNMI(qemuMonitor *mon) =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -4705,16 +4632,17 @@ int qemuMonitorJSONSendKey(qemuMonitor *mon, unsigned int nkeycodes) { int ret =3D -1; - virJSONValue *cmd =3D NULL; - virJSONValue *reply =3D NULL; - virJSONValue *keys =3D NULL; - virJSONValue *key =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; + g_autoptr(virJSONValue) keys =3D NULL; size_t i; =20 /* create the key data array */ keys =3D virJSONValueNewArray(); =20 for (i =3D 0; i < nkeycodes; i++) { + g_autoptr(virJSONValue) key =3D NULL; + if (keycodes[i] > 0xffff) { virReportError(VIR_ERR_OPERATION_FAILED, _("keycode %zu is invalid: 0x%X"), i, keycodes[= i]); @@ -4751,10 +4679,6 @@ int qemuMonitorJSONSendKey(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - virJSONValueFree(keys); - virJSONValueFree(key); return ret; } =20 @@ -4764,8 +4688,8 @@ int qemuMonitorJSONScreendump(qemuMonitor *mon, const char *file) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 cmd =3D qemuMonitorJSONMakeCommand("screendump", "s:filename", file, @@ -4784,8 +4708,6 @@ int qemuMonitorJSONScreendump(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -4925,8 +4847,8 @@ qemuMonitorJSONBlockStream(qemuMonitor *mon, unsigned long long speed) { int ret =3D -1; - virJSONValue *cmd =3D NULL; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virTristateBool autofinalize =3D VIR_TRISTATE_BOOL_ABSENT; virTristateBool autodismiss =3D VIR_TRISTATE_BOOL_ABSENT; =20 @@ -4956,8 +4878,6 @@ qemuMonitorJSONBlockStream(qemuMonitor *mon, ret =3D 0; =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -4992,8 +4912,8 @@ qemuMonitorJSONBlockJobSetSpeed(qemuMonitor *mon, unsigned long long speed) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("block-job-set-speed", "s:device", jobname, @@ -5010,8 +4930,6 @@ qemuMonitorJSONBlockJobSetSpeed(qemuMonitor *mon, ret =3D 0; =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -5021,8 +4939,8 @@ qemuMonitorJSONDrivePivot(qemuMonitor *mon, const char *jobname) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 cmd =3D qemuMonitorJSONMakeCommand("block-job-complete", "s:device", jobname, @@ -5038,8 +4956,6 @@ qemuMonitorJSONDrivePivot(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -5094,8 +5010,8 @@ int qemuMonitorJSONOpenGraphics(qemuMonitor *mon, bool skipauth) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 cmd =3D qemuMonitorJSONMakeCommand("add_client", "s:protocol", protocol, @@ -5114,8 +5030,6 @@ int qemuMonitorJSONOpenGraphics(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -5266,21 +5180,20 @@ int qemuMonitorJSONGetBlockIoThrottle(qemuMonitor *= mon, virDomainBlockIoTuneInfo *reply) { int ret =3D -1; - virJSONValue *devices =3D NULL; + g_autoptr(virJSONValue) devices =3D NULL; =20 if (!(devices =3D qemuMonitorJSONQueryBlock(mon))) return -1; =20 ret =3D qemuMonitorJSONBlockIoThrottleInfo(devices, drivealias, qdevid= , reply); - virJSONValueFree(devices); return ret; } =20 int qemuMonitorJSONSystemWakeup(qemuMonitor *mon) { int ret =3D -1; - virJSONValue *cmd =3D NULL; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 cmd =3D qemuMonitorJSONMakeCommand("system_wakeup", NULL); if (!cmd) @@ -5294,8 +5207,6 @@ int qemuMonitorJSONSystemWakeup(qemuMonitor *mon) =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -5306,8 +5217,8 @@ int qemuMonitorJSONGetVersion(qemuMonitor *mon, char **package) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data; virJSONValue *qemu; =20 @@ -5361,8 +5272,6 @@ int qemuMonitorJSONGetVersion(qemuMonitor *mon, ret =3D 0; =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -5371,8 +5280,8 @@ int qemuMonitorJSONGetMachines(qemuMonitor *mon, qemuMonitorMachineInfo ***machines) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data; qemuMonitorMachineInfo **infolist =3D NULL; size_t n =3D 0; @@ -5484,8 +5393,6 @@ int qemuMonitorJSONGetMachines(qemuMonitor *mon, qemuMonitorMachineInfoFree(infolist[i]); VIR_FREE(infolist); } - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -5615,15 +5522,14 @@ static virJSONValue * qemuMonitorJSONMakeCPUModel(virCPUDef *cpu, bool migratable) { - virJSONValue *model =3D virJSONValueNewObject(); - virJSONValue *props =3D NULL; + g_autoptr(virJSONValue) model =3D virJSONValueNewObject(); size_t i; =20 if (virJSONValueObjectAppendString(model, "name", cpu->model) < 0) goto error; =20 if (cpu->nfeatures || !migratable) { - props =3D virJSONValueNewObject(); + g_autoptr(virJSONValue) props =3D virJSONValueNewObject(); =20 for (i =3D 0; i < cpu->nfeatures; i++) { char *name =3D cpu->features[i].name; @@ -5648,11 +5554,9 @@ qemuMonitorJSONMakeCPUModel(virCPUDef *cpu, goto error; } =20 - return model; + return g_steal_pointer(&model); =20 error: - virJSONValueFree(model); - virJSONValueFree(props); return NULL; } =20 @@ -5978,8 +5882,8 @@ int qemuMonitorJSONGetKVMState(qemuMonitor *mon, bool *present) { int ret =3D -1; - virJSONValue *cmd =3D NULL; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data =3D NULL; =20 /* Safe defaults */ @@ -6006,8 +5910,6 @@ int qemuMonitorJSONGetKVMState(qemuMonitor *mon, ret =3D 0; =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -6063,8 +5965,8 @@ int qemuMonitorJSONGetObjectListPaths(qemuMonitor *mo= n, qemuMonitorJSONListPath ***paths) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data; qemuMonitorJSONListPath **pathlist =3D NULL; size_t n =3D 0; @@ -6125,8 +6027,6 @@ int qemuMonitorJSONGetObjectListPaths(qemuMonitor *mo= n, qemuMonitorJSONListPathFree(pathlist[i]); VIR_FREE(pathlist); } - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -6146,8 +6046,8 @@ int qemuMonitorJSONGetObjectProperty(qemuMonitor *mon, qemuMonitorJSONObjectProperty *prop) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data; const char *tmp; =20 @@ -6210,9 +6110,6 @@ int qemuMonitorJSONGetObjectProperty(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; } =20 @@ -6259,8 +6156,8 @@ int qemuMonitorJSONSetObjectProperty(qemuMonitor *mon, qemuMonitorJSONObjectProperty *prop) { int ret =3D -1; - virJSONValue *cmd =3D NULL; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 switch ((qemuMonitorJSONObjectPropertyType) prop->type) { /* Simple cases of boolean, int, long, uint, ulong, double, and string @@ -6305,9 +6202,6 @@ int qemuMonitorJSONSetObjectProperty(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; } #undef MAKE_SET_CMD @@ -6439,8 +6333,8 @@ qemuMonitorJSONGetTargetArch(qemuMonitor *mon) { char *ret =3D NULL; const char *arch; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("query-target", NULL))) @@ -6463,8 +6357,6 @@ qemuMonitorJSONGetTargetArch(qemuMonitor *mon) ret =3D g_strdup(arch); =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -6563,8 +6455,8 @@ qemuMonitorJSONGetGICCapabilities(qemuMonitor *mon, virGICCapability **capabilities) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *caps; virGICCapability *list =3D NULL; size_t i; @@ -6643,8 +6535,6 @@ qemuMonitorJSONGetGICCapabilities(qemuMonitor *mon, =20 cleanup: VIR_FREE(list); - virJSONValueFree(cmd); - virJSONValueFree(reply); =20 return ret; } @@ -6669,8 +6559,8 @@ qemuMonitorJSONGetSEVCapabilities(qemuMonitor *mon, virSEVCapability **capabilities) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *caps; const char *pdh =3D NULL; const char *cert_chain =3D NULL; @@ -6738,9 +6628,6 @@ qemuMonitorJSONGetSEVCapabilities(qemuMonitor *mon, *capabilities =3D g_steal_pointer(&capability); ret =3D 1; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; } =20 @@ -6748,38 +6635,34 @@ static virJSONValue * qemuMonitorJSONBuildInetSocketAddress(const char *host, const char *port) { - virJSONValue *addr =3D NULL; - virJSONValue *data =3D NULL; + g_autoptr(virJSONValue) addr =3D NULL; + g_autoptr(virJSONValue) data =3D NULL; =20 if (virJSONValueObjectCreate(&data, "s:host", host, "s:port", port, NULL) < 0) return NULL; =20 if (virJSONValueObjectCreate(&addr, "s:type", "inet", - "a:data", &data, NULL) < 0) { - virJSONValueFree(data); + "a:data", &data, NULL) < 0) return NULL; - } =20 - return addr; + return g_steal_pointer(&addr); } =20 static virJSONValue * qemuMonitorJSONBuildUnixSocketAddress(const char *path) { - virJSONValue *addr =3D NULL; - virJSONValue *data =3D NULL; + g_autoptr(virJSONValue) addr =3D NULL; + g_autoptr(virJSONValue) data =3D NULL; =20 if (virJSONValueObjectCreate(&data, "s:path", path, NULL) < 0) return NULL; =20 if (virJSONValueObjectCreate(&addr, "s:type", "unix", - "a:data", &data, NULL) < 0) { - virJSONValueFree(data); + "a:data", &data, NULL) < 0) return NULL; - } =20 - return addr; + return g_steal_pointer(&addr); } =20 int @@ -6788,9 +6671,9 @@ qemuMonitorJSONNBDServerStart(qemuMonitor *mon, const char *tls_alias) { int ret =3D -1; - virJSONValue *cmd =3D NULL; - virJSONValue *reply =3D NULL; - virJSONValue *addr =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; + g_autoptr(virJSONValue) addr =3D NULL; char *port_str =3D NULL; =20 switch ((virStorageNetHostTransport)server->transport) { @@ -6826,9 +6709,6 @@ qemuMonitorJSONNBDServerStart(qemuMonitor *mon, =20 cleanup: VIR_FREE(port_str); - virJSONValueFree(reply); - virJSONValueFree(cmd); - virJSONValueFree(addr); return ret; } =20 @@ -6840,8 +6720,8 @@ qemuMonitorJSONNBDServerAdd(qemuMonitor *mon, const char *bitmap) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 /* Note: bitmap must be NULL if QEMU_CAPS_NBD_BITMAP is lacking */ if (!(cmd =3D qemuMonitorJSONMakeCommand("nbd-server-add", @@ -6860,8 +6740,6 @@ qemuMonitorJSONNBDServerAdd(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -6869,8 +6747,8 @@ int qemuMonitorJSONNBDServerStop(qemuMonitor *mon) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("nbd-server-stop", NULL))) @@ -6884,8 +6762,6 @@ qemuMonitorJSONNBDServerStop(qemuMonitor *mon) =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -6966,9 +6842,9 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID, const virDomainChrSourceDef *chr) { virJSONValue *ret =3D NULL; - virJSONValue *backend =3D virJSONValueNewObject(); - virJSONValue *data =3D virJSONValueNewObject(); - virJSONValue *addr =3D NULL; + g_autoptr(virJSONValue) backend =3D virJSONValueNewObject(); + g_autoptr(virJSONValue) data =3D virJSONValueNewObject(); + g_autoptr(virJSONValue) addr =3D NULL; const char *backend_type =3D NULL; const char *host; const char *port; @@ -7122,9 +6998,6 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID, =20 cleanup: VIR_FREE(tlsalias); - virJSONValueFree(addr); - virJSONValueFree(data); - virJSONValueFree(backend); return ret; } =20 @@ -7135,8 +7008,8 @@ qemuMonitorJSONAttachCharDev(qemuMonitor *mon, virDomainChrSourceDef *chr) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 if (!(cmd =3D qemuMonitorJSONAttachCharDevCommand(chrID, chr))) return ret; @@ -7168,8 +7041,6 @@ qemuMonitorJSONAttachCharDev(qemuMonitor *mon, ret =3D 0; =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -7178,8 +7049,8 @@ qemuMonitorJSONDetachCharDev(qemuMonitor *mon, const char *chrID) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("chardev-remove", "s:id", chrID, @@ -7194,8 +7065,6 @@ qemuMonitorJSONDetachCharDev(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -7314,8 +7183,8 @@ qemuMonitorJSONGetCPUx86Data(qemuMonitor *mon, const char *property, virCPUData **cpudata) { - virJSONValue *cmd =3D NULL; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data; int ret =3D -1; =20 @@ -7338,8 +7207,6 @@ qemuMonitorJSONGetCPUx86Data(qemuMonitor *mon, ret =3D 0; =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -7351,8 +7218,8 @@ qemuMonitorJSONGetCPUx86Data(qemuMonitor *mon, static int qemuMonitorJSONCheckCPUx86(qemuMonitor *mon) { - virJSONValue *cmd =3D NULL; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data; size_t i; size_t n; @@ -7394,8 +7261,6 @@ qemuMonitorJSONCheckCPUx86(qemuMonitor *mon) ret =3D 1; =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -7580,8 +7445,8 @@ int qemuMonitorJSONRTCResetReinjection(qemuMonitor *mon) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("rtc-reset-reinjection", NULL))) @@ -7595,8 +7460,6 @@ qemuMonitorJSONRTCResetReinjection(qemuMonitor *mon) =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -7612,8 +7475,8 @@ qemuMonitorJSONGetIOThreads(qemuMonitor *mon, int *niothreads) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data; qemuMonitorIOThreadInfo **infolist =3D NULL; size_t n =3D 0; @@ -7696,8 +7559,6 @@ qemuMonitorJSONGetIOThreads(qemuMonitor *mon, VIR_FREE(infolist[i]); VIR_FREE(infolist); } - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -7740,8 +7601,8 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon, GHashTable *info) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data =3D NULL; size_t i; =20 @@ -7841,8 +7702,6 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon, ret =3D 0; =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -8012,8 +7871,8 @@ int qemuMonitorJSONMigrateStartPostCopy(qemuMonitor *mon) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("migrate-start-postcopy", NUL= L))) return -1; @@ -8024,8 +7883,6 @@ qemuMonitorJSONMigrateStartPostCopy(qemuMonitor *mon) ret =3D qemuMonitorJSONCheckError(cmd, reply); =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -8036,8 +7893,8 @@ qemuMonitorJSONMigrateContinue(qemuMonitor *mon, { const char *statusStr =3D qemuMonitorMigrationStatusTypeToString(statu= s); int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("migrate-continue", "s:state", statusStr, @@ -8050,8 +7907,6 @@ qemuMonitorJSONMigrateContinue(qemuMonitor *mon, ret =3D qemuMonitorJSONCheckError(cmd, reply); =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -8061,8 +7916,8 @@ qemuMonitorJSONGetRTCTime(qemuMonitor *mon, struct tm *tm) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("qom-get", @@ -8092,8 +7947,6 @@ qemuMonitorJSONGetRTCTime(qemuMonitor *mon, =20 ret =3D 0; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -8228,8 +8081,8 @@ qemuMonitorJSONGetHotpluggableCPUs(qemuMonitor *mon, int ret =3D -1; size_t i; virJSONValue *data; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *vcpu; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("query-hotpluggable-cpus", NU= LL))) @@ -8261,8 +8114,6 @@ qemuMonitorJSONGetHotpluggableCPUs(qemuMonitor *mon, =20 cleanup: qemuMonitorQueryHotpluggableCpusFree(info, ninfo); - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -8270,8 +8121,8 @@ qemuMonitorJSONGetHotpluggableCPUs(qemuMonitor *mon, virJSONValue * qemuMonitorJSONQueryQMPSchema(qemuMonitor *mon) { - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *ret =3D NULL; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("query-qmp-schema", NULL))) @@ -8286,9 +8137,6 @@ qemuMonitorJSONQueryQMPSchema(qemuMonitor *mon) ret =3D virJSONValueObjectStealArray(reply, "return"); =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; } =20 @@ -8298,8 +8146,8 @@ qemuMonitorJSONSetBlockThreshold(qemuMonitor *mon, const char *nodename, unsigned long long threshold) { - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; int ret =3D -1; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("block-set-write-threshold", @@ -8317,9 +8165,6 @@ qemuMonitorJSONSetBlockThreshold(qemuMonitor *mon, ret =3D 0; =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; } =20 @@ -8461,8 +8306,8 @@ qemuMonitorJSONBlockdevTrayOpen(qemuMonitor *mon, const char *id, bool force) { - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; int ret =3D -1; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("blockdev-open-tray", @@ -8479,8 +8324,6 @@ qemuMonitorJSONBlockdevTrayOpen(qemuMonitor *mon, ret =3D 0; =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -8489,8 +8332,8 @@ int qemuMonitorJSONBlockdevTrayClose(qemuMonitor *mon, const char *id) { - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; int ret =3D -1; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("blockdev-close-tray", @@ -8506,8 +8349,6 @@ qemuMonitorJSONBlockdevTrayClose(qemuMonitor *mon, ret =3D 0; =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -8516,8 +8357,8 @@ int qemuMonitorJSONBlockdevMediumRemove(qemuMonitor *mon, const char *id) { - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; int ret =3D -1; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("blockdev-remove-medium", @@ -8533,8 +8374,6 @@ qemuMonitorJSONBlockdevMediumRemove(qemuMonitor *mon, ret =3D 0; =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -8544,8 +8383,8 @@ qemuMonitorJSONBlockdevMediumInsert(qemuMonitor *mon, const char *id, const char *nodename) { - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; int ret =3D -1; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("blockdev-insert-medium", @@ -8563,8 +8402,6 @@ qemuMonitorJSONBlockdevMediumInsert(qemuMonitor *mon, ret =3D 0; =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 @@ -8584,8 +8421,8 @@ qemuMonitorJSONGetSEVMeasurement(qemuMonitor *mon) { const char *tmp; char *measurement =3D NULL; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("query-sev-launch-measure", N= ULL))) @@ -8605,8 +8442,6 @@ qemuMonitorJSONGetSEVMeasurement(qemuMonitor *mon) measurement =3D g_strdup(tmp); =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return measurement; } =20 @@ -8666,8 +8501,8 @@ qemuMonitorJSONGetPRManagerInfo(qemuMonitor *mon, GHashTable *info) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("query-pr-managers", NULL))) @@ -8681,8 +8516,6 @@ qemuMonitorJSONGetPRManagerInfo(qemuMonitor *mon, =20 ret =3D qemuMonitorJSONExtractPRManagerInfo(reply, info); cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; =20 } @@ -8716,8 +8549,8 @@ qemuMonitorJSONGetCurrentMachineInfo(qemuMonitor *mon, qemuMonitorCurrentMachineInfo *info) { int ret =3D -1; - virJSONValue *cmd; - virJSONValue *reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("query-current-machine", NULL))) @@ -8732,8 +8565,6 @@ qemuMonitorJSONGetCurrentMachineInfo(qemuMonitor *mon, ret =3D qemuMonitorJSONExtractCurrentMachineInfo(reply, info); =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); return ret; } =20 --=20 2.32.0 From nobody Fri May 3 11:16:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1635159503; cv=none; d=zohomail.com; s=zohoarc; b=I2+it+ehJosT0XO19DxRJLu+s0lN2KP90H9+ll3kMCb8fy8jSutDdJr+on7xoZR4a/s6Bj4Cai0oSmXWfM3ujP4ppBovIFnP3NngwnD13JwguGkkfXxU9ZMgUDVWwBo9XrNeVkAupYoXhzkY4DuY7khy16LDhmI+mb3/YdTLR5w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635159503; 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=HK0JUlB0czU74TCMVyEezUzm7/90cgZH/uixdLIAV+0=; b=c/donX27P27JC70EAqRt+OJBZn13hFTWwlOIO2dJ/ta8JjtBAu6IGkZAiYPTdlGBzcTVNH63LjIXX609PcSpCiHKBNd/SQUf/BkZgFgVokSBAizkBBVfKZ0otSAnROHLDhqRBedy0LujQZ253XwOqRH6uq6dxA8g8iHkFqrWFds= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1635159503309101.68379958273931; Mon, 25 Oct 2021 03:58:23 -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-58-8c_LdZlVPcGD4y941wjn7w-1; Mon, 25 Oct 2021 06:58:20 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 89BD8A0CB7; Mon, 25 Oct 2021 10:58:15 +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 6413A16A33; Mon, 25 Oct 2021 10:58:15 +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 0514C1832DF5; Mon, 25 Oct 2021 10:58:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19PAvxss016917 for ; Mon, 25 Oct 2021 06:57:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3AE12ADF9; Mon, 25 Oct 2021 10:57:59 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6BF75DAA5 for ; Mon, 25 Oct 2021 10:57:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635159502; 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=HK0JUlB0czU74TCMVyEezUzm7/90cgZH/uixdLIAV+0=; b=hRAwVlkg2B/VzAmbBe8A+Hn9Mm5gVt1/jVqHMBVEatx6TJTX/FyzvqweuKQisHr++pqaLA gtJ/aRTpdWhfWVDDfUciBPNP6Tq8WaKrLcgHOL9Q3efqhWQrtKE9MLOeytnXkIAWxqekEj 7Li0DzYMayZ+e+Dr/0bkbJ30EQ4TveA= X-MC-Unique: 8c_LdZlVPcGD4y941wjn7w-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 11/13] qemu_monitor_json: Use g_autofree Date: Mon, 25 Oct 2021 12:57:35 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.23 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: 1635159504906100005 Content-Type: text/plain; charset="utf-8" Let's replace VIR_FREE() calls with g_autofree. Not all calls can be replaced though - the legitimate ones are kept (e.g. those which free array, or which free a struct for which we don't have g_autoptr() yet, and so on). Signed-off-by: Michal Privoznik Reviewed-by: Tim Wiederhake --- src/qemu/qemu_monitor_json.c | 37 +++++++++++------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 1eb0b3b54c..cd4a37a685 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -175,7 +175,7 @@ qemuMonitorJSONIOProcessEvent(qemuMonitor *mon, const char *type; qemuEventHandler *handler; virJSONValue *data; - char *details =3D NULL; + g_autofree char *details =3D NULL; virJSONValue *timestamp; long long seconds =3D -1; unsigned int micros =3D 0; @@ -199,7 +199,6 @@ qemuMonitorJSONIOProcessEvent(qemuMonitor *mon, µs)); } qemuMonitorEmitEvent(mon, type, seconds, micros, details); - VIR_FREE(details); =20 handler =3D bsearch(type, eventHandlers, G_N_ELEMENTS(eventHandlers), sizeof(eventHandlers[0]), qemuMonitorEventCompare); @@ -270,16 +269,12 @@ int qemuMonitorJSONIOProcess(qemuMonitor *mon, =20 if (nl) { int got =3D nl - (data + used); - char *line; - line =3D g_strndup(data + used, got); + g_autofree char *line =3D g_strndup(data + used, got); + used +=3D got + strlen(LINE_ENDING); line[got] =3D '\0'; /* kill \n */ - if (qemuMonitorJSONIOProcessLine(mon, line, msg) < 0) { - VIR_FREE(line); + if (qemuMonitorJSONIOProcessLine(mon, line, msg) < 0) return -1; - } - - VIR_FREE(line); } else { break; } @@ -6458,7 +6453,7 @@ qemuMonitorJSONGetGICCapabilities(qemuMonitor *mon, g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *caps; - virGICCapability *list =3D NULL; + g_autofree virGICCapability *list =3D NULL; size_t i; size_t n; =20 @@ -6534,8 +6529,6 @@ qemuMonitorJSONGetGICCapabilities(qemuMonitor *mon, *capabilities =3D g_steal_pointer(&list); =20 cleanup: - VIR_FREE(list); - return ret; } =20 @@ -6674,7 +6667,7 @@ qemuMonitorJSONNBDServerStart(qemuMonitor *mon, g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; g_autoptr(virJSONValue) addr =3D NULL; - char *port_str =3D NULL; + g_autofree char *port_str =3D NULL; =20 switch ((virStorageNetHostTransport)server->transport) { case VIR_STORAGE_NET_HOST_TRANS_TCP: @@ -6708,7 +6701,6 @@ qemuMonitorJSONNBDServerStart(qemuMonitor *mon, ret =3D 0; =20 cleanup: - VIR_FREE(port_str); return ret; } =20 @@ -6848,7 +6840,7 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID, const char *backend_type =3D NULL; const char *host; const char *port; - char *tlsalias =3D NULL; + g_autofree char *tlsalias =3D NULL; bool telnet; =20 switch ((virDomainChrType)chr->type) { @@ -6997,7 +6989,6 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID, goto cleanup; =20 cleanup: - VIR_FREE(tlsalias); return ret; } =20 @@ -7568,7 +7559,7 @@ qemuMonitorJSONSetIOThread(qemuMonitor *mon, qemuMonitorIOThreadInfo *iothreadInfo) { int ret =3D -1; - char *path =3D NULL; + g_autofree char *path =3D NULL; qemuMonitorJSONObjectProperty prop; =20 path =3D g_strdup_printf("/objects/iothread%u", iothreadInfo->iothread= _id); @@ -7591,7 +7582,6 @@ qemuMonitorJSONSetIOThread(qemuMonitor *mon, ret =3D 0; =20 cleanup: - VIR_FREE(path); return ret; } =20 @@ -7724,7 +7714,7 @@ qemuMonitorJSONFindObjectPathByAlias(qemuMonitor *mon, char **path) { qemuMonitorJSONListPath **paths =3D NULL; - char *child =3D NULL; + g_autofree char *child =3D NULL; int npaths; int ret =3D -1; size_t i; @@ -7750,7 +7740,6 @@ qemuMonitorJSONFindObjectPathByAlias(qemuMonitor *mon, for (i =3D 0; i < npaths; i++) qemuMonitorJSONListPathFree(paths[i]); VIR_FREE(paths); - VIR_FREE(child); return ret; } =20 @@ -7775,7 +7764,6 @@ qemuMonitorJSONFindObjectPathByName(qemuMonitor *mon, { ssize_t i, npaths =3D 0; int ret =3D -2; - char *nextpath =3D NULL; qemuMonitorJSONListPath **paths =3D NULL; =20 VIR_DEBUG("Searching for '%s' Object Path starting at '%s'", name, cur= path); @@ -7797,10 +7785,9 @@ qemuMonitorJSONFindObjectPathByName(qemuMonitor *mon, * traversed looking for more entries */ if (paths[i]->type && STRPREFIX(paths[i]->type, "child<")) { - nextpath =3D g_strdup_printf("%s/%s", curpath, paths[i]->name); + g_autofree char *nextpath =3D g_strdup_printf("%s/%s", curpath= , paths[i]->name); =20 ret =3D qemuMonitorJSONFindObjectPathByName(mon, nextpath, nam= e, path); - VIR_FREE(nextpath); } } =20 @@ -7808,7 +7795,6 @@ qemuMonitorJSONFindObjectPathByName(qemuMonitor *mon, for (i =3D 0; i < npaths; i++) qemuMonitorJSONListPathFree(paths[i]); VIR_FREE(paths); - VIR_FREE(nextpath); return ret; } =20 @@ -7831,7 +7817,7 @@ qemuMonitorJSONFindLinkPath(qemuMonitor *mon, const char *alias, char **path) { - char *linkname =3D NULL; + g_autofree char *linkname =3D NULL; int ret =3D -1; =20 if (alias) { @@ -7843,7 +7829,6 @@ qemuMonitorJSONFindLinkPath(qemuMonitor *mon, linkname =3D g_strdup_printf("link<%s>", name); =20 ret =3D qemuMonitorJSONFindObjectPathByName(mon, "/", linkname, path); - VIR_FREE(linkname); return ret; } =20 --=20 2.32.0 From nobody Fri May 3 11:16:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1635159544; cv=none; d=zohomail.com; s=zohoarc; b=mwDRQmpzHdNF6vfxgizQziIzW+QV+PylQy6TJeuK/COABAfbTNI+SeOPsLp9FyTYaU6x4ttS5XKoj2I/If77LkVon6dmo3VRojGDyZGoj/BGmkDgrLktjocwba4AtvM+tsHVI7mOcmmzWzONgvZvGpctdkOpzH1Qpt2dPf2WWlc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635159544; 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=FM8cGvPJF9Ky6hOc0YHmB3JGPC/ytVukGkiY78aywmI=; b=AQiybRxA/pL5K759ECxZZngj+YaQjg6WXqItjNQyl9uKKFdkrla8bO9fiAq1UMdsp4zmBV47900uWJoON3BRS56+YY7pDwNs26EI/vxSEQlCRxpPN2oPjZgw0hzpFlz8uSVIgI8hj7ypHeXWodl8JnLdboC8F7eqOY1DMdY9dmo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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 [170.10.129.124]) by mx.zohomail.com with SMTPS id 1635159544958796.1404145298484; Mon, 25 Oct 2021 03:59:04 -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-470-zu742EE6PcqZaQHdsYXANg-1; Mon, 25 Oct 2021 06:58:11 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3A524101B4A3; Mon, 25 Oct 2021 10:58:07 +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 0C6D716A57; Mon, 25 Oct 2021 10:58:07 +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 C57D21832DDE; Mon, 25 Oct 2021 10:58:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19PAw5u5016966 for ; Mon, 25 Oct 2021 06:58:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0DF84ADCD; Mon, 25 Oct 2021 10:58:05 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 120065DAA5 for ; Mon, 25 Oct 2021 10:57:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635159543; 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=FM8cGvPJF9Ky6hOc0YHmB3JGPC/ytVukGkiY78aywmI=; b=eCRDjHygCDtnKrYjb6jTNYSgemcOzN+pEzZszA+/vlCgeFSUttvsPkZW4SLfV7J4QjkeZO O9vUiwQZFLP/OQJADdYlsHtYdJ62hvxpKMnKatbAl5Cd1SlBwrA2gcL18KHFDtWiYsKAJx b3XSdiP/cL2MXEH5vxuGcBKTlCF6poc= X-MC-Unique: zu742EE6PcqZaQHdsYXANg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 12/13] qemu_monitor_json: Drop pointless cleanup labels Date: Mon, 25 Oct 2021 12:57:36 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.23 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: 1635159546287100001 Content-Type: text/plain; charset="utf-8" After previous cleanups, some 'cleanup' labels were rendered needless - they contain nothing more than a return statement. Well, those labels can be dropped and 'goto cleanup' can be replaced with return statement directly. Signed-off-by: Michal Privoznik Reviewed-by: Tim Wiederhake --- src/qemu/qemu_monitor_json.c | 1035 ++++++++++++---------------------- 1 file changed, 368 insertions(+), 667 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index cd4a37a685..bb76ac7d37 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -216,25 +216,24 @@ qemuMonitorJSONIOProcessLine(qemuMonitor *mon, qemuMonitorMessage *msg) { g_autoptr(virJSONValue) obj =3D NULL; - int ret =3D -1; =20 VIR_DEBUG("Line [%s]", line); =20 if (!(obj =3D virJSONValueFromString(line))) - goto cleanup; + return -1; =20 if (virJSONValueGetType(obj) !=3D VIR_JSON_TYPE_OBJECT) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Parsed JSON reply '%s' isn't an object"), line); - goto cleanup; + return -1; } =20 if (virJSONValueObjectHasKey(obj, "QMP") =3D=3D 1) { - ret =3D 0; + return 0; } else if (virJSONValueObjectHasKey(obj, "event") =3D=3D 1) { PROBE(QEMU_MONITOR_RECV_EVENT, "mon=3D%p event=3D%s", mon, line); - ret =3D qemuMonitorJSONIOProcessEvent(mon, obj); + return qemuMonitorJSONIOProcessEvent(mon, obj); } else if (virJSONValueObjectHasKey(obj, "error") =3D=3D 1 || virJSONValueObjectHasKey(obj, "return") =3D=3D 1) { PROBE(QEMU_MONITOR_RECV_REPLY, @@ -242,7 +241,7 @@ qemuMonitorJSONIOProcessLine(qemuMonitor *mon, if (msg) { msg->rxObject =3D g_steal_pointer(&obj); msg->finished =3D 1; - ret =3D 0; + return 0; } else { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unexpected JSON reply '%s'"), line); @@ -252,8 +251,7 @@ qemuMonitorJSONIOProcessLine(qemuMonitor *mon, _("Unknown JSON reply '%s'"), line); } =20 - cleanup: - return ret; + return -1; } =20 int qemuMonitorJSONIOProcess(qemuMonitor *mon, @@ -307,12 +305,12 @@ qemuMonitorJSONCommandWithFd(qemuMonitor *mon, if (virJSONValueObjectAppendString(cmd, "id", id) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unable to append command 'id' string")); - goto cleanup; + return -1; } } =20 if (virJSONValueToBuffer(cmd, &cmdbuf, false) < 0) - goto cleanup; + return -1; virBufferAddLit(&cmdbuf, "\r\n"); =20 msg.txLength =3D virBufferUse(&cmdbuf); @@ -331,7 +329,6 @@ qemuMonitorJSONCommandWithFd(qemuMonitor *mon, } } =20 - cleanup: return ret; } =20 @@ -1455,33 +1452,29 @@ qemuMonitorJSONHumanCommand(qemuMonitor *mon, g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *obj; const char *data; - int ret =3D -1; =20 cmd =3D qemuMonitorJSONMakeCommand("human-monitor-command", "s:command-line", cmd_str, NULL); =20 if (!cmd || qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONHasError(reply, "CommandNotFound")) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("Human monitor command is not available to run %s= "), cmd_str); - goto cleanup; + return -1; } =20 if (qemuMonitorJSONCheckError(cmd, reply)) - goto cleanup; + return -1; =20 obj =3D virJSONValueObjectGet(reply, "return"); data =3D virJSONValueGetString(obj); *reply_str =3D g_strdup(NULLSTR_EMPTY(data)); =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -1542,7 +1535,6 @@ qemuMonitorJSONStartCPUs(qemuMonitor *mon) int qemuMonitorJSONStopCPUs(qemuMonitor *mon) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("stop", NUL= L); g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -1550,14 +1542,12 @@ qemuMonitorJSONStopCPUs(qemuMonitor *mon) return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -1604,7 +1594,6 @@ qemuMonitorJSONGetStatus(qemuMonitor *mon, =20 int qemuMonitorJSONSystemPowerdown(qemuMonitor *mon) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("system_pow= erdown", NULL); g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -1612,21 +1601,18 @@ int qemuMonitorJSONSystemPowerdown(qemuMonitor *mon) return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 int qemuMonitorJSONSetLink(qemuMonitor *mon, const char *name, virDomainNetInterfaceLinkState state) { - int ret =3D -1; g_autoptr(virJSONValue) reply =3D NULL; g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("set_link", "s:name", nam= e, @@ -1637,19 +1623,16 @@ int qemuMonitorJSONSetLink(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 int qemuMonitorJSONSystemReset(qemuMonitor *mon) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("system_res= et", NULL); g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -1657,14 +1640,12 @@ int qemuMonitorJSONSystemReset(qemuMonitor *mon) return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -1840,7 +1821,6 @@ qemuMonitorJSONQueryCPUs(qemuMonitor *mon, bool force, bool fast) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data; @@ -1854,20 +1834,15 @@ qemuMonitorJSONQueryCPUs(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (force && qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - if (!(data =3D virJSONValueObjectGetArray(reply, "return"))) { - ret =3D -2; - goto cleanup; - } + if (!(data =3D virJSONValueObjectGetArray(reply, "return"))) + return -2; =20 - ret =3D qemuMonitorJSONExtractCPUInfo(data, entries, nentries, fast); - - cleanup: - return ret; + return qemuMonitorJSONExtractCPUInfo(data, entries, nentries, fast); } =20 =20 @@ -1987,7 +1962,6 @@ int qemuMonitorJSONGetBalloonInfo(qemuMonitor *mon, unsigned long long *currmem) { - int ret =3D -1; virJSONValue *data; unsigned long long mem; g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("query-ball= oon", @@ -2000,31 +1974,28 @@ qemuMonitorJSONGetBalloonInfo(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 /* See if balloon soft-failed */ if (qemuMonitorJSONHasError(reply, "DeviceNotActive") || qemuMonitorJSONHasError(reply, "KVMMissingCap")) { - ret =3D 0; - goto cleanup; + return 0; } =20 /* See if any other fatal error occurred */ if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) - goto cleanup; + return -1; =20 data =3D virJSONValueObjectGetObject(reply, "return"); =20 if (virJSONValueObjectGetNumberUlong(data, "actual", &mem) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("info balloon reply was missing balloon data")); - goto cleanup; + return -1; } =20 *currmem =3D (mem/1024); - ret =3D 1; - cleanup: - return ret; + return 1; } =20 =20 @@ -2200,19 +2171,15 @@ qemuMonitorJSONQueryBlock(qemuMonitor *mon) { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; - virJSONValue *devices =3D NULL; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("query-block", NULL))) return NULL; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0 || qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) - goto cleanup; + return NULL; =20 - devices =3D virJSONValueObjectStealArray(reply, "return"); - - cleanup: - return devices; + return virJSONValueObjectStealArray(reply, "return"); } =20 =20 @@ -2279,7 +2246,6 @@ qemuMonitorJSONBlockInfoAdd(GHashTable *table, int qemuMonitorJSONGetBlockInfo(qemuMonitor *mon, GHashTable *table) { - int ret =3D -1; size_t i; g_autoptr(virJSONValue) devices =3D NULL; =20 @@ -2295,10 +2261,10 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitor *mon, const char *qdev; =20 if (!(dev =3D qemuMonitorJSONGetBlockDev(devices, i))) - goto cleanup; + return -1; =20 if (!(thisdev =3D qemuMonitorJSONGetBlockDevDevice(dev))) - goto cleanup; + return -1; =20 thisdev =3D qemuAliasDiskDriveSkipPrefix(thisdev); qdev =3D virJSONValueObjectGetString(dev, "qdev"); @@ -2309,14 +2275,14 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitor *mon, if (!qdev && !thisdev) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("query-block device entry was not in expected= format")); - goto cleanup; + return -1; } =20 if (virJSONValueObjectGetBoolean(dev, "removable", &info.removable= ) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot read %s value"), "removable"); - goto cleanup; + return -1; } =20 /* 'tray_open' is present only if the device has a tray */ @@ -2334,21 +2300,19 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitor *mon, if ((status =3D virJSONValueObjectGetString(dev, "io-status"))) { info.io_status =3D qemuMonitorBlockIOStatusToError(status); if (info.io_status < 0) - goto cleanup; + return -1; } =20 if (thisdev && qemuMonitorJSONBlockInfoAdd(table, &info, thisdev) < 0) - goto cleanup; + return -1; =20 if (qdev && STRNEQ_NULLABLE(thisdev, qdev) && qemuMonitorJSONBlockInfoAdd(table, &info, qdev) < 0) - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -2661,7 +2625,6 @@ qemuMonitorJSONBlockStatsUpdateCapacityBlockdev(qemuM= onitor *mon, GHashTable *stats) { g_autoptr(virJSONValue) nodes =3D NULL; - int ret =3D -1; =20 if (!(nodes =3D qemuMonitorJSONQueryNamedBlockNodes(mon, false))) return -1; @@ -2669,12 +2632,9 @@ qemuMonitorJSONBlockStatsUpdateCapacityBlockdev(qemu= Monitor *mon, if (virJSONValueArrayForeachSteal(nodes, qemuMonitorJSONBlockStatsUpdateCapac= ityBlockdevWorker, stats) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -2845,7 +2805,6 @@ int qemuMonitorJSONBlockResize(qemuMonitor *mon, const char *nodename, unsigned long long size) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -2858,14 +2817,12 @@ int qemuMonitorJSONBlockResize(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -2874,7 +2831,6 @@ int qemuMonitorJSONSetPassword(qemuMonitor *mon, const char *password, const char *action_if_connected) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("set_passwo= rd", "s:protocol",= protocol, "s:password",= password, @@ -2886,21 +2842,18 @@ int qemuMonitorJSONSetPassword(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 int qemuMonitorJSONExpirePassword(qemuMonitor *mon, const char *protocol, const char *expire_time) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("expire_pas= sword", "s:protocol",= protocol, "s:time", exp= ire_time, @@ -2911,14 +2864,12 @@ int qemuMonitorJSONExpirePassword(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -2926,7 +2877,6 @@ int qemuMonitorJSONSetBalloon(qemuMonitor *mon, unsigned long long newmem) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("balloon", "U:value", ne= wmem * 1024, NULL); @@ -2936,30 +2886,26 @@ qemuMonitorJSONSetBalloon(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 /* See if balloon soft-failed */ if (qemuMonitorJSONHasError(reply, "DeviceNotActive") || qemuMonitorJSONHasError(reply, "KVMMissingCap")) { - ret =3D 0; - goto cleanup; + return 0; } =20 /* See if any other fatal error occurred */ if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 /* Real success */ - ret =3D 1; - cleanup: - return ret; + return 1; } =20 =20 int qemuMonitorJSONSetCPU(qemuMonitor *mon, int cpu, bool online) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -2970,18 +2916,15 @@ int qemuMonitorJSONSetCPU(qemuMonitor *mon, } else { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("vCPU unplug is not supported by this QEMU")); - goto cleanup; + return -1; } if (!cmd) - goto cleanup; + return -1; =20 - if ((ret =3D qemuMonitorJSONCommand(mon, cmd, &reply)) < 0) - goto cleanup; + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + return -1; =20 - ret =3D qemuMonitorJSONCheckError(cmd, reply); - - cleanup: - return ret; + return qemuMonitorJSONCheckError(cmd, reply); } =20 =20 @@ -2996,7 +2939,6 @@ int qemuMonitorJSONEjectMedia(qemuMonitor *mon, const char *dev_name, bool force) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("eject", "s:device", d= ev_name, "b:force", fo= rce ? 1 : 0, @@ -3007,14 +2949,12 @@ int qemuMonitorJSONEjectMedia(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -3023,7 +2963,6 @@ int qemuMonitorJSONChangeMedia(qemuMonitor *mon, const char *newmedia, const char *format) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -3037,14 +2976,12 @@ int qemuMonitorJSONChangeMedia(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -3054,7 +2991,6 @@ static int qemuMonitorJSONSaveMemory(qemuMonitor *mon, unsigned long long length, const char *path) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand(cmdtype, "U:val", offs= et, "U:size", len= gth, @@ -3066,14 +3002,12 @@ static int qemuMonitorJSONSaveMemory(qemuMonitor *m= on, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -3097,7 +3031,6 @@ int qemuMonitorJSONSavePhysicalMemory(qemuMonitor *mo= n, int qemuMonitorJSONSetMigrationSpeed(qemuMonitor *mon, unsigned long bandwidth) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -3108,21 +3041,18 @@ int qemuMonitorJSONSetMigrationSpeed(qemuMonitor *m= on, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 int qemuMonitorJSONSetMigrationDowntime(qemuMonitor *mon, unsigned long long downtime) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -3133,14 +3063,12 @@ int qemuMonitorJSONSetMigrationDowntime(qemuMonitor= *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -3148,7 +3076,6 @@ int qemuMonitorJSONGetMigrationCacheSize(qemuMonitor *mon, unsigned long long *cacheSize) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -3159,20 +3086,18 @@ qemuMonitorJSONGetMigrationCacheSize(qemuMonitor *m= on, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_NUMBER) < 0) - goto cleanup; + return -1; =20 if (virJSONValueObjectGetNumberUlong(reply, "return", cacheSize) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("invalid cache size in query-migrate-cache-size r= eply")); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -3180,7 +3105,6 @@ int qemuMonitorJSONSetMigrationCacheSize(qemuMonitor *mon, unsigned long long cacheSize) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -3191,14 +3115,12 @@ qemuMonitorJSONSetMigrationCacheSize(qemuMonitor *m= on, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -3206,7 +3128,6 @@ int qemuMonitorJSONGetMigrationParams(qemuMonitor *mon, virJSONValue **params) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -3216,16 +3137,13 @@ qemuMonitorJSONGetMigrationParams(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) - goto cleanup; + return -1; =20 *params =3D virJSONValueObjectStealObject(reply, "return"); - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 int @@ -3464,7 +3382,6 @@ int qemuMonitorJSONGetMigrationStats(qemuMonitor *mon, qemuMonitorMigrationStats *stats, char **error) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("query-migr= ate", NULL); g_autoptr(virJSONValue) reply =3D NULL; @@ -3475,17 +3392,15 @@ int qemuMonitorJSONGetMigrationStats(qemuMonitor *m= on, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONGetMigrationStatsReply(reply, stats, error) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -3493,7 +3408,6 @@ int qemuMonitorJSONMigrate(qemuMonitor *mon, unsigned int flags, const char *uri) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("migrate", "b:detach", flags & QEMU_MONITOR_MIGRATE_= BACKGROUND ? 1 : 0, @@ -3507,33 +3421,28 @@ int qemuMonitorJSONMigrate(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 int qemuMonitorJSONMigrateCancel(qemuMonitor *mon) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("migrate_ca= ncel", NULL); g_autoptr(virJSONValue) reply =3D NULL; if (!cmd) return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -3553,23 +3462,19 @@ qemuMonitorJSONQueryDump(qemuMonitor *mon, g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("query-dump= ", NULL); g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *result =3D NULL; - int ret =3D -1; =20 if (!cmd) return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) - goto cleanup; + return -1; =20 result =3D virJSONValueObjectGetObject(reply, "return"); =20 - ret =3D qemuMonitorJSONExtractDumpStats(result, stats); - - cleanup: - return ret; + return qemuMonitorJSONExtractDumpStats(result, stats); } =20 =20 @@ -3577,7 +3482,6 @@ int qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMonitor *mon, const char *capability) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *caps; @@ -3589,17 +3493,17 @@ qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMon= itor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) - goto cleanup; + return -1; =20 caps =3D virJSONValueObjectGetObject(reply, "return"); =20 if (!(formats =3D virJSONValueObjectGetArray(caps, "formats"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing supported dump formats")); - goto cleanup; + return -1; } =20 for (i =3D 0; i < virJSONValueArraySize(formats); i++) { @@ -3608,18 +3512,14 @@ qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMon= itor *mon, if (!dumpformat || virJSONValueGetType(dumpformat) !=3D VIR_JSON_T= YPE_STRING) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing entry in supported dump formats")); - goto cleanup; + return -1; } =20 - if (STREQ(virJSONValueGetString(dumpformat), capability)) { - ret =3D 1; - goto cleanup; - } + if (STREQ(virJSONValueGetString(dumpformat), capability)) + return 1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 int @@ -3628,7 +3528,6 @@ qemuMonitorJSONDump(qemuMonitor *mon, const char *dumpformat, bool detach) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -3642,14 +3541,12 @@ qemuMonitorJSONDump(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 int qemuMonitorJSONGraphicsRelocate(qemuMonitor *mon, @@ -3659,7 +3556,6 @@ int qemuMonitorJSONGraphicsRelocate(qemuMonitor *mon, int tlsPort, const char *tlsSubject) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("client_mig= rate_info", "s:protocol", (type =3D=3D = VIR_DOMAIN_GRAPHICS_TYPE_SPICE ? "spice" : "vnc"), @@ -3674,14 +3570,12 @@ int qemuMonitorJSONGraphicsRelocate(qemuMonitor *mo= n, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -3864,7 +3758,6 @@ int qemuMonitorJSONSendFileHandle(qemuMonitor *mon, const char *fdname, int fd) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("getfd", "s:fdname", f= dname, NULL); @@ -3874,21 +3767,18 @@ int qemuMonitorJSONSendFileHandle(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommandWithFd(mon, cmd, fd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 int qemuMonitorJSONCloseFileHandle(qemuMonitor *mon, const char *fdname) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("closefd", "s:fdname", f= dname, NULL); @@ -3898,14 +3788,12 @@ int qemuMonitorJSONCloseFileHandle(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -3955,7 +3843,6 @@ static int qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg, virNetDevRxFilter **filter) { - int ret =3D -1; const char *tmp; virJSONValue *returnArray; virJSONValue *entry; @@ -3966,21 +3853,21 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg, g_autoptr(virNetDevRxFilter) fil =3D virNetDevRxFilterNew(); =20 if (!fil) - goto cleanup; + return -1; =20 returnArray =3D virJSONValueObjectGetArray(msg, "return"); =20 if (!(entry =3D virJSONValueArrayGet(returnArray, 0))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("query -rx-filter return data missing array eleme= nt")); - goto cleanup; + _("query-rx-filter return data missing array elemen= t")); + return -1; } =20 if (!(tmp =3D virJSONValueObjectGetString(entry, "name"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing or invalid name " "in query-rx-filter response")); - goto cleanup; + return -1; } fil->name =3D g_strdup(tmp); if ((!(tmp =3D virJSONValueObjectGetString(entry, "main-mac"))) || @@ -3988,21 +3875,21 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing or invalid 'main-mac' " "in query-rx-filter response")); - goto cleanup; + return -1; } if (virJSONValueObjectGetBoolean(entry, "promiscuous", &fil->promiscuous) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing or invalid 'promiscuous' " "in query-rx-filter response")); - goto cleanup; + return -1; } if (virJSONValueObjectGetBoolean(entry, "broadcast-allowed", &fil->broadcastAllowed) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing or invalid 'broadcast-allowed' " "in query-rx-filter response")); - goto cleanup; + return -1; } =20 if ((!(tmp =3D virJSONValueObjectGetString(entry, "unicast"))) || @@ -4011,21 +3898,21 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing or invalid 'unicast' " "in query-rx-filter response")); - goto cleanup; + return -1; } if (virJSONValueObjectGetBoolean(entry, "unicast-overflow", &fil->unicast.overflow) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing or invalid 'unicast-overflow' " "in query-rx-filter response")); - goto cleanup; + return -1; } if ((!(table =3D virJSONValueObjectGet(entry, "unicast-table"))) || (!virJSONValueIsArray(table))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing or invalid 'unicast-table' array " "in query-rx-filter response")); - goto cleanup; + return -1; } nTable =3D virJSONValueArraySize(table); fil->unicast.table =3D g_new0(virMacAddr, nTable); @@ -4035,13 +3922,13 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg, virReportError(VIR_ERR_INTERNAL_ERROR, _("Missing or invalid element %zu of 'unicast' " "list in query-rx-filter response"), i); - goto cleanup; + return -1; } if (virMacAddrParse(tmp, &fil->unicast.table[i]) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid mac address '%s' in 'unicast-table' " "array in query-rx-filter response"), tmp); - goto cleanup; + return -1; } } fil->unicast.nTable =3D nTable; @@ -4052,21 +3939,21 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing or invalid 'multicast' " "in query-rx-filter response")); - goto cleanup; + return -1; } if (virJSONValueObjectGetBoolean(entry, "multicast-overflow", &fil->multicast.overflow) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing or invalid 'multicast-overflow' " "in query-rx-filter response")); - goto cleanup; + return -1; } if ((!(table =3D virJSONValueObjectGet(entry, "multicast-table"))) || (!virJSONValueIsArray(table))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing or invalid 'multicast-table' array " "in query-rx-filter response")); - goto cleanup; + return -1; } nTable =3D virJSONValueArraySize(table); fil->multicast.table =3D g_new0(virMacAddr, nTable); @@ -4076,13 +3963,13 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg, virReportError(VIR_ERR_INTERNAL_ERROR, _("Missing or invalid element %zu of 'multicast= ' " "list in query-rx-filter response"), i); - goto cleanup; + return -1; } if (virMacAddrParse(tmp, &fil->multicast.table[i]) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid mac address '%s' in 'multicast-table= ' " "array in query-rx-filter response"), tmp); - goto cleanup; + return -1; } } fil->multicast.nTable =3D nTable; @@ -4093,14 +3980,14 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing or invalid 'vlan' " "in query-rx-filter response")); - goto cleanup; + return -1; } if ((!(table =3D virJSONValueObjectGet(entry, "vlan-table"))) || (!virJSONValueIsArray(table))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing or invalid 'vlan-table' array " "in query-rx-filter response")); - goto cleanup; + return -1; } nTable =3D virJSONValueArraySize(table); fil->vlan.table =3D g_new0(unsigned int, nTable); @@ -4110,15 +3997,13 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg, virReportError(VIR_ERR_INTERNAL_ERROR, _("Missing or invalid element %zu of 'vlan-tabl= e' " "array in query-rx-filter response"), i); - goto cleanup; + return -1; } } fil->vlan.nTable =3D nTable; =20 *filter =3D g_steal_pointer(&fil); - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -4126,27 +4011,24 @@ int qemuMonitorJSONQueryRxFilter(qemuMonitor *mon, const char *alias, virNetDevRxFilter **filter) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("query-rx-f= ilter", "s:name", ali= as, NULL); g_autoptr(virJSONValue) reply =3D NULL; =20 if (!cmd) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONQueryRxFilterParse(reply, filter) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -4233,7 +4115,6 @@ qemuMonitorJSONGetChardevInfo(qemuMonitor *mon, GHashTable *info) =20 { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("query-char= dev", NULL); g_autoptr(virJSONValue) reply =3D NULL; @@ -4242,21 +4123,18 @@ qemuMonitorJSONGetChardevInfo(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) - goto cleanup; + return -1; =20 - ret =3D qemuMonitorJSONExtractChardevInfo(reply, info); - cleanup: - return ret; + return qemuMonitorJSONExtractChardevInfo(reply, info); } =20 =20 int qemuMonitorJSONDelDevice(qemuMonitor *mon, const char *devalias) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -4267,19 +4145,15 @@ int qemuMonitorJSONDelDevice(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 - if (qemuMonitorJSONHasError(reply, "DeviceNotFound")) { - ret =3D -2; - goto cleanup; - } + if (qemuMonitorJSONHasError(reply, "DeviceNotFound")) + return -2; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -4425,7 +4299,6 @@ qemuMonitorJSONBlockdevMirror(qemuMonitor *mon, int qemuMonitorJSONTransaction(qemuMonitor *mon, virJSONValue **actions) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -4433,17 +4306,15 @@ qemuMonitorJSONTransaction(qemuMonitor *mon, virJSO= NValue **actions) "a:actions", actions, NULL); if (!cmd) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -4461,7 +4332,6 @@ qemuMonitorJSONBlockCommit(qemuMonitor *mon, const char *backingName, unsigned long long speed) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; virTristateBool autofinalize =3D VIR_TRISTATE_BOOL_ABSENT; @@ -4488,14 +4358,12 @@ qemuMonitorJSONBlockCommit(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -4538,7 +4406,6 @@ qemuMonitorJSONDiskNameLookup(qemuMonitor *mon, virStorageSource *top, virStorageSource *target) { - char *ret =3D NULL; g_autoptr(virJSONValue) devices =3D NULL; size_t i; =20 @@ -4552,28 +4419,27 @@ qemuMonitorJSONDiskNameLookup(qemuMonitor *mon, const char *thisdev; =20 if (!(dev =3D qemuMonitorJSONGetBlockDev(devices, i))) - goto cleanup; + return NULL; =20 if (!(thisdev =3D qemuMonitorJSONGetBlockDevDevice(dev))) - goto cleanup; + return NULL; =20 if (STREQ(thisdev, device)) { if ((inserted =3D virJSONValueObjectGetObject(dev, "inserted")= ) && (image =3D virJSONValueObjectGetObject(inserted, "image"))= ) { - ret =3D qemuMonitorJSONDiskNameLookupOne(image, top, targe= t); + return qemuMonitorJSONDiskNameLookupOne(image, top, target= ); } - break; } } /* Guarantee an error when returning NULL, but don't override a * more specific error if one was already generated. */ - if (!ret && virGetLastErrorCode() =3D=3D VIR_ERR_OK) + if (virGetLastErrorCode() =3D=3D VIR_ERR_OK) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to find backing name for device %s"), device); + } =20 - cleanup: - return ret; + return NULL; } =20 =20 @@ -4583,26 +4449,21 @@ int qemuMonitorJSONArbitraryCommand(qemuMonitor *mo= n, { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; - int ret =3D -1; =20 if (!(cmd =3D virJSONValueFromString(cmd_str))) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (!(*reply_str =3D virJSONValueToString(reply, false))) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 int qemuMonitorJSONInjectNMI(qemuMonitor *mon) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -4611,14 +4472,12 @@ int qemuMonitorJSONInjectNMI(qemuMonitor *mon) return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 int qemuMonitorJSONSendKey(qemuMonitor *mon, @@ -4626,7 +4485,6 @@ int qemuMonitorJSONSendKey(qemuMonitor *mon, unsigned int *keycodes, unsigned int nkeycodes) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; g_autoptr(virJSONValue) keys =3D NULL; @@ -4641,7 +4499,7 @@ int qemuMonitorJSONSendKey(qemuMonitor *mon, if (keycodes[i] > 0xffff) { virReportError(VIR_ERR_OPERATION_FAILED, _("keycode %zu is invalid: 0x%X"), i, keycodes[= i]); - goto cleanup; + return -1; } =20 /* create single key object */ @@ -4649,14 +4507,14 @@ int qemuMonitorJSONSendKey(qemuMonitor *mon, =20 /* Union KeyValue has two types, use the generic one */ if (virJSONValueObjectAppendString(key, "type", "number") < 0) - goto cleanup; + return -1; =20 /* with the keycode */ if (virJSONValueObjectAppendNumberInt(key, "data", keycodes[i]) < = 0) - goto cleanup; + return -1; =20 if (virJSONValueArrayAppend(keys, &key) < 0) - goto cleanup; + return -1; } =20 cmd =3D qemuMonitorJSONMakeCommand("send-key", @@ -4664,17 +4522,15 @@ int qemuMonitorJSONSendKey(qemuMonitor *mon, "p:hold-time", holdtime, NULL); if (!cmd) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 int qemuMonitorJSONScreendump(qemuMonitor *mon, @@ -4682,7 +4538,6 @@ int qemuMonitorJSONScreendump(qemuMonitor *mon, unsigned int head, const char *file) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -4696,14 +4551,12 @@ int qemuMonitorJSONScreendump(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -4841,7 +4694,6 @@ qemuMonitorJSONBlockStream(qemuMonitor *mon, const char *backingName, unsigned long long speed) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; virTristateBool autofinalize =3D VIR_TRISTATE_BOOL_ABSENT; @@ -4865,15 +4717,12 @@ qemuMonitorJSONBlockStream(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -4906,7 +4755,6 @@ qemuMonitorJSONBlockJobSetSpeed(qemuMonitor *mon, const char *jobname, unsigned long long speed) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -4917,15 +4765,12 @@ qemuMonitorJSONBlockJobSetSpeed(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONBlockJobError(cmd, reply, jobname) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -4933,7 +4778,6 @@ int qemuMonitorJSONDrivePivot(qemuMonitor *mon, const char *jobname) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -4944,14 +4788,12 @@ qemuMonitorJSONDrivePivot(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONBlockJobError(cmd, reply, jobname) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -5004,7 +4846,6 @@ int qemuMonitorJSONOpenGraphics(qemuMonitor *mon, const char *fdname, bool skipauth) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -5018,14 +4859,12 @@ int qemuMonitorJSONOpenGraphics(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -5174,19 +5013,16 @@ int qemuMonitorJSONGetBlockIoThrottle(qemuMonitor *= mon, const char *qdevid, virDomainBlockIoTuneInfo *reply) { - int ret =3D -1; g_autoptr(virJSONValue) devices =3D NULL; =20 if (!(devices =3D qemuMonitorJSONQueryBlock(mon))) return -1; =20 - ret =3D qemuMonitorJSONBlockIoThrottleInfo(devices, drivealias, qdevid= , reply); - return ret; + return qemuMonitorJSONBlockIoThrottleInfo(devices, drivealias, qdevid,= reply); } =20 int qemuMonitorJSONSystemWakeup(qemuMonitor *mon) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -5195,14 +5031,12 @@ int qemuMonitorJSONSystemWakeup(qemuMonitor *mon) return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 int qemuMonitorJSONGetVersion(qemuMonitor *mon, @@ -5211,7 +5045,6 @@ int qemuMonitorJSONGetVersion(qemuMonitor *mon, int *micro, char **package) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data; @@ -5225,33 +5058,33 @@ int qemuMonitorJSONGetVersion(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) - goto cleanup; + return -1; =20 data =3D virJSONValueObjectGetObject(reply, "return"); =20 if (!(qemu =3D virJSONValueObjectGetObject(data, "qemu"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("query-version reply was missing 'qemu' data")); - goto cleanup; + return -1; } =20 if (virJSONValueObjectGetNumberInt(qemu, "major", major) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("query-version reply was missing 'major' version"= )); - goto cleanup; + return -1; } if (virJSONValueObjectGetNumberInt(qemu, "minor", minor) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("query-version reply was missing 'minor' version"= )); - goto cleanup; + return -1; } if (virJSONValueObjectGetNumberInt(qemu, "micro", micro) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("query-version reply was missing 'micro' version"= )); - goto cleanup; + return -1; } =20 if (package) { @@ -5259,15 +5092,12 @@ int qemuMonitorJSONGetVersion(qemuMonitor *mon, if (!(tmp =3D virJSONValueObjectGetString(data, "package"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("query-version reply was missing 'package' ve= rsion")); - goto cleanup; + return -1; } *package =3D g_strdup(tmp); } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -5593,7 +5423,6 @@ qemuMonitorJSONParseCPUModel(const char *cpu_name, qemuMonitorCPUModelInfo **model_info) { g_autoptr(qemuMonitorCPUModelInfo) machine_model =3D NULL; - int ret =3D -1; =20 machine_model =3D g_new0(qemuMonitorCPUModelInfo, 1); machine_model->name =3D g_strdup(cpu_name); @@ -5606,14 +5435,11 @@ qemuMonitorJSONParseCPUModel(const char *cpu_name, if (virJSONValueObjectForeachKeyValue(cpu_props, qemuMonitorJSONParseCPUModel= Property, machine_model) < 0) - goto cleanup; + return -1; } =20 *model_info =3D g_steal_pointer(&machine_model); - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -5876,7 +5702,6 @@ int qemuMonitorJSONGetKVMState(qemuMonitor *mon, bool *enabled, bool *present) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data =3D NULL; @@ -5888,10 +5713,10 @@ int qemuMonitorJSONGetKVMState(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) - goto cleanup; + return -1; =20 data =3D virJSONValueObjectGetObject(reply, "return"); =20 @@ -5899,13 +5724,10 @@ int qemuMonitorJSONGetKVMState(qemuMonitor *mon, virJSONValueObjectGetBoolean(data, "present", present) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("query-kvm replied unexpected data")); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -6053,10 +5875,10 @@ int qemuMonitorJSONGetObjectProperty(qemuMonitor *m= on, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 data =3D virJSONValueObjectGet(reply, "return"); =20 @@ -6093,19 +5915,17 @@ int qemuMonitorJSONGetObjectProperty(qemuMonitor *m= on, virReportError(VIR_ERR_INTERNAL_ERROR, _("qom-get invalid object property type %d"), prop->type); - goto cleanup; + return -1; break; } =20 if (ret =3D=3D -1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("qom-get reply was missing return data")); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -6150,7 +5970,6 @@ int qemuMonitorJSONSetObjectProperty(qemuMonitor *mon, const char *property, qemuMonitorJSONObjectProperty *prop) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -6183,21 +6002,19 @@ int qemuMonitorJSONSetObjectProperty(qemuMonitor *m= on, virReportError(VIR_ERR_INTERNAL_ERROR, _("qom-set invalid object property type %d"), prop->type); - goto cleanup; + return -1; =20 } if (!cmd) return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } #undef MAKE_SET_CMD =20 @@ -6326,7 +6143,6 @@ qemuMonitorJSONGetObjectProps(qemuMonitor *mon, char * qemuMonitorJSONGetTargetArch(qemuMonitor *mon) { - char *ret =3D NULL; const char *arch; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; @@ -6336,23 +6152,20 @@ qemuMonitorJSONGetTargetArch(qemuMonitor *mon) return NULL; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return NULL; =20 if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) - goto cleanup; + return NULL; =20 data =3D virJSONValueObjectGetObject(reply, "return"); =20 if (!(arch =3D virJSONValueObjectGetString(data, "arch"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("query-target reply was missing arch data")); - goto cleanup; + return NULL; } =20 - ret =3D g_strdup(arch); - - cleanup: - return ret; + return g_strdup(arch); } =20 =20 @@ -6449,7 +6262,6 @@ int qemuMonitorJSONGetGICCapabilities(qemuMonitor *mon, virGICCapability **capabilities) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *caps; @@ -6464,27 +6276,23 @@ qemuMonitorJSONGetGICCapabilities(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 /* If the 'query-gic-capabilities' QMP command was not available * we simply successfully return zero capabilities. * This is the case for QEMU <2.6 and all non-ARM architectures */ - if (qemuMonitorJSONHasError(reply, "CommandNotFound")) { - ret =3D 0; - goto cleanup; - } + if (qemuMonitorJSONHasError(reply, "CommandNotFound")) + return 0; =20 if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) - goto cleanup; + return -1; =20 caps =3D virJSONValueObjectGetArray(reply, "return"); n =3D virJSONValueArraySize(caps); =20 /* If the returned array was empty we have to return successfully */ - if (n =3D=3D 0) { - ret =3D 0; - goto cleanup; - } + if (n =3D=3D 0) + return 0; =20 list =3D g_new0(virGICCapability, n); =20 @@ -6497,25 +6305,25 @@ qemuMonitorJSONGetGICCapabilities(qemuMonitor *mon, if (!cap || virJSONValueGetType(cap) !=3D VIR_JSON_TYPE_OBJECT) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing entry in GIC capabilities list")); - goto cleanup; + return -1; } =20 if (virJSONValueObjectGetNumberInt(cap, "version", &version) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing GIC version")); - goto cleanup; + return -1; } =20 if (virJSONValueObjectGetBoolean(cap, "kernel", &kernel) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing in-kernel GIC information")); - goto cleanup; + return -1; } =20 if (virJSONValueObjectGetBoolean(cap, "emulated", &emulated) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing emulated GIC information")); - goto cleanup; + return -1; } =20 list[i].version =3D version; @@ -6525,11 +6333,8 @@ qemuMonitorJSONGetGICCapabilities(qemuMonitor *mon, list[i].implementation |=3D VIR_GIC_IMPLEMENTATION_EMULATED; } =20 - ret =3D n; *capabilities =3D g_steal_pointer(&list); - - cleanup: - return ret; + return n; } =20 =20 @@ -6551,7 +6356,6 @@ int qemuMonitorJSONGetSEVCapabilities(qemuMonitor *mon, virSEVCapability **capabilities) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *caps; @@ -6568,16 +6372,14 @@ qemuMonitorJSONGetSEVCapabilities(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 /* QEMU has only compiled-in support of SEV */ - if (qemuMonitorJSONHasError(reply, "GenericError")) { - ret =3D 0; - goto cleanup; - } + if (qemuMonitorJSONHasError(reply, "GenericError")) + return 0; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 caps =3D virJSONValueObjectGetObject(reply, "return"); =20 @@ -6585,7 +6387,7 @@ qemuMonitorJSONGetSEVCapabilities(qemuMonitor *mon, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("query-sev-capabilities reply was missing" " 'cbitpos' field")); - goto cleanup; + return -1; } =20 if (virJSONValueObjectGetNumberUint(caps, "reduced-phys-bits", @@ -6593,21 +6395,21 @@ qemuMonitorJSONGetSEVCapabilities(qemuMonitor *mon, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("query-sev-capabilities reply was missing" " 'reduced-phys-bits' field")); - goto cleanup; + return -1; } =20 if (!(pdh =3D virJSONValueObjectGetString(caps, "pdh"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("query-sev-capabilities reply was missing" " 'pdh' field")); - goto cleanup; + return -1; } =20 if (!(cert_chain =3D virJSONValueObjectGetString(caps, "cert-chain")))= { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("query-sev-capabilities reply was missing" " 'cert-chain' field")); - goto cleanup; + return -1; } =20 capability =3D g_new0(virSEVCapability, 1); @@ -6619,9 +6421,7 @@ qemuMonitorJSONGetSEVCapabilities(qemuMonitor *mon, capability->cbitpos =3D cbitpos; capability->reduced_phys_bits =3D reduced_phys_bits; *capabilities =3D g_steal_pointer(&capability); - ret =3D 1; - cleanup: - return ret; + return 1; } =20 static virJSONValue * @@ -6663,7 +6463,6 @@ qemuMonitorJSONNBDServerStart(qemuMonitor *mon, const virStorageNetHostDef *server, const char *tls_alias) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; g_autoptr(virJSONValue) addr =3D NULL; @@ -6681,27 +6480,24 @@ qemuMonitorJSONNBDServerStart(qemuMonitor *mon, case VIR_STORAGE_NET_HOST_TRANS_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("invalid server address")); - goto cleanup; + return -1; } if (!addr) - goto cleanup; + return -1; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("nbd-server-start", "a:addr", &addr, "S:tls-creds", tls_alias, NULL))) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 int @@ -6711,7 +6507,6 @@ qemuMonitorJSONNBDServerAdd(qemuMonitor *mon, bool writable, const char *bitmap) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -6722,39 +6517,34 @@ qemuMonitorJSONNBDServerAdd(qemuMonitor *mon, "b:writable", writable, "S:bitmap", bitmap, NULL))) - return ret; + return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 int qemuMonitorJSONNBDServerStop(qemuMonitor *mon) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("nbd-server-stop", NULL))) - return ret; + return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -6833,7 +6623,6 @@ static virJSONValue * qemuMonitorJSONAttachCharDevCommand(const char *chrID, const virDomainChrSourceDef *chr) { - virJSONValue *ret =3D NULL; g_autoptr(virJSONValue) backend =3D virJSONValueNewObject(); g_autoptr(virJSONValue) data =3D virJSONValueNewObject(); g_autoptr(virJSONValue) addr =3D NULL; @@ -6859,18 +6648,18 @@ qemuMonitorJSONAttachCharDevCommand(const char *chr= ID, case VIR_DOMAIN_CHR_TYPE_FILE: backend_type =3D "file"; if (virJSONValueObjectAppendString(data, "out", chr->data.file.pat= h) < 0) - goto cleanup; + return NULL; if (virJSONValueObjectAdd(data, "T:append", chr->data.file.append, NULL) < 0) - goto cleanup; + return NULL; break; =20 case VIR_DOMAIN_CHR_TYPE_DEV: backend_type =3D STRPREFIX(chrID, "parallel") ? "parallel" : "seri= al"; if (virJSONValueObjectAppendString(data, "device", chr->data.file.path) < 0) - goto cleanup; + return NULL; break; =20 case VIR_DOMAIN_CHR_TYPE_TCP: @@ -6879,27 +6668,27 @@ qemuMonitorJSONAttachCharDevCommand(const char *chr= ID, chr->data.tcp.service= ); if (!addr || virJSONValueObjectAppend(data, "addr", &addr) < 0) - goto cleanup; + return NULL; =20 telnet =3D chr->data.tcp.protocol =3D=3D VIR_DOMAIN_CHR_TCP_PROTOC= OL_TELNET; =20 if (chr->data.tcp.listen && virJSONValueObjectAppendBoolean(data, "wait", false) < 0) - goto cleanup; + return NULL; =20 if (virJSONValueObjectAppendBoolean(data, "telnet", telnet) < 0 || virJSONValueObjectAppendBoolean(data, "server", chr->data.tcp.= listen) < 0) - goto cleanup; + return NULL; if (chr->data.tcp.tlscreds) { if (!(tlsalias =3D qemuAliasTLSObjFromSrcAlias(chrID))) - goto cleanup; + return NULL; =20 if (virJSONValueObjectAppendString(data, "tls-creds", tlsalias= ) < 0) - goto cleanup; + return NULL; } =20 if (qemuMonitorJSONBuildChrChardevReconnect(data, &chr->data.tcp.r= econnect) < 0) - goto cleanup; + return NULL; break; =20 case VIR_DOMAIN_CHR_TYPE_UDP: @@ -6911,7 +6700,7 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID, chr->data.udp.connect= Service); if (!addr || virJSONValueObjectAppend(data, "remote", &addr) < 0) - goto cleanup; + return NULL; =20 host =3D chr->data.udp.bindHost; port =3D chr->data.udp.bindService; @@ -6923,7 +6712,7 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID, addr =3D qemuMonitorJSONBuildInetSocketAddress(host, port); if (!addr || virJSONValueObjectAppend(data, "local", &addr) < 0) - goto cleanup; + return NULL; } break; =20 @@ -6933,17 +6722,17 @@ qemuMonitorJSONAttachCharDevCommand(const char *chr= ID, =20 if (!addr || virJSONValueObjectAppend(data, "addr", &addr) < 0) - goto cleanup; + return NULL; =20 if (chr->data.nix.listen && virJSONValueObjectAppendBoolean(data, "wait", false) < 0) - goto cleanup; + return NULL; =20 if (virJSONValueObjectAppendBoolean(data, "server", chr->data.nix.= listen) < 0) - goto cleanup; + return NULL; =20 if (qemuMonitorJSONBuildChrChardevReconnect(data, &chr->data.nix.r= econnect) < 0) - goto cleanup; + return NULL; break; =20 case VIR_DOMAIN_CHR_TYPE_SPICEVMC: @@ -6951,7 +6740,7 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID, =20 if (virJSONValueObjectAppendString(data, "type", virDomainChrSpicevmcTypeToStrin= g(chr->data.spicevmc)) < 0) - goto cleanup; + return NULL; break; =20 case VIR_DOMAIN_CHR_TYPE_SPICEPORT: @@ -6968,7 +6757,7 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID, _("Hotplug unsupported for char device type '%d= '"), chr->type); } - goto cleanup; + return NULL; } =20 if (chr->logfile && @@ -6976,20 +6765,16 @@ qemuMonitorJSONAttachCharDevCommand(const char *chr= ID, "s:logfile", chr->logfile, "T:logappend", chr->logappend, NULL) < 0) - goto cleanup; + return NULL; =20 if (virJSONValueObjectAppendString(backend, "type", backend_type) < 0 = || virJSONValueObjectAppend(backend, "data", &data) < 0) - goto cleanup; + return NULL; =20 - if (!(ret =3D qemuMonitorJSONMakeCommand("chardev-add", - "s:id", chrID, - "a:backend", &backend, - NULL))) - goto cleanup; - - cleanup: - return ret; + return qemuMonitorJSONMakeCommand("chardev-add", + "s:id", chrID, + "a:backend", &backend, + NULL); } =20 =20 @@ -6998,22 +6783,21 @@ qemuMonitorJSONAttachCharDev(qemuMonitor *mon, const char *chrID, virDomainChrSourceDef *chr) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 if (!(cmd =3D qemuMonitorJSONAttachCharDevCommand(chrID, chr))) - return ret; + return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (chr->type =3D=3D VIR_DOMAIN_CHR_TYPE_PTY) { if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < = 0) - goto cleanup; + return -1; } else { if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; } =20 if (chr->type =3D=3D VIR_DOMAIN_CHR_TYPE_PTY) { @@ -7023,40 +6807,34 @@ qemuMonitorJSONAttachCharDev(qemuMonitor *mon, if (!(path =3D virJSONValueObjectGetString(data, "pty"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("chardev-add reply was missing pty path")); - goto cleanup; + return -1; } =20 chr->data.file.path =3D g_strdup(path); } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 int qemuMonitorJSONDetachCharDev(qemuMonitor *mon, const char *chrID) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("chardev-remove", "s:id", chrID, NULL))) - return ret; + return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -7177,28 +6955,24 @@ qemuMonitorJSONGetCPUx86Data(qemuMonitor *mon, g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data; - int ret =3D -1; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("qom-get", "s:path", QOM_CPU_PATH, "s:property", property, NULL))) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) - goto cleanup; + return -1; =20 data =3D virJSONValueObjectGetArray(reply, "return"); if (!(*cpudata =3D qemuMonitorJSONParseCPUx86Features(data))) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -7214,27 +6988,25 @@ qemuMonitorJSONCheckCPUx86(qemuMonitor *mon) virJSONValue *data; size_t i; size_t n; - int ret =3D -1; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("qom-list", "s:path", QOM_CPU_PATH, NULL))) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if ((data =3D virJSONValueObjectGet(reply, "error"))) { const char *klass =3D virJSONValueObjectGetString(data, "class"); if (STREQ_NULLABLE(klass, "DeviceNotFound") || STREQ_NULLABLE(klass, "CommandNotFound")) { - ret =3D 0; - goto cleanup; + return 0; } } =20 if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) - goto cleanup; + return -1; =20 data =3D virJSONValueObjectGetArray(reply, "return"); n =3D virJSONValueArraySize(data); @@ -7243,16 +7015,10 @@ qemuMonitorJSONCheckCPUx86(qemuMonitor *mon) virJSONValue *element =3D virJSONValueArrayGet(data, i); if (STREQ_NULLABLE(virJSONValueObjectGetString(element, "name"), "feature-words")) - break; + return 1; } =20 - if (i =3D=3D n) - ret =3D 0; - else - ret =3D 1; - - cleanup: - return ret; + return 0; } =20 =20 @@ -7408,50 +7174,43 @@ qemuMonitorJSONGetGuestCPU(qemuMonitor *mon, { g_autoptr(virCPUData) cpuEnabled =3D NULL; g_autoptr(virCPUData) cpuDisabled =3D NULL; - int ret =3D -1; =20 if (!(cpuEnabled =3D virCPUDataNew(arch)) || !(cpuDisabled =3D virCPUDataNew(arch))) - goto cleanup; + return -1; =20 if (qemuMonitorJSONGetCPUData(mon, translate, opaque, cpuEnabled) < 0) - goto cleanup; + return -1; =20 if (disabled && qemuMonitorJSONGetCPUDataDisabled(mon, translate, opaque, cpuDisab= led) < 0) - goto cleanup; + return -1; =20 *enabled =3D g_steal_pointer(&cpuEnabled); if (disabled) *disabled =3D g_steal_pointer(&cpuDisabled); =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 int qemuMonitorJSONRTCResetReinjection(qemuMonitor *mon) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("rtc-reset-reinjection", NULL))) - return ret; + return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 /** @@ -7558,7 +7317,6 @@ int qemuMonitorJSONSetIOThread(qemuMonitor *mon, qemuMonitorIOThreadInfo *iothreadInfo) { - int ret =3D -1; g_autofree char *path =3D NULL; qemuMonitorJSONObjectProperty prop; =20 @@ -7570,7 +7328,7 @@ qemuMonitorJSONSetIOThread(qemuMonitor *mon, prop.type =3D QEMU_MONITOR_OBJECT_PROPERTY_INT; \ prop.val.iv =3D iothreadInfo->propVal; \ if (qemuMonitorJSONSetObjectProperty(mon, path, propName, &prop) <= 0) \ - goto cleanup; \ + return -1; \ } =20 VIR_IOTHREAD_SET_PROP("poll-max-ns", poll_max_ns); @@ -7579,10 +7337,7 @@ qemuMonitorJSONSetIOThread(qemuMonitor *mon, =20 #undef VIR_IOTHREAD_SET_PROP =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -7590,7 +7345,6 @@ int qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon, GHashTable *info) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data =3D NULL; @@ -7600,10 +7354,10 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) - goto cleanup; + return -1; =20 data =3D virJSONValueObjectGetArray(reply, "return"); =20 @@ -7618,14 +7372,14 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("query-memory-devices reply data doesn't cont= ain " "enum type discriminator")); - goto cleanup; + return -1; } =20 if (!(dimminfo =3D virJSONValueObjectGetObject(elem, "data"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("query-memory-devices reply data doesn't " "contain enum data")); - goto cleanup; + return -1; } =20 /* While 'id' attribute is marked as optional in QEMU's QAPI @@ -7634,7 +7388,7 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon, if (!(devalias =3D virJSONValueObjectGetString(dimminfo, "id"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("dimm memory info data is missing 'id'")); - goto cleanup; + return -1; } =20 meminfo =3D g_new0(qemuMonitorMemoryDeviceInfo, 1); @@ -7645,21 +7399,21 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon, &meminfo->address) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed/missing addr in dimm memory in= fo")); - goto cleanup; + return -1; } =20 if (virJSONValueObjectGetNumberUint(dimminfo, "slot", &meminfo->slot) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed/missing slot in dimm memory in= fo")); - goto cleanup; + return -1; } =20 if (virJSONValueObjectGetBoolean(dimminfo, "hotplugged", &meminfo->hotplugged) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed/missing hotplugged in dimm mem= ory info")); - goto cleanup; + return -1; =20 } =20 @@ -7667,7 +7421,7 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon, &meminfo->hotpluggable) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed/missing hotpluggable in dimm m= emory info")); - goto cleanup; + return -1; =20 } =20 @@ -7676,7 +7430,7 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon, &meminfo->size) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed/missing size in virtio memory = info")); - goto cleanup; + return -1; } } else { /* type not handled yet */ @@ -7684,15 +7438,12 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon, } =20 if (virHashAddEntry(info, devalias, meminfo) < 0) - goto cleanup; + return -1; =20 meminfo =3D NULL; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -7855,7 +7606,6 @@ qemuMonitorJSONMigrateIncoming(qemuMonitor *mon, int qemuMonitorJSONMigrateStartPostCopy(qemuMonitor *mon) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -7863,12 +7613,9 @@ qemuMonitorJSONMigrateStartPostCopy(qemuMonitor *mon) return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 - ret =3D qemuMonitorJSONCheckError(cmd, reply); - - cleanup: - return ret; + return qemuMonitorJSONCheckError(cmd, reply); } =20 =20 @@ -7877,7 +7624,6 @@ qemuMonitorJSONMigrateContinue(qemuMonitor *mon, qemuMonitorMigrationStatus status) { const char *statusStr =3D qemuMonitorMigrationStatusTypeToString(statu= s); - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -7887,12 +7633,9 @@ qemuMonitorJSONMigrateContinue(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 - ret =3D qemuMonitorJSONCheckError(cmd, reply); - - cleanup: - return ret; + return qemuMonitorJSONCheckError(cmd, reply); } =20 =20 @@ -7900,7 +7643,6 @@ int qemuMonitorJSONGetRTCTime(qemuMonitor *mon, struct tm *tm) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data; @@ -7912,10 +7654,10 @@ qemuMonitorJSONGetRTCTime(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) - goto cleanup; + return -1; =20 data =3D virJSONValueObjectGet(reply, "return"); =20 @@ -7927,12 +7669,10 @@ qemuMonitorJSONGetRTCTime(qemuMonitor *mon, virJSONValueObjectGetNumberInt(data, "tm_sec", &tm->tm_sec) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("qemu returned malformed time")); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -8108,21 +7848,17 @@ qemuMonitorJSONQueryQMPSchema(qemuMonitor *mon) { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; - virJSONValue *ret =3D NULL; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("query-qmp-schema", NULL))) return NULL; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return NULL; =20 if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) - goto cleanup; + return NULL; =20 - ret =3D virJSONValueObjectStealArray(reply, "return"); - - cleanup: - return ret; + return virJSONValueObjectStealArray(reply, "return"); } =20 =20 @@ -8133,7 +7869,6 @@ qemuMonitorJSONSetBlockThreshold(qemuMonitor *mon, { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; - int ret =3D -1; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("block-set-write-threshold", "s:node-name", nodename, @@ -8142,15 +7877,12 @@ qemuMonitorJSONSetBlockThreshold(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -8293,7 +8025,6 @@ qemuMonitorJSONBlockdevTrayOpen(qemuMonitor *mon, { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; - int ret =3D -1; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("blockdev-open-tray", "s:id", id, @@ -8301,15 +8032,12 @@ qemuMonitorJSONBlockdevTrayOpen(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -8319,22 +8047,18 @@ qemuMonitorJSONBlockdevTrayClose(qemuMonitor *mon, { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; - int ret =3D -1; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("blockdev-close-tray", "s:id", id, NULL))) return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -8344,22 +8068,18 @@ qemuMonitorJSONBlockdevMediumRemove(qemuMonitor *mo= n, { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; - int ret =3D -1; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("blockdev-remove-medium", "s:id", id, NULL))) return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -8370,7 +8090,6 @@ qemuMonitorJSONBlockdevMediumInsert(qemuMonitor *mon, { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; - int ret =3D -1; =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("blockdev-insert-medium", "s:id", id, @@ -8379,15 +8098,12 @@ qemuMonitorJSONBlockdevMediumInsert(qemuMonitor *mo= n, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -8405,7 +8121,6 @@ char * qemuMonitorJSONGetSEVMeasurement(qemuMonitor *mon) { const char *tmp; - char *measurement =3D NULL; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; virJSONValue *data; @@ -8414,20 +8129,17 @@ qemuMonitorJSONGetSEVMeasurement(qemuMonitor *mon) return NULL; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return NULL; =20 if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) - goto cleanup; + return NULL; =20 data =3D virJSONValueObjectGetObject(reply, "return"); =20 if (!(tmp =3D virJSONValueObjectGetString(data, "data"))) - goto cleanup; + return NULL; =20 - measurement =3D g_strdup(tmp); - - cleanup: - return measurement; + return g_strdup(tmp); } =20 =20 @@ -8443,7 +8155,6 @@ qemuMonitorJSONExtractPRManagerInfo(virJSONValue *rep= ly, GHashTable *info) { virJSONValue *data; - int ret =3D -1; size_t i; =20 data =3D virJSONValueObjectGetArray(reply, "return"); @@ -8465,19 +8176,17 @@ qemuMonitorJSONExtractPRManagerInfo(virJSONValue *r= eply, } =20 if (virHashAddEntry(info, alias, entry) < 0) - goto cleanup; + return -1; =20 entry =3D NULL; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; =20 malformed: virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed prManager reply")); - goto cleanup; + return -1; } =20 =20 @@ -8485,7 +8194,6 @@ int qemuMonitorJSONGetPRManagerInfo(qemuMonitor *mon, GHashTable *info) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -8494,15 +8202,12 @@ qemuMonitorJSONGetPRManagerInfo(qemuMonitor *mon, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) - goto cleanup; - - ret =3D qemuMonitorJSONExtractPRManagerInfo(reply, info); - cleanup: - return ret; + return -1; =20 + return qemuMonitorJSONExtractPRManagerInfo(reply, info); } =20 =20 @@ -8533,7 +8238,6 @@ int qemuMonitorJSONGetCurrentMachineInfo(qemuMonitor *mon, qemuMonitorCurrentMachineInfo *info) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; =20 @@ -8542,15 +8246,12 @@ qemuMonitorJSONGetCurrentMachineInfo(qemuMonitor *m= on, return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) - goto cleanup; + return -1; =20 - ret =3D qemuMonitorJSONExtractCurrentMachineInfo(reply, info); - - cleanup: - return ret; + return qemuMonitorJSONExtractCurrentMachineInfo(reply, info); } =20 =20 --=20 2.32.0 From nobody Fri May 3 11:16:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1635159501; cv=none; d=zohomail.com; s=zohoarc; b=aUdlkZpw7kuApKc5kM4aVZ/KGsG0cVY6uRkF5RBsTI+nxQRoLUhfdQlT7XI9LoJxljL6TvOnZ1UtgGnSbF1Co4oi8q11R52vvnqFDhPqWmIbLevmGycYt1SKl4ilD8+YpZdKFEjJD1pdhJtYnizT1AsJwoLBxJawzUuJOdpakvw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635159501; 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=pQadCyeE9/Ite5qe/wEqUEX20KxOTBM1pPGzLcZm+oE=; b=gozAX+GA++cJrldWGn6M30W/e3JRZaxyRqmSlsXWDTkD+Tz9D9SiKttGzooFFVfC9BRm47uIpKdkPTT6aqQFTvld7gX6Dz0lctUmXg7CXFSPVhHcRoqyV3/ZZ9t/9vQXDmT87VpzgTMOjw9rOXynk2uX2CjrjrkfPWupyvHp0VA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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 [170.10.129.124]) by mx.zohomail.com with SMTPS id 1635159501790310.75133326013224; Mon, 25 Oct 2021 03:58:21 -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-131-Ga3-xxFPPNOyPv-5qdoJkQ-1; Mon, 25 Oct 2021 06:58:17 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2390F80A5C8; Mon, 25 Oct 2021 10:58:10 +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 0296E17CE1; Mon, 25 Oct 2021 10:58:10 +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 C19E61832DF3; Mon, 25 Oct 2021 10:58:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19PAw5Lj016976 for ; Mon, 25 Oct 2021 06:58:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id D187A5DAA5; Mon, 25 Oct 2021 10:58:05 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 595665DEFB for ; Mon, 25 Oct 2021 10:58:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635159500; 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=pQadCyeE9/Ite5qe/wEqUEX20KxOTBM1pPGzLcZm+oE=; b=AFP5lncbYyW3cF0pK44iYpQMzrVdBcztFRBiUFcSWGnPtbRbG+rUal2c7XfipPr/kQGBYD r3SVhGbnYT2PoIRXEr4uQb5Pzq3w71ZYz47LZ7QHS46nmmZruhOzd5ZRgJ7O6X3YOHksyu aZf0T3rp26cSrl7lkeezfzsPXwopnLc= X-MC-Unique: Ga3-xxFPPNOyPv-5qdoJkQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 13/13] qemu_monitor_json: Drop pointless error labels Date: Mon, 25 Oct 2021 12:57:37 +0200 Message-Id: <7c7013dbecd4ee4e408633853e87e719ef128607.1635159386.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.14 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: 1635159502799100001 Content-Type: text/plain; charset="utf-8" After previous cleanups, some 'error' labels were rendered needless - they contain nothing more than a return statement. Well, those labels can be dropped and 'goto error' can be replaced with return statement directly. Signed-off-by: Michal Privoznik Reviewed-by: Tim Wiederhake --- src/qemu/qemu_monitor_json.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index bb76ac7d37..e9be9bdabd 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5351,7 +5351,7 @@ qemuMonitorJSONMakeCPUModel(virCPUDef *cpu, size_t i; =20 if (virJSONValueObjectAppendString(model, "name", cpu->model) < 0) - goto error; + return NULL; =20 if (cpu->nfeatures || !migratable) { g_autoptr(virJSONValue) props =3D virJSONValueNewObject(); @@ -5367,22 +5367,19 @@ qemuMonitorJSONMakeCPUModel(virCPUDef *cpu, enabled =3D true; =20 if (virJSONValueObjectAppendBoolean(props, name, enabled) < 0) - goto error; + return NULL; } =20 if (!migratable && virJSONValueObjectAppendBoolean(props, "migratable", false) < = 0) { - goto error; + return NULL; } =20 if (virJSONValueObjectAppend(model, "props", &props) < 0) - goto error; + return NULL; } =20 return g_steal_pointer(&model); - - error: - return NULL; } =20 =20 @@ -6930,20 +6927,17 @@ qemuMonitorJSONParseCPUx86Features(virJSONValue *da= ta) size_t i; =20 if (!(cpudata =3D virCPUDataNew(VIR_ARCH_X86_64))) - goto error; + return NULL; =20 item.type =3D VIR_CPU_X86_DATA_CPUID; for (i =3D 0; i < virJSONValueArraySize(data); i++) { if (qemuMonitorJSONParseCPUx86FeatureWord(virJSONValueArrayGet(dat= a, i), &item.data.cpuid) < 0 || virCPUx86DataAdd(cpudata, &item) < 0) - goto error; + return NULL; } =20 return g_steal_pointer(&cpudata); - - error: - return NULL; } =20 =20 @@ -7049,20 +7043,17 @@ qemuMonitorJSONGetGuestCPUx86(qemuMonitor *mon, =20 if (qemuMonitorJSONGetCPUx86Data(mon, "feature-words", &cpuEnabled) < 0) - goto error; + return -1; =20 if (disabled && qemuMonitorJSONGetCPUx86Data(mon, "filtered-features", &cpuDisabled) < 0) - goto error; + return -1; =20 *data =3D g_steal_pointer(&cpuEnabled); if (disabled) *disabled =3D g_steal_pointer(&cpuDisabled); return 0; - - error: - return -1; } =20 =20 --=20 2.32.0