[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] tweaks: make three conversion specifications more compliant
From: |
Benno Schulenberg |
Subject: |
Re: [PATCH] tweaks: make three conversion specifications more compliant |
Date: |
Sat, 8 May 2021 12:54:16 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
Op 08-05-2021 om 08:18 schreef Hussam al-Homsi:
> - sprintf(info, "%4ju %cB", (intmax_t)result,
> modifier);
> + sprintf(info, "%4jd %cB", (intmax_t)result,
> modifier);
It should not be possible for a file to have a negative size, so %d should
not be used. The 'result' is of type off_t, which I expect to be unsigned
(I can't find its definition), so I don't understand why that intmax_t cast
is there.
> - sprintf(hexadecimal, "U+%04X", (unsigned
> char)*this_position);
> + sprintf(hexadecimal, "U+%04hhX", (unsigned
> char)*this_position);
When using "hh", the cast is superfluous. And the other way around.
I prefer the cast.
Benno
signature.asc
Description: OpenPGP digital signature