[PATCH] spl: add %z support for tiny-printf

Sean Anderson sean.anderson at seco.com
Mon Feb 14 17:37:37 CET 2022



On 2/14/22 10:52 AM, Tom Rini wrote:
> On Mon, Feb 14, 2022 at 08:04:35PM +0800, Du Huanpeng wrote:
> 
>> the %zx format are used in spl from files below:
>>   lib/lzma/LzmaTools.c
>>   common/malloc_simple.c
>> 
>> it results output like "... 0xx", "size=x" output,
>> treat '%z' as '%l' to support `ssize_t' type.
>> 
>> Signed-off-by: Du Huanpeng <dhu at hodcarrier.org>
>> ---
>>  lib/tiny-printf.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c
>> index 8fc7e48..4b65f72 100644
>> --- a/lib/tiny-printf.c
>> +++ b/lib/tiny-printf.c
>> @@ -228,7 +228,7 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
>>  					ch = *fmt++;
>>  				}
>>  			}
>> -			if (ch == 'l') {
>> +			if (ch == 'l' || ch == 'z') {
>>  				ch = *(fmt++);
>>  				islong = true;
>>  			}
> 
> Generally, we try and change code rather than add more support to
> tiny-printf as it's supposed to stay as tiny as possible.  See 
> eebcdb34d061 ("malloc_simple: Remove usage of unsupported %zx format
> string") for a recent example.
> 

Perhaps we should add a macro like PRIz which expands to "u", "lu",
or "llu" as appropriate. This would let us keep code size the same.
The problem with this of course is that as far as can tell
simple_printf does not support llu...

--Sean


More information about the U-Boot mailing list