qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 14/14] libqos/ahci: create libqos/ahci.c


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH 14/14] libqos/ahci: create libqos/ahci.c
Date: Mon, 19 Jan 2015 18:59:29 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Paolo Bonzini <address@hidden> writes:

> On 13/01/2015 04:34, John Snow wrote:
>> +tests/ahci-test$(EXESUF): tests/ahci-test.o $(libqos-pc-obj-y) \
>> +                          tests/libqos/ahci.o
>
> Why not add this to libqos-pc-obj-y or libqos-obj-y?
>
>> 
>> + * Allocate space in the guest using information in the AHCIQState object.
>> + */
>> +uint64_t ahci_alloc(AHCIQState *ahci, size_t bytes)
>> +{
>> +    g_assert(ahci);
>> +    g_assert(ahci->parent);
>> +    return qmalloc(ahci->parent, bytes);
>
> No need to assert if you'd get a subsequent NULL pointer access.
>
>> +}
>> +
>> +void ahci_free(AHCIQState *ahci, uint64_t addr)
>> +{
>> +    g_assert(ahci);
>> +    g_assert(ahci->parent);
>> +    qfree(ahci->parent, addr);
>> +}
>
> Same here.
>
>> +    g_assert(ahci->hba_base != 0);
>
> Comparing void * to NULL.  Not a problem since I think hba_base should
> become an uint32_t anyway.

g_assert(ahci->hba_base) works fine in either case :)

Comparing a pointer with 0 looks sloppy in C, and might deceive readers.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]