From: Laszlo Ersek <lersek@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>, qemu-devel@nongnu.org
Cc: Marcel Apfelbaum <marcel.a@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/2] acpi-test: signature endian-ness fixes
Date: Tue, 18 Mar 2014 19:02:30 +0100 [thread overview]
Message-ID: <53288A36.2040703@redhat.com> (raw)
In-Reply-To: <1395154048-28278-1-git-send-email-mst@redhat.com>
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 <mst@redhat.com>
> ---
> 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 <lersek@redhat.com>
prev parent reply other threads:[~2014-03-18 18:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-18 14:48 [Qemu-devel] [PATCH 1/2] acpi-test: signature endian-ness fixes Michael S. Tsirkin
2014-03-18 14:48 ` [Qemu-devel] [PATCH 2/2] acpi: fix endian-ness for table ids Michael S. Tsirkin
2014-03-18 18:07 ` Laszlo Ersek
2014-03-19 13:49 ` Marcel Apfelbaum
2014-03-18 18:02 ` Laszlo Ersek [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53288A36.2040703@redhat.com \
--to=lersek@redhat.com \
--cc=marcel.a@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).