From patchwork Fri Dec 23 20:07:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak R Varma X-Patchwork-Id: 36336 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp489709wrn; Fri, 23 Dec 2022 12:09:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXsHJDFQWu8rTxf1euiTVuong7RupzSkLV2y6d0mZhkuM3mZW7DAqheUsiRu0A02gQunmhtX X-Received: by 2002:a05:6a20:c51b:b0:ad:b91c:96d7 with SMTP id gm27-20020a056a20c51b00b000adb91c96d7mr12459047pzb.51.1671826170717; Fri, 23 Dec 2022 12:09:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671826170; cv=none; d=google.com; s=arc-20160816; b=yF60QRReP0VvZYnDFPj7KYno23U+bgnn6E/pGKJdrIWmIKZvpOPBj8Frr+2QPpLtJb YOv6xEaLIGuHrqHfzxYbaZe0q12pcF9FYRzwaI1YAzhBHGw2A1QZ31SNX1tNoiGwv+uz B2XM3SJSgmzka0TaOai4IoPcAEBLxlI0ZFO0FDezyWUnm3SJbGBH5MiDzpCWLx50tRuC px3Qm/hsrlrAWez5bdKOU1wKtvlIFU16l9BxO6uSd1ErXhtz6Odd1/DRq2hRTQ8WTdIn bMBePYq75dl02xsl3yUKHUmyFxX0t5PEffwdkdSuEmWEiZO9eCsyus47fR+yDsMleVSD cI/w== 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=5l33XDHO0FMkWPqo1kPYabTloYpcbYHPsTzDP5V+7Vk=; b=I2Rwz5kAWixRFek0HZzIrSfuSWvpbESgBcwZZbxARVJ+e117C7HvkQ2PaJErEcGAA1 gjLo+dXNBhTbejlq1d3ZzlDOc4y/FPUnEP/GEhvDo0B5GwVSA4s+c1CzlSI5V1ykxLs3 IawdFKT3GF301RB9WEIP5HQO0fLobKMAY8MdISZebPKEn3+vr+aZDP6o/YGiwISEHEo+ d3S1fv2cB00EDtb1DNxQL8dgJMMr32zjyvNVbak3cKf1bpOgdlyZEE83f8VXA5APJ2vt Oe3LS0v+C9ZIv+tg+7/3sLA0s38UEnQWPzzV8V74bJ5vQ33rvq6fVEd3Fr+GfeO+9gtq IHjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=f0BJtlf2; 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 o17-20020a639211000000b004620564706dsi1506175pgd.730.2022.12.23.12.09.18; Fri, 23 Dec 2022 12:09:30 -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=f0BJtlf2; 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 S233400AbiLWUJC (ORCPT + 99 others); Fri, 23 Dec 2022 15:09:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233167AbiLWUIm (ORCPT ); Fri, 23 Dec 2022 15:08:42 -0500 Received: from msg-2.mailo.com (msg-2.mailo.com [213.182.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B00114013; Fri, 23 Dec 2022 12:08:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1671826053; bh=14iqMvlBXFPuwkQ+tLG2S5XN85mJQwSd2VCBQKPJQ2Y=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=f0BJtlf27AF0+t+MM3ffTfbc27/OI2QI5s8yF7lyYk5rFUwmhlbtPzrXHxKh3uujF MnffusfnpFL/TGEvFTKCd4sGZ4t2iE2zxSomAzblls8VrMt7ZgHEh4+TEUtfU+yVhm TxeH/lakgM8h4h/e6X2o4s/w1+VlTTarA1/Y3Ctc= Received: by b-1.in.mailobj.net [192.168.90.11] with ESMTP via ip-206.mailobj.net [213.182.55.206] Fri, 23 Dec 2022 21:07:31 +0100 (CET) X-EA-Auth: Po/4f9zZ+atWMjHK+A87Io28wXW8i5FBiLXWDIn25T46cPd5/Uz1Wn/w8JYRR2v0y1QrBCN0KtmTW1c08UzSGJFyccq4Ei6n Date: Sat, 24 Dec 2022 01:37:26 +0530 From: Deepak R Varma To: "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: scsi_transport_sas: Use sysfs_emit in show function callsbacks 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?1753036798648098425?= X-GMAIL-MSGID: =?utf-8?q?1753036798648098425?= According to Documentation/filesystems/sysfs.rst, the show() callback function of kobject attributes should strictly use sysfs_emit() instead of sprintf() family functions. Issue identified using the coccinelle device_attr_show.cocci script. Signed-off-by: Deepak R Varma --- drivers/scsi/scsi_transport_sas.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.34.1 diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c index 74b99f2b0b74..5504067adcf1 100644 --- a/drivers/scsi/scsi_transport_sas.c +++ b/drivers/scsi/scsi_transport_sas.c @@ -522,7 +522,7 @@ show_sas_device_type(struct device *dev, struct sas_phy *phy = transport_class_to_phy(dev); if (!phy->identify.device_type) - return snprintf(buf, 20, "none\n"); + return sysfs_emit(buf, "none\n"); return get_sas_device_type_names(phy->identify.device_type, buf); } static DEVICE_ATTR(device_type, S_IRUGO, show_sas_device_type, NULL); @@ -569,7 +569,7 @@ show_sas_phy_enable(struct device *dev, struct device_attribute *attr, { struct sas_phy *phy = transport_class_to_phy(dev); - return snprintf(buf, 20, "%d\n", phy->enabled); + return sysfs_emit(buf, "%d\n", phy->enabled); } static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, show_sas_phy_enable, @@ -1177,7 +1177,7 @@ show_sas_rphy_device_type(struct device *dev, struct sas_rphy *rphy = transport_class_to_rphy(dev); if (!rphy->identify.device_type) - return snprintf(buf, 20, "none\n"); + return sysfs_emit(buf, "none\n"); return get_sas_device_type_names( rphy->identify.device_type, buf); }