linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Denis Mukhin <dmkhn@proton.me>
Cc: dmukhin@ford.com, Jonathan Corbet <corbet@lwn.net>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] x86/early_printk: add MMIO-based UARTs
Date: Wed, 19 Mar 2025 23:16:52 +0100	[thread overview]
Message-ID: <Z9tCVIPTZr10WnNq@gmail.com> (raw)
In-Reply-To: <wlidpR0nAfMoUkVTrtOogcSBeZ8pEKU32ZCubunTj3-kDUj4hKY0fJAAQD11aFA5xkGAH9qV2tNee7yB5qJof_lq9zxdXAfzR0Fm6mf5cqI=@proton.me>


* Denis Mukhin <dmkhn@proton.me> wrote:

> Hi,
> 
> Thanks for taking a look!
> 
> On Monday, March 17th, 2025 at 12:58 AM, Ingo Molnar <mingo@kernel.org> wrote:
> 
> >
> >
> >
> > * Denis Mukhin via B4 Relay devnull+dmukhin.ford.com@kernel.org wrote:
> >
> > > + if (!strncmp(s, "nocfg", 5))
> > > + baudrate = 0;
> > > + else {
> > > + baudrate = simple_strtoul(s, &e, 0);
> > > + if (baudrate == 0 || s == e)
> > > + baudrate = DEFAULT_BAUD;
> > > + }
> >
> >
> > In standard kernel coding style we always balance curly braces and
> > don't skip them in the single-statement case. Ie. the above should be:
> >
> > if (!strncmp(s, "nocfg", 5)) {
> > baudrate = 0;
> > } else {
> >
> > > + if (baudrate)
> > > + early_serial_hw_init(115200 / baudrate);
> >
> >
> > Hm, I think that division will go poorly if 'baudrate' ends up being 0
> > in the 'nocfg' case ... ;-)
> 
> This patch has a guardrail:
>   early_serial_hw_init(115200 / baudrate);
> will not be called in case of baudrate is 0.

Ugh, I must have had very limited reading comprehension that day :-/

> I can re-write code to avoid confusion.

No need to rewrite, the code is clear enough, it's my fault. :-)

But please do send -v3 with the curly braces fix, and merged against 
the latest x86 tree at:

  git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git master

because there's a pending commit that creates a conflict:

  306859de59e5 ("x86/early_printk: Harden early_serial")

... while the conflict looks simple enough, it would be best to also 
test it, etc.

Thanks,

	Ingo

      reply	other threads:[~2025-03-19 22:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-14 20:09 [PATCH v2] x86/early_printk: add MMIO-based UARTs Denis Mukhin via B4 Relay
2025-03-17  7:58 ` Ingo Molnar
2025-03-18 23:39   ` Denis Mukhin
2025-03-19 22:16     ` Ingo Molnar [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z9tCVIPTZr10WnNq@gmail.com \
    --to=mingo@kernel.org \
    --cc=bp@alien8.de \
    --cc=corbet@lwn.net \
    --cc=dave.hansen@linux.intel.com \
    --cc=dmkhn@proton.me \
    --cc=dmukhin@ford.com \
    --cc=hpa@zytor.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).