[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <793b7cd9b229bc9427539c683524572259f2893b.camel@perches.com>
Date: Sun, 13 Mar 2022 20:21:15 -0700
From: Joe Perches <joe@...ches.com>
To: Alexey Dobriyan <adobriyan@...il.com>
Cc: x86@...nel.org, tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
dave.hansen@...ux.intel.com, hpa@...or.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/5] x86/alternative: simplify DUMP_BYTES macro
On Sun, 2022-03-13 at 21:09 +0300, Alexey Dobriyan wrote:
> On Sat, Mar 12, 2022 at 08:36:11AM -0800, Joe Perches wrote:
> > On Fri, 2022-03-11 at 17:43 +0300, Alexey Dobriyan wrote:
> > > Avoid zero length check with clever whitespace placement in the format
> > > string.
> > []
> > > diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
> > []
> > > @@ -66,13 +66,10 @@ do { \
> > > if (unlikely(debug_alternative)) { \
> > > int j; \
> > > \
> > > - if (!(len)) \
> > > - break; \
> > > - \
> > > printk(KERN_DEBUG pr_fmt(fmt), ##args); \
> > > - for (j = 0; j < (len) - 1; j++) \
> > > - printk(KERN_CONT "%02hhx ", buf[j]); \
> > > - printk(KERN_CONT "%02hhx\n", buf[j]); \
> > > + for (j = 0; j < (len); j++) \
> > > + printk(KERN_CONT " %02hhx", buf[j]); \
> > > + printk(KERN_CONT "\n"); \
> > > } \
> >
> > This could also use %02x and not %02hhx
>
> I doubt as there is funky stuff possible with 255 and such values.
'"%02hhx", u8' and '"%02x", u8' have the same output as the
u8 is converted anyway given the integer promotions.
https://lore.kernel.org/lkml/CAHk-=wgoxnmsj8GEVFJSvTwdnWm8wVJthefNk2n6+4TC=20e0Q@mail.gmail.com/
> Format specifiers aren't the purpose of the patch anyway.
IMO: If you are already touching the lines,
you might as well fix it at the same time.
cheers, Joe
Powered by blists - more mailing lists