Re: [PATCH] EDAC/mce_amd: Do not print a stray newline

From: Yazen Ghannam

Date: Fri Aug 14 2026 - 09:47:06 EST


On Wed, Aug 12, 2026 at 04:58:39PM -0700, Borislav Petkov wrote:
> On Tue, Jul 14, 2026 at 09:04:55AM -0400, Yazen Ghannam wrote:
> > - pr_emerg(HW_ERR "%s Ext. Error Code: %d", smca_get_long_name(bank_type), xec);
> > + memset(buf, 0, sizeof(buf));
> > + p = buf;
> > + end = buf + sizeof(buf);
> > +
> > + p += scnprintf(p, end - p, "%s Ext. Error Code: %d", smca_get_long_name(bank_type), xec);
> > +
> > + pr_emerg(HW_ERR "%s", buf);
>
> Yes, I think this is the right idea, albeit with a couple of improvements:
>
> 1. We should define our own vararg log() function - static, used only in this
> file, which gets a format string and params and vscnprintf()s into our
> local, heap-allocated string array of 256 initially, we can grow it later
> if needed
>
> 2. Function will be a fire-and-forget and should not care about ptr
> advancement, buffer size, yadda yadda - log() will do that
>
> 3. When string buffer is full, log() will complain ofc.
>
> 4. When logging is done, we will have log_print() which goes over the whole
> string array and splits it into, say, 100-ish chars and breaks the lines
> then, during printing. We would use a space " " so that we can mark where
> we can break the string

The delimiter would need more thought. There are a few strings with
spaces like "Ext. Error Code", etc. Though maybe you mean we can use
extra spaces like double-space between strings?

>
> 5. No locking yet - we can do that later, if really needed
>
> This way we'll be able to handle all kinds of error record formats but still
> keep them compact enough so that they can go out in a couple of printk()
> calls.
>
> The other advantage when having a buffer like that is, if you look at kdump
> memory image, you can find the buffer in memory and actually dump its contents
> - one more way to get to the error.
>
> Thoughts?
>
> Lemme know if you have cycles to do this. If not, I can take a stab at it
> myself.
>

I like the idea but I'm not familiar with the concepts. It'll take me
some time to figure it out, so I don't have cycles to do it now.

Thanks,
Yazen