From patchwork Thu Nov 17 01:50:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: guo.ziliang@zte.com.cn X-Patchwork-Id: 13046025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0B6FC433FE for ; Thu, 17 Nov 2022 01:50:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234234AbiKQBuk (ORCPT ); Wed, 16 Nov 2022 20:50:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233963AbiKQBuk (ORCPT ); Wed, 16 Nov 2022 20:50:40 -0500 Received: from mxct.zte.com.cn (mxct.zte.com.cn [58.251.27.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 422655BD75; Wed, 16 Nov 2022 17:50:39 -0800 (PST) Received: from mxde.zte.com.cn (unknown [10.35.20.165]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mxct.zte.com.cn (FangMail) with ESMTPS id 4NCNCx38RmzvM0; Thu, 17 Nov 2022 09:50:37 +0800 (CST) Received: from mxus.zte.com.cn (unknown [10.207.168.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mxde.zte.com.cn (FangMail) with ESMTPS id 4NCNCg1rrQz64WfR; Thu, 17 Nov 2022 09:50:23 +0800 (CST) Received: from mxhk.zte.com.cn (unknown [192.168.250.137]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mxus.zte.com.cn (FangMail) with ESMTPS id 4NCNCb5JGRzdmc16; Thu, 17 Nov 2022 09:50:19 +0800 (CST) Received: from mse-fl2.zte.com.cn (unknown [10.5.228.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4NCNCX3t31z8R039; Thu, 17 Nov 2022 09:50:16 +0800 (CST) Received: from xaxapp01.zte.com.cn ([10.88.40.50]) by mse-fl2.zte.com.cn with SMTP id 2AH1o8FT092758; Thu, 17 Nov 2022 09:50:08 +0800 (+08) (envelope-from guo.ziliang@zte.com.cn) Received: from mapi (xaxapp03[null]) by mapi (Zmail) with MAPI id mid32; Thu, 17 Nov 2022 09:50:09 +0800 (CST) Date: Thu, 17 Nov 2022 09:50:09 +0800 (CST) X-Zmail-TransId: 2afb63759351fffffffff87339c3 X-Mailer: Zmail v1.0 Message-ID: <202211170950093878676@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , Subject: =?utf-8?q?=5BPATCH_linux-next=5D_scsi=3A_target=3A_Use_sysfs=5Fstre?= =?utf-8?q?q_instead_of_strncmp?= X-MAIL: mse-fl2.zte.com.cn 2AH1o8FT092758 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.251.14.novalocal with ID 6375936C.000 by FangMail milter! X-FangMail-Envelope: 1668649837/4NCNCx38RmzvM0/6375936C.000/10.35.20.165/[10.35.20.165]/mxde.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 6375936C.000/4NCNCx38RmzvM0 Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org From: guo ziliang 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 --- drivers/target/target_core_configfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 1.8.3.1 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: