[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 4/6] device_tree: qemu_fdt_getprop converted to
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH 4/6] device_tree: qemu_fdt_getprop converted to use the error API |
Date: |
Tue, 5 Jan 2016 17:54:08 +0000 |
On 5 January 2016 at 16:20, Eric Auger <address@hidden> wrote:
> Hi Peter,
> On 12/18/2015 03:36 PM, Peter Maydell wrote:
>> On 17 December 2015 at 12:29, Eric Auger <address@hidden> wrote:
>>> Current qemu_fdt_getprop exits if the property is not found. It is
>>> sometimes needed to read an optional property, in which case we do
>>> not wish to exit but simply returns a null value.
>>>
>>> This patch converts qemu_fdt_getprop to accept an Error **, and existing
>>> users are converted to pass &error_fatal. This preserves the existing
>>> behaviour. Then to use the API with your optional semantic a null
>>> parameter can be conveyed.
>>>
>>> Signed-off-by: Eric Auger <address@hidden>
>>>
>>> ---
>>>
>>> RFC -> v1:
>>> - get rid of qemu_fdt_getprop_optional and implement Peter's suggestion
>>> that consists in using the error API
>>
>> This doesn't seem to me like a great way for qemu_fdt_getprop to
>> report "property not found", because there's no way for the caller
>> to distinguish "property not found" from "function went wrong
>> some other way" (since Errors just report human readable strings,
>> and in any case you're not distinguishing -FDT_ERR_NOTFOUND
>> from any of the other FDT errors).
> Not sure I get what you mean here. In case fdt_getprop fails, as long as
> the caller provided a lenp != NULL, *lenp contains the error code so
> qemu_fdt_getprop's caller can discriminate a -FDT_ERR_NOTFOUND from any
> other errors. Do I miss something?
There's no documentation of this behaviour of qemu_fdt_getprop
in either this commit message or in a doc comment in the header,
so I didn't realise that was your intention.
thanks
-- PMM