On 08/28/2017 09:41 AM, Cédric Le Goater wrote:
> On 08/23/2017 01:53 PM, Dr. David Alan Gilbert wrote:
>> * Juan Quintela (quint...@redhat.com) 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 <quint...@redhat.com>
>>> ---

>>>  
>>>      /* 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 fixed that one with :
> 
> @@ -40,7 +40,7 @@ static uint32_t acpi_find_vgia(void)
>      AcpiRsdpDescriptor rsdp_table;
>      uint32_t rsdt;
>      AcpiRsdtDescriptorRev1 rsdt_table;
> -    int tables_nr;
> +    uint32_t tables_nr;

I like this one better (multiplication in g_malloc0() makes me worry
about overflow; using unsigned math to avoid the problem is nicer).  Are
we going to see a v2 of this patch series?

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to