From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51338) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPyLb-0006RU-N0 for qemu-devel@nongnu.org; Tue, 18 Mar 2014 14:02:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WPyLU-0001UO-43 for qemu-devel@nongnu.org; Tue, 18 Mar 2014 14:02:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29478) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPyLT-0001Ti-P6 for qemu-devel@nongnu.org; Tue, 18 Mar 2014 14:02:36 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2II2WAU019111 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 18 Mar 2014 14:02:33 -0400 Message-ID: <53288A36.2040703@redhat.com> Date: Tue, 18 Mar 2014 19:02:30 +0100 From: Laszlo Ersek MIME-Version: 1.0 References: <1395154048-28278-1-git-send-email-mst@redhat.com> In-Reply-To: <1395154048-28278-1-git-send-email-mst@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/2] acpi-test: signature endian-ness fixes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" , qemu-devel@nongnu.org Cc: Marcel Apfelbaum On 03/18/14 15:48, Michael S. Tsirkin wrote: > acpi table signature is really an ASCII string. > Treat it as such in tests. > > Signed-off-by: Michael S. Tsirkin > --- > tests/acpi-test.c | 48 +++++++++++++++++++++++++++++++++--------------- > 1 file changed, 33 insertions(+), 15 deletions(-) > > diff --git a/tests/acpi-test.c b/tests/acpi-test.c > index 185309a..249fe03 100644 > --- a/tests/acpi-test.c > +++ b/tests/acpi-test.c > @@ -23,7 +23,6 @@ > #define MACHINE_Q35 "q35" > > #define ACPI_REBUILD_EXPECTED_AML "TEST_ACPI_REBUILD_AML" > -#define ACPI_SSDT_SIGNATURE 0x54445353 /* SSDT */ > > /* DSDT and SSDTs format */ > typedef struct { > @@ -101,6 +100,20 @@ typedef struct { > ACPI_READ_FIELD((table)->asl_compiler_revision, addr); \ > } while (0); > > +#define ACPI_ASSERT_CMP(actual, expected) do { \ > + uint32_t ACPI_ASSERT_CMP_le = cpu_to_le32(actual); \ > + char ACPI_ASSERT_CMP_str[5] = {}; \ > + memcpy(ACPI_ASSERT_CMP_str, &ACPI_ASSERT_CMP_le, 4); \ > + g_assert_cmpstr(ACPI_ASSERT_CMP_str, ==, expected); \ > +} while (0) > + > +#define ACPI_ASSERT_CMP64(actual, expected) do { \ > + uint64_t ACPI_ASSERT_CMP_le = cpu_to_le64(actual); \ > + char ACPI_ASSERT_CMP_str[9] = {}; \ > + memcpy(ACPI_ASSERT_CMP_str, &ACPI_ASSERT_CMP_le, 8); \ > + g_assert_cmpstr(ACPI_ASSERT_CMP_str, ==, expected); \ > +} while (0) > + The {} initializers are GNUisms, { 0 } is the standard way to write them. (For strings where you specify the size explicitly, = "" would work too (in C99 explicitly, in C89 a bit more navel gazing would be required to derive that).) The patch seems reasonable to me. Reviewed-by: Laszlo Ersek