Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp244802rdb; Mon, 15 Jan 2024 21:02:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IHl/2IJf2zxhQBKYXHtnkSyeOSunoDqmGhxvNcBjEGGSLcJvuDO5nOCfBDuehctf5SZ150M X-Received: by 2002:a17:902:cecf:b0:1d4:ea27:6f5b with SMTP id d15-20020a170902cecf00b001d4ea276f5bmr4246574plg.109.1705381332388; Mon, 15 Jan 2024 21:02:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705381332; cv=none; d=google.com; s=arc-20160816; b=VjLuzymp7Qho5gE0n0Yfzhm6NJ9sa/pweIZ3c4Ut6LBpzFsjnr7lalY52vuxI1pNZO eRe+iRo9znfV/fL5VZa4DG9hwNnOASlPh3iDeCAM+w5ktaSJ+LAqaCiRYZ3Wc0/WiKri fXRYesrOU++hIvAuli9c+3Cc2xxYEaRaRN/sHT0VczGUpKgoVjIlMc8p8inDOdeVO94U 7UVJtnR5dWOtQ5VK849AmPH0xy+vp+9beR5muBRI2sMC+uHg/8QLVAdq5TTz5jvHVExV Us+n+sUJ9EcrQhP9vu7euIJiK+pYlYt0BwiTD0rLpQF/cNSvYUdRSbRis5dljZOtGyb9 kcWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=ksgcHEMr6+s0Mn0Ckz6Pkmj1MewcZiS116ylrSYHqpY=; fh=Zjw+0PT1zT5RoGUu9WL9T7CWXAriEh8orTRtdR8QpzU=; b=ax80NI8qfiw69FvfiRxb83nEcfUmgNAoKYk97CEG9Fpm+YBY9fXJ9vTtXbQ0m/kEtb 8rrqw1q/FTSt42g45HxWZZ8TCXoUHzItlesVQ3hyp9TEffpiDi7XWSd2l3euNy8k/gP6 sP4Mgys9ve+/G10SEmHfV3nW5QYe0h2FbkuEPD6v06tcBWJBX6QSIWMgcYrg/7ColUek Acs62T1x0zJ+rDUa0QoxvCly7Fj3AfemleRrzn+aqQD8hpgGMe50Z9p+H5/2y7xaTNJq 3shFgESgL0LT3Ow7DQvpkFXzlB7EhG3oza+1fon0l1D2O3ooVnLx9/ob7OD+BK3tU2ol 9NtA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26991-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26991-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c6-20020a170902aa4600b001d5ea445252si287531plr.556.2024.01.15.21.02.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 21:02:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26991-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26991-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26991-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 124F328185C for ; Tue, 16 Jan 2024 05:02:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 554571DDDA; Tue, 16 Jan 2024 04:52:42 +0000 (UTC) Received: from esa6.hc1455-7.c3s2.iphmx.com (esa6.hc1455-7.c3s2.iphmx.com [68.232.139.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 701B61CD33; Tue, 16 Jan 2024 04:52:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="147894818" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="147894818" Received: from unknown (HELO oym-r3.gw.nic.fujitsu.com) ([210.162.30.91]) by esa6.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:26 +0900 Received: from oym-m2.gw.nic.fujitsu.com (oym-nat-oym-m2.gw.nic.fujitsu.com [192.168.87.59]) by oym-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id E0355D64B1; Tue, 16 Jan 2024 13:52:24 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 13430BF3E1; Tue, 16 Jan 2024 13:52:24 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 9493F200A7693; Tue, 16 Jan 2024 13:52:23 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 26AE11A015F; Tue, 16 Jan 2024 12:52:23 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , Hannes Reinecke , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 30/42] drivers/scsi/myrb: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:39 +0800 Message-Id: <20240116045151.3940401-28-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.004 X-TMASE-Result: 10--8.893800-10.000000 X-TMASE-MatchedRID: ebEStOsB1eE4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPkgxCMf8A0YpR5sRK06wHV4TBF7stuNMMxLdBFrfY9r2nBOVz0Jwcxl6vCrG0TnfVUg9x e4gtUJtpqw4mhfH/Cj7xaYlLIzqlbaTkWqXcVprtntEdzQBf3IaEetkTb5Lzr/el+DRyvXwj3MM lWBma+yPZDRpNFX1vsPXZweTH/QGs1rNmBlj28a54CIKY/Hg3AGdQnQSTrKGPEQdG7H66TyH4gK q42LRYkmOeZ/APcnU2x+8bnxF0U7UDKtlSVxUFKwnbA8hGMEzl+3BndfXUhXQ== X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/myrb.c:1770:9-17: WARNING: please use sysfs_emit > ./drivers/scsi/myrb.c:1889:10-18: WARNING: please use sysfs_emit > ./drivers/scsi/myrb.c:1906:9-17: WARNING: please use sysfs_emit > ./drivers/scsi/myrb.c:2143:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/myrb.c:2153:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/myrb.c:2163:8-16: WARNING: please use sysfs_emit No functional change intended CC: Hannes Reinecke CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian --- drivers/scsi/myrb.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/scsi/myrb.c b/drivers/scsi/myrb.c index ca2e932dd9b7..06a5e6fb9f99 100644 --- a/drivers/scsi/myrb.c +++ b/drivers/scsi/myrb.c @@ -1767,7 +1767,7 @@ static ssize_t raid_state_show(struct device *dev, int ret; if (!sdev->hostdata) - return snprintf(buf, 16, "Unknown\n"); + return sysfs_emit(buf, "Unknown\n"); if (sdev->channel == myrb_logical_channel(sdev->host)) { struct myrb_ldev_info *ldev_info = sdev->hostdata; @@ -1775,10 +1775,10 @@ static ssize_t raid_state_show(struct device *dev, name = myrb_devstate_name(ldev_info->state); if (name) - ret = snprintf(buf, 32, "%s\n", name); + ret = sysfs_emit(buf, "%s\n", name); else - ret = snprintf(buf, 32, "Invalid (%02X)\n", - ldev_info->state); + ret = sysfs_emit(buf, "Invalid (%02X)\n", + ldev_info->state); } else { struct myrb_pdev_state *pdev_info = sdev->hostdata; unsigned short status; @@ -1796,10 +1796,10 @@ static ssize_t raid_state_show(struct device *dev, else name = myrb_devstate_name(pdev_info->state); if (name) - ret = snprintf(buf, 32, "%s\n", name); + ret = sysfs_emit(buf, "%s\n", name); else - ret = snprintf(buf, 32, "Invalid (%02X)\n", - pdev_info->state); + ret = sysfs_emit(buf, "Invalid (%02X)\n", + pdev_info->state); } return ret; } @@ -1886,11 +1886,11 @@ static ssize_t raid_level_show(struct device *dev, name = myrb_raidlevel_name(ldev_info->raid_level); if (!name) - return snprintf(buf, 32, "Invalid (%02X)\n", - ldev_info->state); - return snprintf(buf, 32, "%s\n", name); + return sysfs_emit(buf, "Invalid (%02X)\n", + ldev_info->state); + return sysfs_emit(buf, "%s\n", name); } - return snprintf(buf, 32, "Physical Drive\n"); + return sysfs_emit(buf, "Physical Drive\n"); } static DEVICE_ATTR_RO(raid_level); @@ -1903,17 +1903,17 @@ static ssize_t rebuild_show(struct device *dev, unsigned char status; if (sdev->channel < myrb_logical_channel(sdev->host)) - return snprintf(buf, 32, "physical device - not rebuilding\n"); + return sysfs_emit(buf, "physical device - not rebuilding\n"); status = myrb_get_rbld_progress(cb, &rbld_buf); if (rbld_buf.ldev_num != sdev->id || status != MYRB_STATUS_SUCCESS) - return snprintf(buf, 32, "not rebuilding\n"); + return sysfs_emit(buf, "not rebuilding\n"); - return snprintf(buf, 32, "rebuilding block %u of %u\n", - rbld_buf.ldev_size - rbld_buf.blocks_left, - rbld_buf.ldev_size); + return sysfs_emit(buf, "rebuilding block %u of %u\n", + rbld_buf.ldev_size - rbld_buf.blocks_left, + rbld_buf.ldev_size); } static ssize_t rebuild_store(struct device *dev, @@ -2140,7 +2140,7 @@ static ssize_t ctlr_num_show(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); struct myrb_hba *cb = shost_priv(shost); - return snprintf(buf, 20, "%u\n", cb->ctlr_num); + return sysfs_emit(buf, "%u\n", cb->ctlr_num); } static DEVICE_ATTR_RO(ctlr_num); @@ -2150,7 +2150,7 @@ static ssize_t firmware_show(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); struct myrb_hba *cb = shost_priv(shost); - return snprintf(buf, 16, "%s\n", cb->fw_version); + return sysfs_emit(buf, "%s\n", cb->fw_version); } static DEVICE_ATTR_RO(firmware); @@ -2160,7 +2160,7 @@ static ssize_t model_show(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); struct myrb_hba *cb = shost_priv(shost); - return snprintf(buf, 16, "%s\n", cb->model_name); + return sysfs_emit(buf, "%s\n", cb->model_name); } static DEVICE_ATTR_RO(model); -- 2.29.2