Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'coccinelle-for-6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux

Pull coccinelle updates from Julia Lawall:
"Updates to the device_attr_show semantic patch to reflect the new
guidelines of the Linux kernel documentation.

The problem was identified by Li Zhijian <lizhijian@fujitsu.com>, who
proposed an initial fix"

* tag 'coccinelle-for-6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux:
coccinelle: device_attr_show: simplify patch case
coccinelle: device_attr_show: Adapt to the latest Documentation/filesystems/sysfs.rst

+8 -9
+8 -9
scripts/coccinelle/api/device_attr_show.cocci
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 2 /// 3 3 /// From Documentation/filesystems/sysfs.rst: 4 - /// show() must not use snprintf() when formatting the value to be 5 - /// returned to user space. If you can guarantee that an overflow 6 - /// will never happen you can use sprintf() otherwise you must use 7 - /// scnprintf(). 4 + /// show() should only use sysfs_emit() or sysfs_emit_at() when formatting 5 + /// the value to be returned to user space. 8 6 /// 9 7 // Confidence: High 10 8 // Copyright: (C) 2020 Denis Efremov ISPRAS ··· 28 30 29 31 @rp depends on patch@ 30 32 identifier show, dev, attr, buf; 33 + expression BUF, SZ, FORMAT, STR; 31 34 @@ 32 35 33 36 ssize_t show(struct device *dev, struct device_attribute *attr, char *buf) 34 37 { 35 38 <... 36 39 return 37 - - snprintf 38 - + scnprintf 39 - (...); 40 + - snprintf(BUF, SZ, FORMAT 41 + + sysfs_emit(BUF, FORMAT 42 + ,...); 40 43 ...> 41 44 } 42 45 ··· 45 46 p << r.p; 46 47 @@ 47 48 48 - coccilib.report.print_report(p[0], "WARNING: use scnprintf or sprintf") 49 + coccilib.report.print_report(p[0], "WARNING: please use sysfs_emit or sysfs_emit_at") 49 50 50 51 @script: python depends on org@ 51 52 p << r.p; 52 53 @@ 53 54 54 - coccilib.org.print_todo(p[0], "WARNING: use scnprintf or sprintf") 55 + coccilib.org.print_todo(p[0], "WARNING: please use sysfs_emit or sysfs_emit_at")