From nobody Mon Feb 9 00:07:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1589556564; cv=none; d=zohomail.com; s=zohoarc; b=YOQuPnA+9n0itFs4Qx//EF8Fu9cBkNd0+Dyib5xj4IjXLq7FOg83ExbydasqawkPaF1XcdKH/2PV2t/UwkLXhJIPT1qY9Uzt8Y+iFMGAM1Vqb2hZGSO/Ue7Ioc1uRaJz/vhVwsEDTR6vNk/GKvdfGAlufNvZe+AhWgdTEbWTSck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589556564; 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=dUqAaEOBloViLA1zF/ponWt0gEoWt4I1HFjA7JKJYpo=; b=PHcVLVfRzF/gEhNHMzorZN4tL6WBzmfiV0cltWj/up+OnColpI04DKSuGtAvSpy0hGotdLipouMIUc01iVKzfRQhhK+tavW68pvP6VDUEeLh7AlFf9He56Z2CW+KJsBgZq51x/Islc24vKKcBeJ9SQzCJPEUJZMMROD8sHa+fVY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1589556564074448.4716846659113; Fri, 15 May 2020 08:29:24 -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-163-j-qk03g_Ozqfa0CIWNjcIA-1; Fri, 15 May 2020 11:29:20 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4F6B618FE863; Fri, 15 May 2020 15:29: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 2F20F5C583; Fri, 15 May 2020 15:29: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 EF9F41800430; Fri, 15 May 2020 15:29:14 +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 04FFTCMO011347 for ; Fri, 15 May 2020 11:29:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1163A5D9D7; Fri, 15 May 2020 15:29:12 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7CB875D9C9 for ; Fri, 15 May 2020 15:29:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589556562; 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=dUqAaEOBloViLA1zF/ponWt0gEoWt4I1HFjA7JKJYpo=; b=IPnWZZTnPltraTs/GTcSmBV9F+R9kQNip4tNM7qrd8IHjjzSyvFpD8gCjYi9HLNYUiXHhN sv8phjvVucjX38R9nvpBTeG0FsFSmnKzQsZ7YpsmDY+vDxhSkaZSwFGpOZAMZKEAty5r3e KA0Tni2iSO0lwTkNwHBxitfTMepm/2w= X-MC-Unique: j-qk03g_Ozqfa0CIWNjcIA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/21] qemuMonitorJSON(Add|Remove)Netdev: Refactor cleanup Date: Fri, 15 May 2020 17:27:58 +0200 Message-Id: <5dc243add944782a79f9261c52cee1bfecfe3750.1589556042.git.pkrempa@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.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use automatic pointer cleanup for virJSONValuePtrs to get rid of the cleanup label and ret variable. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- src/qemu/qemu_monitor_json.c | 52 +++++++++++++++--------------------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 66422a8489..1224d1c9cc 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3984,13 +3984,13 @@ int qemuMonitorJSONCloseFileHandle(qemuMonitorPtr m= on, } -int qemuMonitorJSONAddNetdev(qemuMonitorPtr mon, - const char *netdevstr) +int +qemuMonitorJSONAddNetdev(qemuMonitorPtr mon, + const char *netdevstr) { - int ret =3D -1; - virJSONValuePtr cmd =3D NULL; - virJSONValuePtr reply =3D NULL; - virJSONValuePtr args =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; + g_autoptr(virJSONValue) args =3D NULL; cmd =3D qemuMonitorJSONMakeCommand("netdev_add", NULL); if (!cmd) @@ -3998,49 +3998,41 @@ int qemuMonitorJSONAddNetdev(qemuMonitorPtr mon, args =3D qemuMonitorJSONKeywordStringToJSON(netdevstr, "type"); if (!args) - goto cleanup; + return -1; if (virJSONValueObjectAppend(cmd, "arguments", args) < 0) - goto cleanup; + return -1; args =3D NULL; /* obj owns reference to args now */ if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; - ret =3D 0; - cleanup: - virJSONValueFree(args); - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; + return 0; } -int qemuMonitorJSONRemoveNetdev(qemuMonitorPtr mon, - const char *alias) +int +qemuMonitorJSONRemoveNetdev(qemuMonitorPtr mon, + const char *alias) { - int ret =3D -1; - virJSONValuePtr cmd =3D qemuMonitorJSONMakeCommand("netdev_del", - "s:id", alias, - NULL); - virJSONValuePtr reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D qemuMonitorJSONMakeCommand("netdev_del= ", + "s:id", alias, + NULL); + g_autoptr(virJSONValue) reply =3D NULL; + if (!cmd) return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; - ret =3D 0; - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; + return 0; } --=20 2.26.2