]> git.ipfire.org Git - thirdparty/linux.git/blame - scripts/coccinelle/api/device_attr_show.cocci
coccinelle: device_attr_show: Remove useless expression STR
[thirdparty/linux.git] / scripts / coccinelle / api / device_attr_show.cocci
CommitLineData
abfc19ff
DE
1// SPDX-License-Identifier: GPL-2.0-only
2///
c9a6bef2 3/// From Documentation/filesystems/sysfs.rst:
68ea60a7
LZ
4/// show() should only use sysfs_emit() or sysfs_emit_at() when formatting
5/// the value to be returned to user space.
abfc19ff
DE
6///
7// Confidence: High
8// Copyright: (C) 2020 Denis Efremov ISPRAS
9// Options: --no-includes --include-headers
10//
11
12virtual report
13virtual org
14virtual context
15virtual patch
16
17@r depends on !patch@
18identifier show, dev, attr, buf;
19position p;
20@@
21
22ssize_t show(struct device *dev, struct device_attribute *attr, char *buf)
23{
24 <...
25* return snprintf@p(...);
26 ...>
27}
28
29@rp depends on patch@
30identifier show, dev, attr, buf;
173f6cd3 31expression BUF, SZ, FORMAT;
abfc19ff
DE
32@@
33
34ssize_t show(struct device *dev, struct device_attribute *attr, char *buf)
35{
36 <...
37 return
ff82e84e
JL
38- snprintf(BUF, SZ, FORMAT
39+ sysfs_emit(BUF, FORMAT
40 ,...);
abfc19ff
DE
41 ...>
42}
43
44@script: python depends on report@
45p << r.p;
46@@
47
68ea60a7 48coccilib.report.print_report(p[0], "WARNING: please use sysfs_emit or sysfs_emit_at")
abfc19ff
DE
49
50@script: python depends on org@
51p << r.p;
52@@
53
68ea60a7 54coccilib.org.print_todo(p[0], "WARNING: please use sysfs_emit or sysfs_emit_at")