| 1 |
// SPDX-License-Identifier: GPL-2.0-only |
| 2 |
/// |
| 3 |
/// From Documentation/filesystems/sysfs.rst: |
| 4 |
/// show() should only use sysfs_emit() or sysfs_emit_at() when formatting |
| 5 |
/// the value to be returned to user space. |
| 6 |
/// |
| 7 |
// Confidence: High |
| 8 |
// Copyright: (C) 2020 Denis Efremov ISPRAS |
| 9 |
// Options: --no-includes --include-headers |
| 10 |
// |
| 11 |
|
| 12 |
virtual report |
| 13 |
virtual org |
| 14 |
virtual context |
| 15 |
virtual patch |
| 16 |
|
| 17 |
@r depends on !patch@ |
| 18 |
identifier show, dev, attr, buf; |
| 19 |
position p; |
| 20 |
@@ |
| 21 |
|
| 22 |
ssize_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@ |
| 30 |
identifier show, dev, attr, buf; |
| 31 |
expression BUF, SZ, FORMAT; |
| 32 |
@@ |
| 33 |
|
| 34 |
ssize_t show(struct device *dev, struct device_attribute *attr, char *buf) |
| 35 |
{ |
| 36 |
<... |
| 37 |
return |
| 38 |
- snprintf(BUF, SZ, FORMAT |
| 39 |
+ sysfs_emit(BUF, FORMAT |
| 40 |
,...); |
| 41 |
...> |
| 42 |
} |
| 43 |
|
| 44 |
@script: python depends on report@ |
| 45 |
p << r.p; |
| 46 |
@@ |
| 47 |
|
| 48 |
coccilib.report.print_report(p[0], "WARNING: please use sysfs_emit or sysfs_emit_at") |
| 49 |
|
| 50 |
@script: python depends on org@ |
| 51 |
p << r.p; |
| 52 |
@@ |
| 53 |
|
| 54 |
coccilib.org.print_todo(p[0], "WARNING: please use sysfs_emit or sysfs_emit_at") |