* [PATCH] EDAC/mc_sysfs: add missing newlines when printing 'max(dimm)_location'
@ 2020-09-04 8:19 Xiongfeng Wang
2020-09-10 11:00 ` Borislav Petkov
0 siblings, 1 reply; 3+ messages in thread
From: Xiongfeng Wang @ 2020-09-04 8:19 UTC (permalink / raw)
To: bp, mchehab, tony.luck; +Cc: linux-edac, linux-kernel, wangxiongfeng2
When I cat 'max_location' and 'dimm_location' by sysfs, it displays as
follows. It's better to add a newline for easy reading.
[root@localhost /]# cat /sys/devices/system/edac/mc/mc0/max_location
memory 3 [root@localhost /]# cat /sys/devices/system/edac/mc/mc0/dimm0/dimm_location
memory 0 [root@localhost /]#
Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
---
I am not sure if there are some userspace tools using this file.
---
drivers/edac/edac_mc_sysfs.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 4e6aca5..5d7b079 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -474,8 +474,12 @@ static ssize_t dimmdev_location_show(struct device *dev,
struct device_attribute *mattr, char *data)
{
struct dimm_info *dimm = to_dimm(dev);
+ ssize_t count;
- return edac_dimm_info_location(dimm, data, PAGE_SIZE);
+ count = edac_dimm_info_location(dimm, data, PAGE_SIZE);
+ count += snprintf(data + count, PAGE_SIZE - count, "\n");
+
+ return count;
}
static ssize_t dimmdev_label_show(struct device *dev,
@@ -821,6 +825,7 @@ static ssize_t mci_max_location_show(struct device *dev,
edac_layer_name[mci->layers[i].type],
mci->layers[i].size - 1);
}
+ p += sprintf(p, "\n");
return p - data;
}
--
1.7.12.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] EDAC/mc_sysfs: add missing newlines when printing 'max(dimm)_location'
2020-09-04 8:19 [PATCH] EDAC/mc_sysfs: add missing newlines when printing 'max(dimm)_location' Xiongfeng Wang
@ 2020-09-10 11:00 ` Borislav Petkov
2020-09-11 8:05 ` Xiongfeng Wang
0 siblings, 1 reply; 3+ messages in thread
From: Borislav Petkov @ 2020-09-10 11:00 UTC (permalink / raw)
To: Xiongfeng Wang; +Cc: mchehab, tony.luck, linux-edac, linux-kernel
On Fri, Sep 04, 2020 at 04:19:23PM +0800, Xiongfeng Wang wrote:
> When I cat 'max_location' and 'dimm_location' by sysfs, it displays as
> follows. It's better to add a newline for easy reading.
>
> [root@localhost /]# cat /sys/devices/system/edac/mc/mc0/max_location
> memory 3 [root@localhost /]# cat /sys/devices/system/edac/mc/mc0/dimm0/dimm_location
> memory 0 [root@localhost /]#
Please use this commit message for your next version:
EDAC/mc_sysfs: Add missing newlines when printing {max,dimm}_location
Reading those sysfs entries gives:
[root@localhost /]# cat /sys/devices/system/edac/mc/mc0/max_location
memory 3 [root@localhost /]# cat /sys/devices/system/edac/mc/mc0/dimm0/dimm_location
memory 0 [root@localhost /]#
Add newlines after the value it prints for better readability.
> @@ -821,6 +825,7 @@ static ssize_t mci_max_location_show(struct device *dev,
> edac_layer_name[mci->layers[i].type],
> mci->layers[i].size - 1);
> }
> + p += sprintf(p, "\n");
No size checking here?
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] EDAC/mc_sysfs: add missing newlines when printing 'max(dimm)_location'
2020-09-10 11:00 ` Borislav Petkov
@ 2020-09-11 8:05 ` Xiongfeng Wang
0 siblings, 0 replies; 3+ messages in thread
From: Xiongfeng Wang @ 2020-09-11 8:05 UTC (permalink / raw)
To: Borislav Petkov; +Cc: mchehab, tony.luck, linux-edac, linux-kernel
On 2020/9/10 19:00, Borislav Petkov wrote:
> On Fri, Sep 04, 2020 at 04:19:23PM +0800, Xiongfeng Wang wrote:
>> When I cat 'max_location' and 'dimm_location' by sysfs, it displays as
>> follows. It's better to add a newline for easy reading.
>>
>> [root@localhost /]# cat /sys/devices/system/edac/mc/mc0/max_location
>> memory 3 [root@localhost /]# cat /sys/devices/system/edac/mc/mc0/dimm0/dimm_location
>> memory 0 [root@localhost /]#
>
> Please use this commit message for your next version:
>
> EDAC/mc_sysfs: Add missing newlines when printing {max,dimm}_location
>
> Reading those sysfs entries gives:
>
> [root@localhost /]# cat /sys/devices/system/edac/mc/mc0/max_location
> memory 3 [root@localhost /]# cat /sys/devices/system/edac/mc/mc0/dimm0/dimm_location
> memory 0 [root@localhost /]#
>
> Add newlines after the value it prints for better readability.
Thanks for your advice. I will add it in the next version.
>
>> @@ -821,6 +825,7 @@ static ssize_t mci_max_location_show(struct device *dev,
>> edac_layer_name[mci->layers[i].type],
>> mci->layers[i].size - 1);
>> }
>> + p += sprintf(p, "\n");
>
> No size checking here?
I can check if it's larger than PAGE_SIZE.
Thanks,
Xiongfeng
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-11 8:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-04 8:19 [PATCH] EDAC/mc_sysfs: add missing newlines when printing 'max(dimm)_location' Xiongfeng Wang
2020-09-10 11:00 ` Borislav Petkov
2020-09-11 8:05 ` Xiongfeng Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).