-
- Downloads
hwmon: replace snprintf in show functions with sysfs_emit
coccicheck complains about the use of snprintf() in sysfs
show functions.
drivers/hwmon/ina3221.c:701:8-16: WARNING: use scnprintf or sprintf
This results in a large number of patch submissions. Fix it all in
one go using the following coccinelle rules. Use sysfs_emit instead
of scnprintf or sprintf since that makes more sense.
@depends on patch@
identifier show, dev, attr, buf;
@@
ssize_t show(struct device *dev, struct device_attribute *attr, char *buf)
{
<...
return
- snprintf(buf, \( PAGE_SIZE \| PAGE_SIZE - 1 \),
+ sysfs_emit(buf,
...);
...>
}
@depends on patch@
identifier show, dev, attr, buf, rc;
@@
ssize_t show(struct device *dev, struct device_attribute *attr, char *buf)
{
<...
rc =
- snprintf(buf, \( PAGE_SIZE \| PAGE_SIZE - 1 \),
+ sysfs_emit(buf,
...);
...>
}
While at it, remove unnecessary braces and as well as unnecessary
else after return statements to address checkpatch warnings in the
resulting patch.
Cc: Zihao Tang <tangzihao1@hisilicon.com>
Cc: Jay Fang <f.fangjian@huawei.com>
Signed-off-by:
Guenter Roeck <linux@roeck-us.net>
Showing
- drivers/hwmon/applesmc.c 17 additions, 17 deletionsdrivers/hwmon/applesmc.c
- drivers/hwmon/ina209.c 3 additions, 3 deletionsdrivers/hwmon/ina209.c
- drivers/hwmon/ina2xx.c 1 addition, 1 deletiondrivers/hwmon/ina2xx.c
- drivers/hwmon/ina3221.c 1 addition, 1 deletiondrivers/hwmon/ina3221.c
- drivers/hwmon/lineage-pem.c 4 additions, 4 deletionsdrivers/hwmon/lineage-pem.c
- drivers/hwmon/ltc2945.c 2 additions, 2 deletionsdrivers/hwmon/ltc2945.c
- drivers/hwmon/ltc2990.c 1 addition, 1 deletiondrivers/hwmon/ltc2990.c
- drivers/hwmon/ltc4151.c 1 addition, 1 deletiondrivers/hwmon/ltc4151.c
- drivers/hwmon/ltc4215.c 4 additions, 4 deletionsdrivers/hwmon/ltc4215.c
- drivers/hwmon/ltc4222.c 2 additions, 2 deletionsdrivers/hwmon/ltc4222.c
- drivers/hwmon/ltc4260.c 2 additions, 2 deletionsdrivers/hwmon/ltc4260.c
- drivers/hwmon/ltc4261.c 2 additions, 2 deletionsdrivers/hwmon/ltc4261.c
- drivers/hwmon/max16065.c 7 additions, 7 deletionsdrivers/hwmon/max16065.c
- drivers/hwmon/occ/common.c 35 additions, 34 deletionsdrivers/hwmon/occ/common.c
- drivers/hwmon/occ/sysfs.c 2 additions, 2 deletionsdrivers/hwmon/occ/sysfs.c
- drivers/hwmon/pmbus/inspur-ipsps.c 14 additions, 14 deletionsdrivers/hwmon/pmbus/inspur-ipsps.c
- drivers/hwmon/pmbus/pmbus_core.c 4 additions, 4 deletionsdrivers/hwmon/pmbus/pmbus_core.c
- drivers/hwmon/s3c-hwmon.c 2 additions, 2 deletionsdrivers/hwmon/s3c-hwmon.c
- drivers/hwmon/sch5627.c 12 additions, 12 deletionsdrivers/hwmon/sch5627.c
- drivers/hwmon/sch5636.c 10 additions, 10 deletionsdrivers/hwmon/sch5636.c
Loading
Please register or sign in to comment