From nobody Wed Nov 27 08:34:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1553705478263437.5308856869708; Wed, 27 Mar 2019 09:51:18 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A659630BC644; Wed, 27 Mar 2019 16:51:16 +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 843711001DD4; Wed, 27 Mar 2019 16:51:16 +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 46BF61803388; Wed, 27 Mar 2019 16:51:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2RGpDdd010347 for ; Wed, 27 Mar 2019 12:51:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id B63DE27CBC; Wed, 27 Mar 2019 16:51:13 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id C11FC282D5; Wed, 27 Mar 2019 16:51:10 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 27 Mar 2019 17:50:46 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 2/2] qemuxml2argvtest: Drop dependency between testInfoArgName and virQEMUCapsFlags enums 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 27 Mar 2019 16:51:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Introduced in fdf6c89ee7b, this dependency looks weird. It was needed because of the way that while() loop was written - it fetches next argument in every iteration. Therefore, our only option was for ARG_END to have the same value as QEMU_CAPS_LAST. This also meant that QEMU_CAPS_* could have been only at the end of the __VA_ARGS__. This commit reworks the while() loop and removes the dependency. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/qemuxml2argvtest.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 4d6e4b0d39..0c0dcae197 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -616,19 +616,7 @@ typedef enum { ARG_PARSEFLAGS, ARG_CAPS_ARCH, ARG_CAPS_VER, - - /* ARG_END is our va_args sentinel. The value QEMU_CAPS_LATEST is - * necessary to handle the DO_TEST(..., NONE) case, which through macro - * magic will give the va_args list: - * - * ARG_QEMU_CAPS, NONE, QEMU_CAPS_LAST, ARG_END - * - * SetArgs consumes the first item, hands off control to virQEMUCapsX - * virQEMUCapsX sees NONE aka QEMU_CAPS_LAST, returns to SetArgs. - * SetArgs sees QEMU_CAPS_LAST aka ARG_END, and exits the parse loop. - * If ARG_END !=3D QEMU_CAPS_LAST, this last step would generate an er= ror. - */ - ARG_END =3D QEMU_CAPS_LAST, + ARG_END, } testInfoArgName; =20 static int @@ -646,7 +634,8 @@ testInfoSetArgs(struct testInfo *info, int ret =3D -1; =20 va_start(argptr, capslatest); - while ((argname =3D va_arg(argptr, testInfoArgName)) < ARG_END) { + argname =3D va_arg(argptr, testInfoArgName); + while (argname !=3D ARG_END) { switch (argname) { case ARG_QEMU_CAPS: if (qemuCaps || !(qemuCaps =3D virQEMUCapsNew())) @@ -655,6 +644,22 @@ testInfoSetArgs(struct testInfo *info, while ((flag =3D va_arg(argptr, int)) < QEMU_CAPS_LAST) virQEMUCapsSet(qemuCaps, flag); =20 + /* Some tests are run with NONE capabilities, which is just + * another name for QEMU_CAPS_LAST. If that is the case the + * arguments look like this : + * + * ARG_QEMU_CAPS, NONE, QEMU_CAPS_LAST, ARG_END + * + * Fetch one argument more and if it is QEMU_CAPS_LAST then + * break from the switch() to force getting next argument + * in the line. If it is not QEMU_CAPS_LAST then we've + * fetched real ARG_* and we must process it. + */ + if ((flag =3D va_arg(argptr, int)) !=3D QEMU_CAPS_LAST) { + argname =3D flag; + continue; + } + break; =20 case ARG_GIC: @@ -690,6 +695,8 @@ testInfoSetArgs(struct testInfo *info, fprintf(stderr, "Unexpected test info argument"); goto cleanup; } + + argname =3D va_arg(argptr, testInfoArgName); } =20 if (!!capsarch ^ !!capsver) { --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list