Re: [PATCH 4/7] lib/vsprintf: Add support for generic FOURCCs by extending %p4cc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux