All of lore.kernel.org
 help / color / mirror / Atom feed
From: <guo.ziliang@zte.com.cn>
To: <target-devel@vger.kernel.org>
Cc: <martin.petersen@oracle.com>, <linux-scsi@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <guo.ziliang@zte.com.cn>
Subject: [PATCH linux-next] scsi: target: Use sysfs_streq instead of strncmp
Date: Thu, 17 Nov 2022 09:50:09 +0800 (CST)	[thread overview]
Message-ID: <202211170950093878676@zte.com.cn> (raw)

From: guo ziliang <guo.ziliang@zte.com.cn>
There is a ready-to-use method to compare a retrieved from a sysfs node
string with another string. It treats both NUL and newline-then-NUL as
equivalent string terminations. So use it instead of manually truncating
the line length in the strncmp() method.

Signed-off-by: guo ziliang <guo.ziliang@zte.com.cn>
---
 drivers/target/target_core_configfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index f4a220a..3b89d83 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -208,7 +208,7 @@ static struct config_group *target_core_register_fabric(
                 * mkdir(2) system calls with known TCM fabric modules.
                 */

-               if (!strncmp(name, "iscsi", 5)) {
+               if (sysfs_streq(name, "iscsi")) {
                        /*
                         * Automatically load the LIO Target fabric module when the
                         * following is called:
@@ -221,7 +221,7 @@ static struct config_group *target_core_register_fabric(
                                         " iscsi_target_mod.ko: %d\n", ret);
                                return ERR_PTR(-EINVAL);
                        }
-               } else if (!strncmp(name, "loopback", 8)) {
+               } else if (sysfs_streq(name, "loopback")) {
                        /*
                         * Automatically load the tcm_loop fabric module when the
                         * following is called:
--
1.8.3.1

                 reply	other threads:[~2022-11-17  1:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=202211170950093878676@zte.com.cn \
    --to=guo.ziliang@zte.com.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=target-devel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.