Skip to content

Commit fc4e784

Browse files
Ye Guojincminyard
authored andcommitted
char: ipmi: replace snprintf in show functions with sysfs_emit
coccicheck complains about the use of snprintf() in sysfs show functions: WARNING use scnprintf or sprintf Use sysfs_emit instead of scnprintf, snprintf or sprintf makes more sense. Reported-by: Zeal Robot <[email protected]> Signed-off-by: Ye Guojin <[email protected]> Message-Id: <[email protected]> Signed-off-by: Corey Minyard <[email protected]>
1 parent ed83855 commit fc4e784

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

drivers/char/ipmi/ipmi_msghandler.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2716,7 +2716,7 @@ static ssize_t device_id_show(struct device *dev,
27162716
if (rv)
27172717
return rv;
27182718

2719-
return snprintf(buf, 10, "%u\n", id.device_id);
2719+
return sysfs_emit(buf, "%u\n", id.device_id);
27202720
}
27212721
static DEVICE_ATTR_RO(device_id);
27222722

@@ -2732,7 +2732,7 @@ static ssize_t provides_device_sdrs_show(struct device *dev,
27322732
if (rv)
27332733
return rv;
27342734

2735-
return snprintf(buf, 10, "%u\n", (id.device_revision & 0x80) >> 7);
2735+
return sysfs_emit(buf, "%u\n", (id.device_revision & 0x80) >> 7);
27362736
}
27372737
static DEVICE_ATTR_RO(provides_device_sdrs);
27382738

@@ -2747,7 +2747,7 @@ static ssize_t revision_show(struct device *dev, struct device_attribute *attr,
27472747
if (rv)
27482748
return rv;
27492749

2750-
return snprintf(buf, 20, "%u\n", id.device_revision & 0x0F);
2750+
return sysfs_emit(buf, "%u\n", id.device_revision & 0x0F);
27512751
}
27522752
static DEVICE_ATTR_RO(revision);
27532753

@@ -2763,7 +2763,7 @@ static ssize_t firmware_revision_show(struct device *dev,
27632763
if (rv)
27642764
return rv;
27652765

2766-
return snprintf(buf, 20, "%u.%x\n", id.firmware_revision_1,
2766+
return sysfs_emit(buf, "%u.%x\n", id.firmware_revision_1,
27672767
id.firmware_revision_2);
27682768
}
27692769
static DEVICE_ATTR_RO(firmware_revision);
@@ -2780,7 +2780,7 @@ static ssize_t ipmi_version_show(struct device *dev,
27802780
if (rv)
27812781
return rv;
27822782

2783-
return snprintf(buf, 20, "%u.%u\n",
2783+
return sysfs_emit(buf, "%u.%u\n",
27842784
ipmi_version_major(&id),
27852785
ipmi_version_minor(&id));
27862786
}
@@ -2798,7 +2798,7 @@ static ssize_t add_dev_support_show(struct device *dev,
27982798
if (rv)
27992799
return rv;
28002800

2801-
return snprintf(buf, 10, "0x%02x\n", id.additional_device_support);
2801+
return sysfs_emit(buf, "0x%02x\n", id.additional_device_support);
28022802
}
28032803
static DEVICE_ATTR(additional_device_support, S_IRUGO, add_dev_support_show,
28042804
NULL);
@@ -2815,7 +2815,7 @@ static ssize_t manufacturer_id_show(struct device *dev,
28152815
if (rv)
28162816
return rv;
28172817

2818-
return snprintf(buf, 20, "0x%6.6x\n", id.manufacturer_id);
2818+
return sysfs_emit(buf, "0x%6.6x\n", id.manufacturer_id);
28192819
}
28202820
static DEVICE_ATTR_RO(manufacturer_id);
28212821

@@ -2831,7 +2831,7 @@ static ssize_t product_id_show(struct device *dev,
28312831
if (rv)
28322832
return rv;
28332833

2834-
return snprintf(buf, 10, "0x%4.4x\n", id.product_id);
2834+
return sysfs_emit(buf, "0x%4.4x\n", id.product_id);
28352835
}
28362836
static DEVICE_ATTR_RO(product_id);
28372837

@@ -2847,7 +2847,7 @@ static ssize_t aux_firmware_rev_show(struct device *dev,
28472847
if (rv)
28482848
return rv;
28492849

2850-
return snprintf(buf, 21, "0x%02x 0x%02x 0x%02x 0x%02x\n",
2850+
return sysfs_emit(buf, "0x%02x 0x%02x 0x%02x 0x%02x\n",
28512851
id.aux_firmware_revision[3],
28522852
id.aux_firmware_revision[2],
28532853
id.aux_firmware_revision[1],
@@ -2869,7 +2869,7 @@ static ssize_t guid_show(struct device *dev, struct device_attribute *attr,
28692869
if (!guid_set)
28702870
return -ENOENT;
28712871

2872-
return snprintf(buf, UUID_STRING_LEN + 1 + 1, "%pUl\n", &guid);
2872+
return sysfs_emit(buf, "%pUl\n", &guid);
28732873
}
28742874
static DEVICE_ATTR_RO(guid);
28752875

drivers/char/ipmi/ipmi_si_intf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,7 +1603,7 @@ static ssize_t name##_show(struct device *dev, \
16031603
{ \
16041604
struct smi_info *smi_info = dev_get_drvdata(dev); \
16051605
\
1606-
return snprintf(buf, 10, "%u\n", smi_get_stat(smi_info, name)); \
1606+
return sysfs_emit(buf, "%u\n", smi_get_stat(smi_info, name)); \
16071607
} \
16081608
static DEVICE_ATTR_RO(name)
16091609

@@ -1613,7 +1613,7 @@ static ssize_t type_show(struct device *dev,
16131613
{
16141614
struct smi_info *smi_info = dev_get_drvdata(dev);
16151615

1616-
return snprintf(buf, 10, "%s\n", si_to_str[smi_info->io.si_type]);
1616+
return sysfs_emit(buf, "%s\n", si_to_str[smi_info->io.si_type]);
16171617
}
16181618
static DEVICE_ATTR_RO(type);
16191619

@@ -1624,7 +1624,7 @@ static ssize_t interrupts_enabled_show(struct device *dev,
16241624
struct smi_info *smi_info = dev_get_drvdata(dev);
16251625
int enabled = smi_info->io.irq && !smi_info->interrupt_disabled;
16261626

1627-
return snprintf(buf, 10, "%d\n", enabled);
1627+
return sysfs_emit(buf, "%d\n", enabled);
16281628
}
16291629
static DEVICE_ATTR_RO(interrupts_enabled);
16301630

@@ -1646,7 +1646,7 @@ static ssize_t params_show(struct device *dev,
16461646
{
16471647
struct smi_info *smi_info = dev_get_drvdata(dev);
16481648

1649-
return snprintf(buf, 200,
1649+
return sysfs_emit(buf,
16501650
"%s,%s,0x%lx,rsp=%d,rsi=%d,rsh=%d,irq=%d,ipmb=%d\n",
16511651
si_to_str[smi_info->io.si_type],
16521652
addr_space_to_str[smi_info->io.addr_space],

drivers/char/ipmi/ipmi_ssif.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,15 +1190,15 @@ static ssize_t ipmi_##name##_show(struct device *dev, \
11901190
{ \
11911191
struct ssif_info *ssif_info = dev_get_drvdata(dev); \
11921192
\
1193-
return snprintf(buf, 10, "%u\n", ssif_get_stat(ssif_info, name));\
1193+
return sysfs_emit(buf, "%u\n", ssif_get_stat(ssif_info, name));\
11941194
} \
11951195
static DEVICE_ATTR(name, S_IRUGO, ipmi_##name##_show, NULL)
11961196

11971197
static ssize_t ipmi_type_show(struct device *dev,
11981198
struct device_attribute *attr,
11991199
char *buf)
12001200
{
1201-
return snprintf(buf, 10, "ssif\n");
1201+
return sysfs_emit(buf, "ssif\n");
12021202
}
12031203
static DEVICE_ATTR(type, S_IRUGO, ipmi_type_show, NULL);
12041204

0 commit comments

Comments
 (0)