From patchwork Mon Jan 30 20:11:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak R Varma X-Patchwork-Id: 50455 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2377651wrn; Mon, 30 Jan 2023 12:19:55 -0800 (PST) X-Google-Smtp-Source: AK7set+zfalVbDRkdCiZsvtA24IAZ6nWM3zGsgfGQfiNfj38YZZT+OuCqw+JYQdo4/3J6JhI3ESw X-Received: by 2002:a05:6402:1f05:b0:4a0:af87:b3ab with SMTP id b5-20020a0564021f0500b004a0af87b3abmr21675261edb.36.1675109995130; Mon, 30 Jan 2023 12:19:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675109995; cv=none; d=google.com; s=arc-20160816; b=aXKzBhcxK91CGHB65SiuFlAC6FUOUFruM4m8FD/eCtnXgZu2WsZsREbVO+G4rrMk4R ERoBejgzyy31YMYuHEEMZzrgsIK62bX6ZMidhnWJVaddmHZxryLB94UjyEYv6LDolWje vLMQiItgxtKVaOTVpm/Ozf9i+SB7L1JXf89BFUUT6YngmXWY0u6Em9AbgL4OlpNdylLS qTBg/Iq8RU4gOVJlMFwkW4NPnYQ4PHWfwpLp47q2rebHQGDsqupGBSPR2pwulq9Zq0za 1Ax18QbpMkEbm8/QbNRwT9krLnax07rPnK1tTTP1pYRZToUNhMEewFxTrwOa96virmRV 6vfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=FApCUrWDdINL9pAVEigvA8ACVjEbOKdzO+xBGmPQq8U=; b=kbpeNoWdrYtfm9tbzRrKzPcgAmdpt/io99CSzBp2L037v8xPilyX2pqTGjX41mtQnC C5LvNpIznPBk4sdVzvUGi0e9rllzLH2VWTLoWUH7xB09yo+9lcy4Hg4wNiDhcaXcZVNI 9gvtaaplxoulu4AgmYWOYtcF4VHHiaaXlYOKIcEg78jyQAr4ZEJnQIqnLn7sDHwnxpww jkLuJh1yPBRjeJPsufBR+SlO0LrmqMPJBW+v/KqN8q/D466MnMT5cPNghj4YWpliI/7B 3PxS7CFBAuoXbQtJBa5kSo5T9WP4Lrut5eDZ6Gslw/dtXTyHW6dGAVthneNgM6MXlEKG cGOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=QuTK57b7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c21-20020a056402101500b0045d4b7ad162si12698966edu.546.2023.01.30.12.19.31; Mon, 30 Jan 2023 12:19:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=QuTK57b7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235820AbjA3ULy (ORCPT + 99 others); Mon, 30 Jan 2023 15:11:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229880AbjA3ULw (ORCPT ); Mon, 30 Jan 2023 15:11:52 -0500 Received: from msg-4.mailo.com (msg-4.mailo.com [213.182.54.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B47512FCF1; Mon, 30 Jan 2023 12:11:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1675109502; bh=nC23UKSb0CmGocYhYebIyi10v6NzVHfWuPVuA9RD+5I=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=QuTK57b7o/69VDAZrW7lKs8+nJE7zG+fk6wAtsjgtMF6fUalsrWIgVOzYuoLFMfwv adxJ9jUqf7Y/M8OXiNG3PGli/FN2BhrKTYQHYoQ2YUTBPmkCxDZeOODGCNCEmPn8eJ zBrROeaQDSQD3tMrIsraAOV51Tx0APGRqjBITCFw= Received: by b-6.in.mailobj.net [192.168.90.16] with ESMTP via ip-206.mailobj.net [213.182.55.206] Mon, 30 Jan 2023 21:11:42 +0100 (CET) X-EA-Auth: 9BdPFPNc5sSrJyZcSmB10vMudrlezrc6mxTOerZXdgYNx8zZQVr5xiB7fuksed7xAGNutcqN2W47ExxVo319+oQkO1t/HNNZ Date: Tue, 31 Jan 2023 01:41:38 +0530 From: Deepak R Varma To: Hannes Reinecke , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Saurabh Singh Sengar , Praveen Kumar , Deepak R Varma Subject: [PATCH] scsi: fcoe: Use sysfs_emit in show function callback Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_FILL_THIS_FORM_SHORT autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756480138614584643?= X-GMAIL-MSGID: =?utf-8?q?1756480138614584643?= According to Documentation/filesystems/sysfs.rst, show() callback function should only use sysfs_emit() or sysfs_emit_at() instead of sprint() family functions when formatting the device attribute values to be returned to user space. Issue identified using the device_attr_show.cocci Coccinelle script. Signed-off-by: Deepak R Varma --- drivers/scsi/fcoe/fcoe_sysfs.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c index 6260aa5ea6af..9c50971c4bba 100644 --- a/drivers/scsi/fcoe/fcoe_sysfs.c +++ b/drivers/scsi/fcoe/fcoe_sysfs.c @@ -250,7 +250,7 @@ static ssize_t show_fcf_state(struct device *dev, name = get_fcoe_fcf_state_name(fcf->state); if (!name) return -EINVAL; - return snprintf(buf, FCOE_FCF_STATE_MAX_NAMELEN, "%s\n", name); + return sysfs_emit(buf, "%s\n", name); } static FCOE_DEVICE_ATTR(fcf, state, S_IRUGO, show_fcf_state, NULL); @@ -265,8 +265,7 @@ static ssize_t show_ctlr_mode(struct device *dev, name = get_fcoe_ctlr_mode_name(ctlr->mode); if (!name) return -EINVAL; - return snprintf(buf, FCOE_MAX_MODENAME_LEN, - "%s\n", name); + return sysfs_emit(buf, "%s\n", name); } static ssize_t store_ctlr_mode(struct device *dev, @@ -373,8 +372,7 @@ static ssize_t show_ctlr_enabled_state(struct device *dev, name = get_fcoe_ctlr_enabled_state_name(ctlr->enabled); if (!name) return -EINVAL; - return snprintf(buf, FCOE_CTLR_ENABLED_MAX_NAMELEN, - "%s\n", name); + return sysfs_emit(buf, "%s\n", name); } static FCOE_DEVICE_ATTR(ctlr, enabled, S_IRUGO | S_IWUSR, @@ -412,7 +410,7 @@ static ssize_t show_ctlr_fip_resp(struct device *dev, struct fcoe_ctlr_device *ctlr = dev_to_ctlr(dev); struct fcoe_ctlr *fip = fcoe_ctlr_device_priv(ctlr); - return sprintf(buf, "%d\n", fip->fip_resp ? 1 : 0); + return sysfs_emit(buf, "%d\n", fip->fip_resp ? 1 : 0); } static FCOE_DEVICE_ATTR(ctlr, fip_vlan_responder, S_IRUGO | S_IWUSR, @@ -455,7 +453,7 @@ static ssize_t show_ctlr_r_a_tov(struct device *dev, struct fcoe_ctlr_device *ctlr_dev = dev_to_ctlr(dev); struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(ctlr_dev); - return sprintf(buf, "%d\n", ctlr->lp->r_a_tov); + return sysfs_emit(buf, "%d\n", ctlr->lp->r_a_tov); } static FCOE_DEVICE_ATTR(ctlr, r_a_tov, S_IRUGO | S_IWUSR, @@ -482,7 +480,7 @@ static ssize_t show_ctlr_e_d_tov(struct device *dev, struct fcoe_ctlr_device *ctlr_dev = dev_to_ctlr(dev); struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(ctlr_dev); - return sprintf(buf, "%d\n", ctlr->lp->e_d_tov); + return sysfs_emit(buf, "%d\n", ctlr->lp->e_d_tov); } static FCOE_DEVICE_ATTR(ctlr, e_d_tov, S_IRUGO | S_IWUSR,