From nobody Sun Dec 22 01:16:21 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=1685027657; cv=none; d=zohomail.com; s=zohoarc; b=MnE7+9V6XsT9CsA4ojJaeAZ536bO2HNyG2V+eVcrMUFMqMXTVzMTjaJvTfsAIoj88Z02TXIKP7Pvv2aHBNJFSWm2V/t+Mdr3yRQXe9Rks7TA69wPT48VdkV0zAWQNeA/ugwTUSo+fQ/QTgEBUe7dmyAqCfGbdPIYmEQmsP6/o3E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685027657; 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=ElvOKXB6pcQqDLcdDr/0AEXQ1OHV+7x6pAZU6NcODZc=; b=IZd0tvuMwoOsCPeu4WAd0md+4PEHdgvYhCo1naoES2j5J3bPSeCpruOgvarhwfkxoShpabmnhsfxM5C9aw5gPcZLCDIrwbr8uuL3SnWHQa0ErXWeb0R+5a3b4ck6J7NFEymEJjYFLSYBYSGM4MgdUjwG8jmi1XN9vgKFS5JqYxY= 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 1685027657914427.8009390825657; Thu, 25 May 2023 08:14:17 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-75-3-xl_Qw3NP-juIyxTSAumA-1; Thu, 25 May 2023 11:14:13 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 85948803791; Thu, 25 May 2023 15:14:10 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B9EEC20296C6; Thu, 25 May 2023 15:14:09 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8ABAB19465A4; Thu, 25 May 2023 15:14:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D2D8D19465B7 for ; Thu, 25 May 2023 15:13:48 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3FDA840107B; Thu, 25 May 2023 15:13:48 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id BCEAB492B00 for ; Thu, 25 May 2023 15:13:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685027656; 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=ElvOKXB6pcQqDLcdDr/0AEXQ1OHV+7x6pAZU6NcODZc=; b=jPc0DIcGkxdgCldJl03/KGTlW2eLFRELkbNGFKDVTC+msk1C7gtW5ji60Fx/JFYfw68HTd mYuu2iXL//20R8vZGZ5j3XfJWE9vv545FvQL+kx+V3XdxjwUN9ezXhtOX5s3LWWuOSTnWl dwQPzhMJemGKUPOxCt4QdlwfYPtzzb8= X-MC-Unique: 3-xl_Qw3NP-juIyxTSAumA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/18] qemuMonitorTestAddItemVerbatim: Simplify cleanup Date: Thu, 25 May 2023 17:13:28 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1685027658597100001 Content-Type: text/plain; charset="utf-8" Reformat the JSON string before allocating the test data structure so that we don't have to free it if the reformatting fails. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemumonitortestutils.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 4e99c4b54e..cfe78b258a 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -673,24 +673,21 @@ qemuMonitorTestAddItemVerbatim(qemuMonitorTest *test, const char *response) { struct qemuMonitorTestHandlerData *data; + char *reformatted =3D NULL; + + if (!(reformatted =3D virJSONStringReformat(command, false))) + return -1; data =3D g_new0(struct qemuMonitorTestHandlerData, 1); data->response =3D g_strdup(response); data->cmderr =3D g_strdup(cmderr); - - data->command_name =3D virJSONStringReformat(command, false); - if (!data->command_name) - goto error; + data->command_name =3D g_steal_pointer(&reformatted); return qemuMonitorTestAddHandler(test, command, qemuMonitorTestProcessCommandVerbatim, data, qemuMonitorTestHandlerDataFree); - - error: - qemuMonitorTestHandlerDataFree(data); - return -1; } --=20 2.40.1