[SLOF] [PATCH] libc: Remove dead code in print_itoa()

Thomas Huth thuth at redhat.com
Mon Nov 30 21:52:47 AEDT 2015


On 30/11/15 06:18, Alexey Kardashevskiy wrote:
> On 11/28/2015 05:00 AM, Thomas Huth wrote:
>> When compiling SLOF with "-Wextra", GCC complains about this:
>>
>> libc/stdio/vsnprintf.c: In function ‘print_itoa’:
>> lib/libc/stdio/vsnprintf.c:33:2: warning: comparison of unsigned
>>                          expression < 0 is always false [-Wtype-limits]
>>    if(value < 0) {
>>    ^
>>
>> When looking more closely at the code, it seems like this is not
>> only dead code, but even wrong code, since the sign is already
>> handled in print_format()! So let's simply remove that dead code.
>>
>> Signed-off-by: Thomas Huth <thuth at redhat.com>
> 
> 
> Thanks, applied.

I just saw that skiboot (which uses the libc from SLOF) completely
reworked the vsnprintf function to use less stack by avoiding
the recursions in print_itoa:

https://github.com/open-power/skiboot/commits/master/libc/stdio/vsnprintf.c

Considering the stack overflow issues that I've hit last week:
Maybe you could have a look at the skiboot version of vsnprintf
and copy that back to SLOF if it's appropriate?

 Thomas



More information about the SLOF mailing list