[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/2] tests: Make acpid test compile
From: |
Dr. David Alan Gilbert |
Subject: |
Re: [Qemu-devel] [PATCH 2/2] tests: Make acpid test compile |
Date: |
Wed, 23 Aug 2017 12:53:27 +0100 |
User-agent: |
Mutt/1.8.3 (2017-05-23) |
* Juan Quintela (address@hidden) wrote:
> Compiler gets confused with the size of the struct, so move form
> g_new0() to g_malloc0().
>
> I *think* that the problem is in gcc (or glib for that matter), but
> the documentation of the g_new0 states that 1sts first argument is an
> struct type, and uint32_t is not an struct type.
>
> Signed-off-by: Juan Quintela <address@hidden>
> ---
> tests/vmgenid-test.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c
> index 3d5c1c3615..032e1d465a 100644
> --- a/tests/vmgenid-test.c
> +++ b/tests/vmgenid-test.c
> @@ -67,7 +67,7 @@ static uint32_t acpi_find_vgia(void)
> g_assert_cmpint(tables_nr, >, 0);
>
> /* get the addresses of the tables pointed by rsdt */
> - tables = g_new0(uint32_t, tables_nr);
> + tables = g_malloc0(sizeof(uint32_t) * tables_nr);
I think there's an easier fix for this I think;
try:
- g_assert_cmpint(tables_nr, >, 0);
+ g_assert(tables_nr > 0);
Dave
> ACPI_READ_ARRAY_PTR(tables, tables_nr, rsdt);
>
> for (i = 0; i < tables_nr; i++) {
> --
> 2.13.5
>
--
Dr. David Alan Gilbert / address@hidden / Manchester, UK
[Qemu-devel] [PATCH 1/2] tests: Use real size for iov tests, Juan Quintela, 2017/08/23