• Guenter Roeck's avatar
    hwmon: replace snprintf in show functions with sysfs_emit · 1f4d4af4
    Guenter Roeck authored
    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: default avatarGuenter Roeck <linux@roeck-us.net>
    1f4d4af4
inspur-ipsps.c 5.71 KB