From nobody Sun Feb 8 13:11:04 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=1629465494; cv=none; d=zohomail.com; s=zohoarc; b=XX6LkNN0dS400vkHt2RRHe5rFVEUv7Nk+TXgVb+je3xZf4n5Cw9Rv8jvCbJlv7qyKw0CtgrvvRS06v9cW7iSjodS3qYJlpiKA15lHJXJZAPFWHRrg1FDogZev6apCB79gk6Tj3r0deu1UDDiR1Li5svAhzUpT0jf/f/sVcM0Euw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629465494; 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=nJUwr7pl3JMFNcOhb+lPY7zHBhwuPZVEhX6ZuOCK370=; b=MyTeP/toAC5m8yfGq0RRdvG5WDxAepWw2xQJUaQuPk8bAOeecLrK2gTazrrA8BOTjuf6spxKHHQOd9ecfWj6bzI3LA1Y09hZ+Eg94AmvxPzEC/YQJSwUmgJ3v7LiQvcsvu16zR9wcPPRq18imKFbTOl5sMcu3pd5lYa4TeT0E0M= 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 1629465494944182.3331907850852; Fri, 20 Aug 2021 06:18:14 -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-390-vBQ0buFXMryYLRtX6GcLGw-1; Fri, 20 Aug 2021 09:18:12 -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 C3CAA1026203; Fri, 20 Aug 2021 13:18:06 +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 A28A95DD68; Fri, 20 Aug 2021 13:18: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 62F244A7CA; Fri, 20 Aug 2021 13:18:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17KDFh5V016625 for ; Fri, 20 Aug 2021 09:15:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id B519A1002D71; Fri, 20 Aug 2021 13:15:43 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.43.2.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3CD0C10013C1 for ; Fri, 20 Aug 2021 13:15:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629465493; 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=nJUwr7pl3JMFNcOhb+lPY7zHBhwuPZVEhX6ZuOCK370=; b=CMPN2Q3L4rHdnKS1P+i4Zo5N2njEWa74HHm8Id/Bkis0WLZ+vi8mYFDnGRMeBjx17KlPKl hjQJHA6MEpZ4DRcEW9+4wkw0y4g+YxYR/DbH4JsARanzW/O5kNEM3BtckE7HFbi+frGAsg D4UNd20dwIJUpPISbg6J7AtkY0KGymc= X-MC-Unique: vBQ0buFXMryYLRtX6GcLGw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 4/5] tests: introduce testVirNetDevBandwidthParse Date: Fri, 20 Aug 2021 15:15:31 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629465495364100001 The 'PARSE' macro does not use '#' or '##' directives, or anything from outside of the macro other than the cleanup label. Turn it into a function. Signed-off-by: J=C3=A1n Tomko --- tests/virnetdevbandwidthtest.c | 44 ++++++++++++++++---------------- tests/virnetdevopenvswitchtest.c | 44 ++++++++++++++++---------------- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/tests/virnetdevbandwidthtest.c b/tests/virnetdevbandwidthtest.c index 197d936479..a17737ec40 100644 --- a/tests/virnetdevbandwidthtest.c +++ b/tests/virnetdevbandwidthtest.c @@ -39,27 +39,26 @@ struct testSetStruct { const bool hierarchical_class; }; =20 -#define PARSE(xml, var) \ - do { \ - int rc; \ - g_autoptr(xmlDoc) doc =3D NULL; \ - g_autoptr(xmlXPathContext) ctxt =3D NULL; \ - \ - if (!xml) \ - break; \ - \ - if (!(doc =3D virXMLParseStringCtxt((xml), \ - "bandwidth definition", \ - &ctxt))) \ - goto cleanup; \ - \ - rc =3D virNetDevBandwidthParse(&(var), \ - NULL, \ - ctxt->node, \ - true); \ - if (rc < 0) \ - goto cleanup; \ - } while (0) +static int +testVirNetDevBandwidthParse(virNetDevBandwidth **var, + const char *xml) +{ + g_autoptr(xmlDoc) doc =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; + + if (!xml) + return 0; + + if (!(doc =3D virXMLParseStringCtxt((xml), + "bandwidth definition", + &ctxt))) + return -1; + + return virNetDevBandwidthParse(var, + NULL, + ctxt->node, + true); +} =20 static int testVirNetDevBandwidthSet(const void *data) @@ -72,7 +71,8 @@ testVirNetDevBandwidthSet(const void *data) g_autofree char *actual_cmd =3D NULL; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 - PARSE(info->band, band); + if (testVirNetDevBandwidthParse(&band, info->band) < 0) + return -1; =20 if (!iface) iface =3D "eth0"; diff --git a/tests/virnetdevopenvswitchtest.c b/tests/virnetdevopenvswitcht= est.c index 89ffc1e4b5..1026c890cd 100644 --- a/tests/virnetdevopenvswitchtest.c +++ b/tests/virnetdevopenvswitchtest.c @@ -45,27 +45,26 @@ struct testClearQosStruct { const unsigned char *vmid; }; =20 -#define PARSE(xml, var) \ - do { \ - int rc; \ - g_autoptr(xmlDoc) doc =3D NULL; \ - g_autoptr(xmlXPathContext) ctxt =3D NULL; \ - \ - if (!xml) \ - break; \ - \ - if (!(doc =3D virXMLParseStringCtxt((xml), \ - "bandwidth definition", \ - &ctxt))) \ - goto cleanup; \ - \ - rc =3D virNetDevBandwidthParse(&(var), \ - NULL, \ - ctxt->node, \ - true); \ - if (rc < 0) \ - goto cleanup; \ - } while (0) +static int +testVirNetDevBandwidthParse(virNetDevBandwidth **var, + const char *xml) +{ + g_autoptr(xmlDoc) doc =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; + + if (!xml) + return 0; + + if (!(doc =3D virXMLParseStringCtxt((xml), + "bandwidth definition", + &ctxt))) + return -1; + + return virNetDevBandwidthParse(var, + NULL, + ctxt->node, + true); +} =20 static const unsigned char vm_id[VIR_UUID_BUFLEN] =3D "fakeuuid"; =20 @@ -161,7 +160,8 @@ testVirNetDevOpenvswitchInterfaceSetQos(const void *dat= a) g_autofree char *actual_cmd =3D NULL; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 - PARSE(info->band, band); + if (testVirNetDevBandwidthParse(&band, info->band) < 0) + return -1; =20 if (!iface) iface =3D "tap-fake"; --=20 2.31.1