mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] xen/pciback: use sysfs_emit_at() instead of scnprintf()
@ 2025-03-17  7:16 tang.dongxing
  2025-03-17  8:50 ` Jiri Slaby
  0 siblings, 1 reply; 3+ messages in thread
From: tang.dongxing @ 2025-03-17  7:16 UTC (permalink / raw)
  To: jgross
  Cc: sstabellini, oleksandr_tyshchenko, jiqian.chen, ray.huang,
	jeff.johnson, minhuadotchen, tang.dongxing, xen-devel,
	linux-kernel, ye.xingchen, yang.guang5, yang.yang29, xu.xin16

From: TangDongxing <tang.dongxing@zte.com.cn>

Follow the advice in Documentation/filesystems/sysfs.rst:
show() should only use sysfs_emit() or sysfs_emit_at() when formatting
the value to be returned to user space.

Signed-off-by: TangDongxing <tang.dongxing@zte.com.cn>
---
 drivers/xen/xen-pciback/pci_stub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/xen/xen-pciback/pci_stub.c b/drivers/xen/xen-pciback/pci_stub.c
index b616b7768c3b..a0782a74ed34 100644
--- a/drivers/xen/xen-pciback/pci_stub.c
+++ b/drivers/xen/xen-pciback/pci_stub.c
@@ -1281,7 +1281,7 @@ static ssize_t slots_show(struct device_driver *drv, char *buf)
 		if (count >= PAGE_SIZE)
 			break;

-		count += scnprintf(buf + count, PAGE_SIZE - count,
+		count += sysfs_emit_at(buf, count,
 				   "%04x:%02x:%02x.%d\n",
 				   pci_dev_id->domain, pci_dev_id->bus,
 				   PCI_SLOT(pci_dev_id->devfn),
-- 
2.25.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] xen/pciback: use sysfs_emit_at() instead of scnprintf()
  2025-03-17  7:16 [PATCH] xen/pciback: use sysfs_emit_at() instead of scnprintf() tang.dongxing
@ 2025-03-17  8:50 ` Jiri Slaby
  2025-03-17  9:18   ` tang.dongxing
  0 siblings, 1 reply; 3+ messages in thread
From: Jiri Slaby @ 2025-03-17  8:50 UTC (permalink / raw)
  To: tang.dongxing, jgross
  Cc: sstabellini, oleksandr_tyshchenko, jiqian.chen, ray.huang,
	jeff.johnson, minhuadotchen, xen-devel, linux-kernel,
	ye.xingchen, yang.guang5, yang.yang29, xu.xin16

On 17. 03. 25, 8:16, tang.dongxing@zte.com.cn wrote:
> From: TangDongxing <tang.dongxing@zte.com.cn>
> 
> Follow the advice in Documentation/filesystems/sysfs.rst:
> show() should only use sysfs_emit() or sysfs_emit_at() when formatting
> the value to be returned to user space.
> 
> Signed-off-by: TangDongxing <tang.dongxing@zte.com.cn>
> ---
>   drivers/xen/xen-pciback/pci_stub.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/xen/xen-pciback/pci_stub.c b/drivers/xen/xen-pciback/pci_stub.c
> index b616b7768c3b..a0782a74ed34 100644
> --- a/drivers/xen/xen-pciback/pci_stub.c
> +++ b/drivers/xen/xen-pciback/pci_stub.c
> @@ -1281,7 +1281,7 @@ static ssize_t slots_show(struct device_driver *drv, char *buf)
>   		if (count >= PAGE_SIZE)
>   			break;
> 
> -		count += scnprintf(buf + count, PAGE_SIZE - count,
> +		count += sysfs_emit_at(buf, count,

This is wrong too [1].

[1] 
https://lore.kernel.org/all/9c552d9a-2d46-4069-a9c4-35fab857bfc3@kernel.org/

regards,
-- 
js
suse labs


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] xen/pciback: use sysfs_emit_at() instead of scnprintf()
  2025-03-17  8:50 ` Jiri Slaby
@ 2025-03-17  9:18   ` tang.dongxing
  0 siblings, 0 replies; 3+ messages in thread
From: tang.dongxing @ 2025-03-17  9:18 UTC (permalink / raw)
  To: jirislaby
  Cc: jgross, sstabellini, oleksandr_tyshchenko, jiqian.chen,
	ray.huang, jeff.johnson, minhuadotchen, xen-devel, linux-kernel,
	ye.xingchen, yang.guang5, yang.yang29, xu.xin16


[-- Attachment #1.1.1: Type: text/plain, Size: 1270 bytes --]

>> From: TangDongxing <tang.dongxing@zte.com.cn>
>> 
>> Follow the advice in Documentation/filesystems/sysfs.rst:
>> show() should only use sysfs_emit() or sysfs_emit_at() when formatting
>> the value to be returned to user space.
>> 
>> Signed-off-by: TangDongxing <tang.dongxing@zte.com.cn>
>> ---
>>   drivers/xen/xen-pciback/pci_stub.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/drivers/xen/xen-pciback/pci_stub.c b/drivers/xen/xen-pciback/pci_stub.c
>> index b616b7768c3b..a0782a74ed34 100644
>> --- a/drivers/xen/xen-pciback/pci_stub.c
>> +++ b/drivers/xen/xen-pciback/pci_stub.c
>> @@ -1281,7 +1281,7 @@ static ssize_t slots_show(struct device_driver *drv, char *buf)
>>           if (count >= PAGE_SIZE)
>>               break;
>> 
>> -        count += scnprintf(buf + count, PAGE_SIZE - count,
>> +        count += sysfs_emit_at(buf, count,
>
>This is wrong too [1].
>
>[1] 
>https://lore.kernel.org/all/9c552d9a-2d46-4069-a9c4-35fab857bfc3@kernel.org/
>
>regards,
>-- 
>js
>suse labs

Dear JiriSlaby,

Thank you for your feedback,I am sorry for my previous submissions.
I will check my work before sending any further updates.

Thank you for your guidance.

Best regards,
Tang Dongxing

[-- Attachment #1.1.2: Type: text/html , Size: 1866 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-17  9:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-17  7:16 [PATCH] xen/pciback: use sysfs_emit_at() instead of scnprintf() tang.dongxing
2025-03-17  8:50 ` Jiri Slaby
2025-03-17  9:18   ` tang.dongxing

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®