Re: [PATCH v3 2/2] serial: core: Don't clobber the baud rate on hangup via B0
From: Andy Shevchenko
Date: Wed Nov 04 2026 - 06:54:18 EST
On Wed, Nov 04, 2026 at 12:28:22PM +0100, Johan Hovold wrote:
> On Wed, Nov 04, 2026 at 01:10:18PM +0200, Andy Shevchenko wrote:
> > On Tue, Nov 03, 2026 at 10:07:58PM +0000, Maciej W. Rozycki wrote:
...
> > > - baud = max(min, 9600);
> > > + baud = (port->hup_speed ?
> > > + port->hup_speed : max(min, 9600));
> >
> > Outer parentheses are redundant. Also use Elvis.
> >
> > baud = port->hup_speed ?: max(min, 9600);
>
> No, don't.
>
> Don't use the ternary operator at all as it tends to make code less
> readable.
I disagree. Elvis is readable as in Python, for example, or a simple English.
"Assign foo to baz OR bar" <——> "foo = baz ?: bar".
--
With Best Regards,
Andy Shevchenko