From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============4883053529617190427==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings Date: Sat, 12 Sep 2020 18:01:42 +0800 Message-ID: <20200912100142.GA14800@e78ef17e6bf7> In-Reply-To: <202009121728.fBDWtmGf%lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============4883053529617190427== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable CC: kbuild-all(a)lists.01.org CC: linux-kernel(a)vger.kernel.org TO: Denis Efremov CC: Julia Lawall CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: Nathan Chancellor CC: linux-scsi(a)vger.kernel.org CC: linux-kernel(a)vger.kernel.org From: kernel test robot drivers/scsi/csiostor/csio_scsi.c:1433:8-16: WARNING: use scnprintf or spri= ntf drivers/scsi/csiostor/csio_scsi.c:1369:9-17: WARNING: use scnprintf or spri= ntf drivers/scsi/csiostor/csio_scsi.c:1477:8-16: WARNING: use scnprintf or spri= ntf From Documentation/filesystems/sysfs.txt: show() must not use snprintf() when formatting the value to be returned to user space. If you can guarantee that an overflow will never happen you can use sprintf() otherwise you must use scnprintf(). Generated by: scripts/coccinelle/api/device_attr_show.cocci Fixes: abfc19ff202d ("coccinelle: api: add device_attr_show script") CC: Denis Efremov Signed-off-by: kernel test robot --- tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git = master head: 729e3d091984487f7aa1ebfabfe594e5b317ed0f commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add devic= e_attr_show script :::::: branch date: 13 hours ago :::::: commit date: 6 weeks ago Please take the patch only if it's a positive warning. Thanks! csio_scsi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/scsi/csiostor/csio_scsi.c +++ b/drivers/scsi/csiostor/csio_scsi.c @@ -1366,9 +1366,9 @@ csio_show_hw_state(struct device *dev, struct csio_hw *hw =3D csio_lnode_to_hw(ln); = if (csio_is_hw_ready(hw)) - return snprintf(buf, PAGE_SIZE, "ready\n"); + return scnprintf(buf, PAGE_SIZE, "ready\n"); else - return snprintf(buf, PAGE_SIZE, "not ready\n"); + return scnprintf(buf, PAGE_SIZE, "not ready\n"); } = /* Device reset */ @@ -1430,7 +1430,7 @@ csio_show_dbg_level(struct device *dev, { struct csio_lnode *ln =3D shost_priv(class_to_shost(dev)); = - return snprintf(buf, PAGE_SIZE, "%x\n", ln->params.log_level); + return scnprintf(buf, PAGE_SIZE, "%x\n", ln->params.log_level); } = /* Store debug level */ @@ -1474,7 +1474,7 @@ csio_show_num_reg_rnodes(struct device * { struct csio_lnode *ln =3D shost_priv(class_to_shost(dev)); = - return snprintf(buf, PAGE_SIZE, "%d\n", ln->num_reg_rnodes); + return scnprintf(buf, PAGE_SIZE, "%d\n", ln->num_reg_rnodes); } = static DEVICE_ATTR(num_reg_rnodes, S_IRUGO, csio_show_num_reg_rnodes, NULL= ); --===============4883053529617190427==--