From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============6728913202190506343==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings Date: Wed, 25 Nov 2020 04:47:04 +0800 Message-ID: <20201124204704.GA50088@e9fc5e93ff7d> In-Reply-To: <202011250450.7PWc70lr-lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============6728913202190506343== 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: Jonathan Cameron CC: Hartmut Knaack CC: "Lars-Peter Clausen" CC: "Peter Meerwald-Stadler" CC: Maxime Coquelin CC: Alexandre Torgue CC: Fabrice Gasnier CC: linux-iio(a)vger.kernel.org From: kernel test robot drivers/iio/trigger/stm32-timer-trigger.c:299:8-16: WARNING: use scnprintf = or sprintf 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 Reported-by: kernel test robot Signed-off-by: kernel test robot --- tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git = master head: d5beb3140f91b1c8a3d41b14d729aefa4dcc58bc commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add devic= e_attr_show script :::::: branch date: 21 hours ago :::::: commit date: 4 months ago Please take the patch only if it's a positive warning. Thanks! stm32-timer-trigger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/iio/trigger/stm32-timer-trigger.c +++ b/drivers/iio/trigger/stm32-timer-trigger.c @@ -296,7 +296,7 @@ static ssize_t stm32_tt_show_master_mode else cr2 =3D (cr2 & TIM_CR2_MMS) >> TIM_CR2_MMS_SHIFT; = - return snprintf(buf, PAGE_SIZE, "%s\n", master_mode_table[cr2]); + return scnprintf(buf, PAGE_SIZE, "%s\n", master_mode_table[cr2]); } = static ssize_t stm32_tt_store_master_mode(struct device *dev, --===============6728913202190506343==--