From patchwork Mon Jan 30 19:32:45 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: 50441 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2365244wrn; Mon, 30 Jan 2023 11:51:29 -0800 (PST) X-Google-Smtp-Source: AK7set/ACHLMFJ2ThutCEoyIG65cW/y8wmx2gNTjxrM5UvTEbtStB8yS/UwJnh6vtdCcycyq6ZMT X-Received: by 2002:a05:6a20:158a:b0:bd:23a2:8840 with SMTP id h10-20020a056a20158a00b000bd23a28840mr5984045pzj.35.1675108288873; Mon, 30 Jan 2023 11:51:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675108288; cv=none; d=google.com; s=arc-20160816; b=Z3hC0JybyExA6ULK1HILVHVkbRUdxQYb2jS38rxsn8Gpz348UKdga1t08+L/YRtGKf YfFoJlLmf2rzqONe6xD6Y6/zqmKCf5ICk6neC7gi0LpgcAJ88dFYEhc4eQxsykMQAnLz LjEHh28LDnKyYzUbFdeEPvZbEUPr5Himn+inCpRfQZvgjh3hCFUOoYE1J3AlJGQL9QKP VqqWvvysMqpMWBSaxDp3JYKGfM4fzbDzySTCjgkIclzcdPATEfLUBT+XUKDfNuSReSFq N1ctLcgnex5Q6fnw+g5ZmSMiyQJrpyVFDMka6y2X3FdflZ+kwcKQSjwZku9Pks/sWAnp l6uA== 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=8y/qGe9WXXjaUmr+hM6xUseKKKsMRu9MYMLXRVpHQ1g=; b=nU97FEyuB6VeFriq2l/3TGpiruA0uCIqKxnTVYDC5KWUKo0b2at5uN1sYenyXpo7fs lEWpsZp3h056H1MXANXLdl9IiCmX+3jKJUNwj9Lkclas34HI2IWTHzfYNJXcFzHXqvfS 0VySnr6MJA7lJvc7P7+2X1G2SwZyefovXCBUwNNU9TIcWPSVQTeMWP7Ahq+mssTea6ZZ qFkaOXEBqqx+vvvz4JIqjAo4Pq8C1KU8ez6gGfry8LrRBfkobdc11EPBUuXETIatOArU iRKHzsuKqsS1FFqAJwbZeaQjoyyK1Wc4bryvMwe5tQwwsGcCreKlsmMmavpzjXAQ/ro7 MtsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=oSFXQK5p; 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 b5-20020a639305000000b004e9311fc090si3916709pge.596.2023.01.30.11.51.16; Mon, 30 Jan 2023 11:51:28 -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=oSFXQK5p; 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 S237573AbjA3TdM (ORCPT + 99 others); Mon, 30 Jan 2023 14:33:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236690AbjA3TdL (ORCPT ); Mon, 30 Jan 2023 14:33:11 -0500 Received: from msg-2.mailo.com (msg-2.mailo.com [213.182.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89230C157; Mon, 30 Jan 2023 11:33:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1675107170; bh=8Ch26340bGNGh7MvxCuYz9qLE9EjgUyzkgWt1CvrVRQ=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=oSFXQK5pxF3Bg82t71nZec3Vq1/4FUH8Rq/C3pvQyOoTVBBRsrmMfCMd7UWg8HrPq Xc9V6UGNSQBvdVsw0TpaP/getMFG06x5gO8PIheN7luOWhnRwLSjQP0dH4i1kEcdq3 rTS+caJqRLTEghmBItJ+h/s3PuPPLePBDNox3kdU= Received: by b-2.in.mailobj.net [192.168.90.12] with ESMTP via ip-206.mailobj.net [213.182.55.206] Mon, 30 Jan 2023 20:32:50 +0100 (CET) X-EA-Auth: TipJ+Tj7bxj605b6/oLpSLv33BDc31aMb1KsTH0jQhdw/J29WH1jtfjUw+iP3i0COi2GLYG84O3Rvw8BjTMQDaR3tD7fJJmg Date: Tue, 31 Jan 2023 01:02:45 +0530 From: Deepak R Varma To: Ketan Mukadam , "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: be2iscsi: 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?1756478348974665263?= X-GMAIL-MSGID: =?utf-8?q?1756478348974665263?= 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 device_attr_show.cocci Coccinelle script. Signed-off-by: Deepak R Varma --- drivers/scsi/be2iscsi/be_mgmt.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c index 4e899ec1477d..cb74524fa516 100644 --- a/drivers/scsi/be2iscsi/be_mgmt.c +++ b/drivers/scsi/be2iscsi/be_mgmt.c @@ -1142,7 +1142,7 @@ ssize_t beiscsi_drvr_ver_disp(struct device *dev, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, BE_NAME "\n"); + return sysfs_emit(buf, BE_NAME "\n"); } /** @@ -1161,7 +1161,7 @@ beiscsi_fw_ver_disp(struct device *dev, struct device_attribute *attr, struct Scsi_Host *shost = class_to_shost(dev); struct beiscsi_hba *phba = iscsi_host_priv(shost); - return snprintf(buf, PAGE_SIZE, "%s\n", phba->fw_ver_str); + return sysfs_emit(buf, "%s\n", phba->fw_ver_str); } /** @@ -1248,16 +1248,14 @@ beiscsi_adap_family_disp(struct device *dev, struct device_attribute *attr, case BE_DEVICE_ID1: case OC_DEVICE_ID1: case OC_DEVICE_ID2: - return snprintf(buf, PAGE_SIZE, - "Obsolete/Unsupported BE2 Adapter Family\n"); + return sysfs_emit(buf, "Obsolete/Unsupported BE2 Adapter Family\n"); case BE_DEVICE_ID2: case OC_DEVICE_ID3: - return snprintf(buf, PAGE_SIZE, "BE3-R Adapter Family\n"); + return sysfs_emit(buf, "BE3-R Adapter Family\n"); case OC_SKH_ID1: - return snprintf(buf, PAGE_SIZE, "Skyhawk-R Adapter Family\n"); + return sysfs_emit(buf, "Skyhawk-R Adapter Family\n"); default: - return snprintf(buf, PAGE_SIZE, - "Unknown Adapter Family: 0x%x\n", dev_id); + return sysfs_emit(buf, "Unknown Adapter Family: 0x%x\n", dev_id); } } @@ -1277,8 +1275,7 @@ beiscsi_phys_port_disp(struct device *dev, struct device_attribute *attr, struct Scsi_Host *shost = class_to_shost(dev); struct beiscsi_hba *phba = iscsi_host_priv(shost); - return snprintf(buf, PAGE_SIZE, "Port Identifier : %u\n", - phba->fw_config.phys_port); + return sysfs_emit(buf, "Port Identifier : %u\n", phba->fw_config.phys_port); } void beiscsi_offload_cxn_v0(struct beiscsi_offload_params *params,