lkml.org 
[lkml]   [2022]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/5] x86/alternative: simplify DUMP_BYTES macro
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.
Format specifiers aren't the purpose of the patch anyway.

> And MAX_PATCH_LEN is 255 but is that really possible?

Yes if you try hard enough.

> Maybe if the actual patch length is always <= 64 this could use
> printk(KERN_CONT "%*ph\n", (int)len, buf);
> instead and avoid all possible interleaving?

It is for debugging feature nobody uses (because it works).

\
 
 \ /
  Last update: 2022-03-13 19:11    [W:0.081 / U:0.588 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site