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@xxxxxxxxx> ... > > 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