From nobody Sun Feb 8 23:05:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606762687; cv=none; d=zohomail.com; s=zohoarc; b=htSfMMkBwgTd+Yw4syHeASY09vymQNZWfTDAhfvu7ShFtvuVeZ+AtIrjEEK8s1zh0QzIjZIdMw0xVdGhf/uaEpJH541OmZbfKV0eP6pGLqC+R1t+IeTL2+BA0Sm9zic7PNjoSxmnuNEGaq+KvIDL0idScWUIO5VVfFsEweHIaxg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606762687; 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=XkK8oWPlmgvAx47QGRX4CR08u11IkqTNblkTeFMDPMw=; b=Nwf1XdY/MTwoUCTG3ibmKMzaUItdUtE35vo46V7tLA4LgtjqAHR9sTgkXf61Fnyq6akclRHMXt/lFy5mRHNVnlCQQyB6wjwO419UWAdn+FiHNgAbqVKBntHElejc9+aLOQh2URM3IcJBHNyvBNe8PiKouckYV5xwsXJDLobeafQ= 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) header.from= 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 1606762687951396.46598217892574; Mon, 30 Nov 2020 10:58:07 -0800 (PST) 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-146-DYxt6zjqMI2nmiicX-4roQ-1; Mon, 30 Nov 2020 13:56:21 -0500 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 D77891005E6F; Mon, 30 Nov 2020 18:56: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 B573E1346F; Mon, 30 Nov 2020 18:56: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 7A6F01809CAB; Mon, 30 Nov 2020 18:56:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0AUItqrr014230 for ; Mon, 30 Nov 2020 13:55:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 73E1A60C69; Mon, 30 Nov 2020 18:55:52 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A0D160C67 for ; Mon, 30 Nov 2020 18:55:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606762686; 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=XkK8oWPlmgvAx47QGRX4CR08u11IkqTNblkTeFMDPMw=; b=OnH1JzeksGVZVdyi8g1pwNdV4sSYgen3Ysw1zkdXr/hX5/D8mNl/9oYVfgQapqf7kqmLRJ tkBywnC/BISzUPSabhsXyhJj5muaUbRqUOWuc4c/V+NGRKpuSeIMzeliENTZPfjuuXSiIo qaPuW6i1rhDEbNY9dLLEqLSMcPX3vk8= X-MC-Unique: DYxt6zjqMI2nmiicX-4roQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/24] qemuMonitorAddObject: Refactor cleanup Date: Mon, 30 Nov 2020 19:55:21 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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) Content-Type: text/plain; charset="utf-8" Remove freeing/clearing of @props as the function doesn't guarantee that it happens on success, rename the variable hodling copy of the alias and use g_autofree to automatically free it and remove the cleanup label as well as 'ret' variable. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index c4fa111836..b26fba303d 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3078,13 +3078,12 @@ qemuMonitorAddObject(qemuMonitorPtr mon, { const char *type =3D NULL; const char *id =3D NULL; - char *tmp =3D NULL; - int ret =3D -1; + g_autofree char *aliasCopy =3D NULL; if (!*props) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("object props can't be NULL")); - goto cleanup; + return -1; } type =3D virJSONValueObjectGetString(*props, "qom-type"); @@ -3092,31 +3091,25 @@ qemuMonitorAddObject(qemuMonitorPtr mon, VIR_DEBUG("type=3D%s id=3D%s", NULLSTR(type), NULLSTR(id)); - QEMU_CHECK_MONITOR_GOTO(mon, cleanup); + QEMU_CHECK_MONITOR(mon); if (!id || !type) { virReportError(VIR_ERR_INTERNAL_ERROR, _("missing alias or qom-type for qemu object '%s'"), NULLSTR(type)); - goto cleanup; + return -1; } if (alias) - tmp =3D g_strdup(id); + aliasCopy =3D g_strdup(id); if (qemuMonitorJSONAddObject(mon, props) < 0) - goto cleanup; + return -1; if (alias) - *alias =3D g_steal_pointer(&tmp); - - ret =3D 0; + *alias =3D g_steal_pointer(&aliasCopy); - cleanup: - VIR_FREE(tmp); - virJSONValueFree(*props); - *props =3D NULL; - return ret; + return 0; } --=20 2.28.0