[PATCH 4/7] lib/vsprintf: Add support for generic FOURCCs by extending %p4cc
Andy Shevchenko
andriy.shevchenko at linux.intel.com
Wed Oct 19 04:20:25 PDT 2022
On Wed, Oct 19, 2022 at 12:00:23PM +0200, Petr Mladek wrote:
> On Tue 2022-09-06 14:19:44, Russell King wrote:
> > From: Hector Martin <marcan at marcan.st>
...
> > for (i = 0; i < sizeof(u32); i++) {
> > - unsigned char c = val >> (i * 8);
> > + unsigned char c = val >> ((3 - i) * 8);
>
> This hardcodes '3' but the for-cycle uses i < sizeof(u32).
> We should be consistent.
>
> A solution would be:
>
> int i;
>
> for (i = sizeof(u32); --i >= 0;) {
> unsigned char c = val >> (i * 8);
With while-loop it might be more readable:
unsigned int i = sizeof(u32);
while (i--) {
...
}
> > /* Print non-control ASCII characters as-is, dot otherwise */
> > *p++ = isascii(c) && isprint(c) ? c : '.';
> > }
--
With Best Regards,
Andy Shevchenko
More information about the linux-arm-kernel
mailing list