linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] serial: core: Replace strncmp()+strlen() with plain strcmp()
@ 2023-07-27  9:05 Andy Shevchenko
  2023-07-27 11:59 ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2023-07-27  9:05 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Tony Lindgren, Dan Carpenter, linux-kernel,
	linux-serial
  Cc: Jiri Slaby, Andy Shevchenko

There is no sense to call strlen() ahead of strncmp().
The same effect can be achieved by calling strcmp() directly.
Replace strncmp()+strlen() with plain strcmp().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/tty/serial/serial_base_bus.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/tty/serial/serial_base_bus.c b/drivers/tty/serial/serial_base_bus.c
index 6ff59c89d867..bd056e6dca2f 100644
--- a/drivers/tty/serial/serial_base_bus.c
+++ b/drivers/tty/serial/serial_base_bus.c
@@ -21,9 +21,7 @@ static bool serial_base_initialized;
 
 static int serial_base_match(struct device *dev, struct device_driver *drv)
 {
-	int len = strlen(drv->name);
-
-	return !strncmp(dev_name(dev), drv->name, len);
+	return !strcmp(dev_name(dev), drv->name);
 }
 
 static struct bus_type serial_base_bus_type = {
-- 
2.40.0.1.gaa8946217a0b


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] serial: core: Replace strncmp()+strlen() with plain strcmp()
  2023-07-27  9:05 [PATCH v1 1/1] serial: core: Replace strncmp()+strlen() with plain strcmp() Andy Shevchenko
@ 2023-07-27 11:59 ` Andy Shevchenko
  2023-07-27 14:36   ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2023-07-27 11:59 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Tony Lindgren, Dan Carpenter, linux-kernel,
	linux-serial
  Cc: Jiri Slaby

On Thu, Jul 27, 2023 at 12:05:07PM +0300, Andy Shevchenko wrote:
> There is no sense to call strlen() ahead of strncmp().
> The same effect can be achieved by calling strcmp() directly.
> Replace strncmp()+strlen() with plain strcmp().

It seems I will have more against serial core, perhaps it makes sense to unite
them in a single series.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] serial: core: Replace strncmp()+strlen() with plain strcmp()
  2023-07-27 11:59 ` Andy Shevchenko
@ 2023-07-27 14:36   ` Andy Shevchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2023-07-27 14:36 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Tony Lindgren, Dan Carpenter, linux-kernel,
	linux-serial
  Cc: Jiri Slaby

On Thu, Jul 27, 2023 at 02:59:37PM +0300, Andy Shevchenko wrote:
> On Thu, Jul 27, 2023 at 12:05:07PM +0300, Andy Shevchenko wrote:
> > There is no sense to call strlen() ahead of strncmp().
> > The same effect can be achieved by calling strcmp() directly.
> > Replace strncmp()+strlen() with plain strcmp().
> 
> It seems I will have more against serial core, perhaps it makes sense to unite
> them in a single series.

Actually this change is simply wrong. Sorry for the noise.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-27 14:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-27  9:05 [PATCH v1 1/1] serial: core: Replace strncmp()+strlen() with plain strcmp() Andy Shevchenko
2023-07-27 11:59 ` Andy Shevchenko
2023-07-27 14:36   ` Andy Shevchenko

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).