From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Tony Lindgren <tony@atomide.com>,
Dan Carpenter <dan.carpenter@linaro.org>,
linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Cc: Jiri Slaby <jirislaby@kernel.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 1/1] serial: core: Replace strncmp()+strlen() with plain strcmp()
Date: Thu, 27 Jul 2023 12:05:07 +0300 [thread overview]
Message-ID: <20230727090507.81962-1-andriy.shevchenko@linux.intel.com> (raw)
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
next reply other threads:[~2023-07-27 9:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-27 9:05 Andy Shevchenko [this message]
2023-07-27 11:59 ` [PATCH v1 1/1] serial: core: Replace strncmp()+strlen() with plain strcmp() Andy Shevchenko
2023-07-27 14:36 ` Andy Shevchenko
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=20230727090507.81962-1-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=dan.carpenter@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=tony@atomide.com \
/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).