Re: [PATCH] serial: core: Fix serial_base_match() after fixing controller port name

From: Andy Shevchenko
Date: Wed Aug 02 2023 - 17:46:20 EST


On Wed, Aug 02, 2023 at 03:48:26PM +0200, Greg Kroah-Hartman wrote:
> On Wed, Aug 02, 2023 at 02:48:43PM +0300, Tony Lindgren wrote:
> > While fixing DEVNAME to be more usable, I broke serial_base_match() as
> > the ctrl and port prefix for device seemed unnecessary.
> >
> > Let's fix the issue by checking against dev->type and drv->name.

...

> > + !strncmp(SERIAL_BASE_CTRL_NAME, drv->name, 4))
>
> maybe:
> !strncmp(SERIAL_BASE_CTRL_NAME, drv->name, strlen(SERIAL_BASE_CTRL_NAME))
>
> as "4" is a magic number :)

str_has_prefix() hides that.

--
With Best Regards,
Andy Shevchenko