public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH linux-next] scsi: target: Use sysfs_streq() instead of strncmp()
@ 2022-11-14  3:40 yang.yang29
  0 siblings, 0 replies; only message in thread
From: yang.yang29 @ 2022-11-14  3:40 UTC (permalink / raw)
  To: martin.petersen
  Cc: linux-scsi, target-devel, linux-kernel, xu.panda, yang.yang29

From: Xu Panda <xu.panda@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: Xu Panda <xu.panda@zte.com.cn>
Signed-off-by: Yang Yang <yang.yang29@zte.com>
---
 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 b8a5c8d6cfde..119711c2bc08 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:
-- 
2.15.2

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-14  3:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-14  3:40 [PATCH linux-next] scsi: target: Use sysfs_streq() instead of strncmp() yang.yang29

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox