From patchwork Tue Jan 31 17:37:41 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: 50987 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp38498wrn; Tue, 31 Jan 2023 09:43:45 -0800 (PST) X-Google-Smtp-Source: AK7set8hgfgSfEqj3HRtinunSvQHyiQz+NXhfkBkcjOBU3CgZAZ+OgML/7r0G5jyTq15BjM+Zsxh X-Received: by 2002:a17:906:275b:b0:88a:d7dc:2dbe with SMTP id a27-20020a170906275b00b0088ad7dc2dbemr5641150ejd.74.1675187024902; Tue, 31 Jan 2023 09:43:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675187024; cv=none; d=google.com; s=arc-20160816; b=MPR8/rPWNcRhQM2Sb07IW3rnz4+pdPHD8TkbFvgCTIT1JIjZlUO/Iw/S+sy4HN9VEY 3X1JXTHZJwriD/UgiOvudVCqRju2NPmn9e/eSDMNHxc4KNdaNaBhHBtPw2CupS1ad+mT BdJpUh86MgmsqF78Ici3Q0N1aYl3etlJERszJ18EMIDrQG5v8bPKuT+03iMlqphUr6+C Hwgw7A0vGZIQ2LyLCYutqECQ9mq7c+4uJ9yftfrUMEgPZ5uMip7u32KSOij7i7+etDwd 3rBhFllcI/HID8P8OUjq8J1p3ErF57kZRiJHKlhm2ph0Cni2v1UdewixYXoFA86NU5pr BK1Q== 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=V190nF+zI06HZEuu4OaRYPhrWPbjs8R8Jf7x0ZO39Gw=; b=OqJ9PHq33uFeeK6kvTDJCYF2et0cmJjfm6BQ0vTs11l8+6Y8TqHFFmup6NO6jD04uK iCCpNtHwcZNuZdCmGFWua+HVmvX/eXmhtiz9NuDNsb2vh2CYZnbNj02Fa9Oc4Pg4411E zCF/tsPfTGlI6OYXuDOi1gFDPUwEyNHUrcmNG3kPDUutm24JL5RusSxAvzszby80qGfv 1mRnF6UMie9SO/GNS9ccfALzT7fqAl+mnNg85ErKMsLWYMzXeMlXRK4tXNPYunz2dNFU VuQZs6bjH9QQjPs1QfJKT+Vwh9887fN8z53BYY7Lj3yJSJuYJfjNA863M26POmeCTQTu 0YmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=lpPM2mnq; 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 j13-20020a170906104d00b008697a71e4e9si20378003ejj.941.2023.01.31.09.43.20; Tue, 31 Jan 2023 09:43:44 -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=lpPM2mnq; 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 S230321AbjAaRiD (ORCPT + 99 others); Tue, 31 Jan 2023 12:38:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229844AbjAaRiC (ORCPT ); Tue, 31 Jan 2023 12:38:02 -0500 Received: from msg-4.mailo.com (msg-4.mailo.com [213.182.54.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC78914210; Tue, 31 Jan 2023 09:37:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1675186665; bh=Rrwh2aeXNtku7IRRh7dET1V89izwqHEMKEn0S9UYy3Q=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=lpPM2mnqCUYymcSswXZ90ByW2ddWrartqVHsN/ZFMCjbjnNd7IMJaz+Gh/N556HQp Qvgp88P+3AUZhrkkN/jygeqn2hEMIwZwa7h+sdBp+ieG1XKpo+GwKNcXBuMfs6MZZs wH3fGtDh1I2fg7cpghc4XX8LeR4dz+6PbxdnSj1w= Received: by b-3.in.mailobj.net [192.168.90.13] with ESMTP via ip-206.mailobj.net [213.182.55.206] Tue, 31 Jan 2023 18:37:45 +0100 (CET) X-EA-Auth: oKy7x5t6P9EgRyHvNtM0M383put+qGVSUqDmUVzeretjO22/5XaYS+xL7mC1raYrYP8kdJjStTib1c3QrBhLck+w9La7w8qy Date: Tue, 31 Jan 2023 23:07:41 +0530 From: Deepak R Varma To: Karan Tilak Kumar , Sesidhar Baddela , "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 v2] scsi: snic: 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 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?1756560909295243879?= X-GMAIL-MSGID: =?utf-8?q?1756560909295243879?= 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 --- Changes in v2: - Simplify patch log message based on feedback received from ALOK TIWARI drivers/scsi/snic/snic_attrs.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/snic/snic_attrs.c b/drivers/scsi/snic/snic_attrs.c index 3ddbdbc3ded1..56c46ea06e60 100644 --- a/drivers/scsi/snic/snic_attrs.c +++ b/drivers/scsi/snic/snic_attrs.c @@ -13,7 +13,7 @@ snic_show_sym_name(struct device *dev, { struct snic *snic = shost_priv(class_to_shost(dev)); - return snprintf(buf, PAGE_SIZE, "%s\n", snic->name); + return sysfs_emit(buf, "%s\n", snic->name); } static ssize_t @@ -23,8 +23,7 @@ snic_show_state(struct device *dev, { struct snic *snic = shost_priv(class_to_shost(dev)); - return snprintf(buf, PAGE_SIZE, "%s\n", - snic_state_str[snic_get_state(snic)]); + return sysfs_emit(buf, "%s\n", snic_state_str[snic_get_state(snic)]); } static ssize_t @@ -32,7 +31,7 @@ snic_show_drv_version(struct device *dev, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%s\n", SNIC_DRV_VERSION); + return sysfs_emit(buf, "%s\n", SNIC_DRV_VERSION); } static ssize_t @@ -45,8 +44,7 @@ snic_show_link_state(struct device *dev, if (snic->config.xpt_type == SNIC_DAS) snic->link_status = svnic_dev_link_status(snic->vdev); - return snprintf(buf, PAGE_SIZE, "%s\n", - (snic->link_status) ? "Link Up" : "Link Down"); + return sysfs_emit(buf, "%s\n", (snic->link_status) ? "Link Up" : "Link Down"); } static DEVICE_ATTR(snic_sym_name, S_IRUGO, snic_show_sym_name, NULL);