[U-Boot] [PATCH 01/19] lib: errno: introduce errno_str(): returns errno related message
Simon Glass
sjg at chromium.org
Fri Oct 10 00:53:14 CEST 2014
On 9 October 2014 10:23, Przemyslaw Marczak <p.marczak at samsung.com> wrote:
> Hello Joakim,
>
> On 10/09/2014 08:46 AM, Joakim Tjernlund wrote:
>
>> From: Przemyslaw Marczak <p.marczak at samsung.com>
>>>
>>> The functions error's numbers are standarized - but the error
>>> messages are not.
>>>
>>> The errors are often handled with unclear error messages,
>>> so why not use an errno standarized messages.
>>>
>>> Advantages:
>>> - This could decrease the binary size.
>>>
>>
>> Having an array of string ptrs adds some extra space needs.
>> Each str needs a ptr and that ptr needs relocation, 8 bytes on 32 bits
>>
>> If you want to save space do this instead
>> static const char const errno_message[] =
>> "Success\0Operation not permitted\0No such file or directory" etc.
>> Then count "\0" to find the error msg.
>>
>> Jocke
>>
>>
> Is this really a problem to add some array with the pointers?
>
> You are right, this array requires some additional space, but this is not
> the main reason of introducing this function. This can be enabled optional,
> so maybe for the less memory and slower devices this shouldn't be used -
> but in the other way, we see many text messages in the code that could be
> replaced with the one from that array.
> So, which is better?
>
> This helps me sometimes, so I added this as some extra feature.
>
I think it looks good as it is as it is simple. My only suggestion is that
the CONFIG should not remove the function, merely make it return an empty
string or "Error strings unavailable". Otherwise you will force #ifdefs in
the code.
Regards,
Simon
More information about the U-Boot
mailing list