From nobody Sun Feb 8 21:29:10 2026 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 --- 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