Coccinelle change for v6.8
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. -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEnGZC8gbRfLXdcpA0F+92B3f5RZ0FAmWsNv4ACgkQF+92B3f5 RZ1CdxAAlLWgipk/Ypg9YQalq8VH1tI9tJM38awLhkM/k7wbXubvArRCQpqdDiMe /7QyBzhplWhnX1RFcdpIfClITcyDi8B7po9zJg89U/ElXZiOuBpvEkOivw40q5Ms uxznSzORGM1vLHTCb/Gv0IaIVM0pUbLZidFWy6OuuKNrVEdM9WkXDcQwzwg2K+Wj ebSYKRZoeefx2PHfCkuZcYDLwLHF7hy90isk8KGgTqPDCZcmYJTAjDnbGYbHP/3X sxXzIAfR5jgzaGsm4WKAdxXM0EGaBtPYF+vg5K4vf8yc9mkbtS1s+xqMw34c3HaU Xv4GAL2cLJPmIRQA9xWVmtiKriat8rkm+KODVal+YCHmKcEeYJbNIP6P4kSLTNRp qSecnHj06zca221dD0wdvV0xeAu/RG0t/svLrxyVoq8ofkqIICAxZFvBPhwiNiDx ID4sw9EGvl90mwQYwxYkvitmxvNs2utn6n6h6/yDRAmFJMsmTmRieIywY3rVA1+R NJ3bHdr/qEJo6U1sVsDU11B0Y7JYWbWbNJ1ODb3nWR/jxTCVEJubPO4O5IaovREt GqPRwhry7GxBreNu2IWlacYKco/65cFUW51n1XjaTwS0LFIjuOYtSJmXGJeVDvaJ 3rsdF9lcuhXmniHN/BO8GavCrUWuBbX37RPmU4qQ1LqhQRDuOCg= =l440 -----END PGP SIGNATURE----- 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
This commit is contained in:
commit
80fc600faf
@ -1,10 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
///
|
||||
/// From Documentation/filesystems/sysfs.rst:
|
||||
/// 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().
|
||||
/// show() should only use sysfs_emit() or sysfs_emit_at() when formatting
|
||||
/// the value to be returned to user space.
|
||||
///
|
||||
// Confidence: High
|
||||
// Copyright: (C) 2020 Denis Efremov ISPRAS
|
||||
@ -30,15 +28,16 @@ ssize_t show(struct device *dev, struct device_attribute *attr, char *buf)
|
||||
|
||||
@rp depends on patch@
|
||||
identifier show, dev, attr, buf;
|
||||
expression BUF, SZ, FORMAT, STR;
|
||||
@@
|
||||
|
||||
ssize_t show(struct device *dev, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
<...
|
||||
return
|
||||
- snprintf
|
||||
+ scnprintf
|
||||
(...);
|
||||
- snprintf(BUF, SZ, FORMAT
|
||||
+ sysfs_emit(BUF, FORMAT
|
||||
,...);
|
||||
...>
|
||||
}
|
||||
|
||||
@ -46,10 +45,10 @@ ssize_t show(struct device *dev, struct device_attribute *attr, char *buf)
|
||||
p << r.p;
|
||||
@@
|
||||
|
||||
coccilib.report.print_report(p[0], "WARNING: use scnprintf or sprintf")
|
||||
coccilib.report.print_report(p[0], "WARNING: please use sysfs_emit or sysfs_emit_at")
|
||||
|
||||
@script: python depends on org@
|
||||
p << r.p;
|
||||
@@
|
||||
|
||||
coccilib.org.print_todo(p[0], "WARNING: use scnprintf or sprintf")
|
||||
coccilib.org.print_todo(p[0], "WARNING: please use sysfs_emit or sysfs_emit_at")
|
||||
|
Loading…
Reference in New Issue
Block a user