linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next 0/2] sparc: use snprintf() in show() methods
@ 2020-05-09  9:18 Chen Zhou
  2020-05-09  9:18 ` [PATCH -next 1/2] sparc: use snprintf() in show_pciobppath_attr() in pci.c Chen Zhou
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Chen Zhou @ 2020-05-09  9:18 UTC (permalink / raw)
  To: davem; +Cc: sparclinux, linux-kernel, chenzhou10

snprintf() returns the number of bytes that would be written,
which may be greater than the the actual length to be written.
	    
show() methods should return the number of bytes printed into the
buffer. This is the return value of scnprintf().

Chen Zhou (2):
  sparc: use snprintf() in show_pciobppath_attr() in pci.c
  sparc: use snprintf() in show_pciobppath_attr() in vio.c

 arch/sparc/kernel/pci.c | 2 +-
 arch/sparc/kernel/vio.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

-- 
2.20.1


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

* [PATCH -next 1/2] sparc: use snprintf() in show_pciobppath_attr() in pci.c
  2020-05-09  9:18 [PATCH -next 0/2] sparc: use snprintf() in show() methods Chen Zhou
@ 2020-05-09  9:18 ` Chen Zhou
  2020-05-09  9:18 ` [PATCH -next 2/2] sparc: use snprintf() in show_pciobppath_attr() in vio.c Chen Zhou
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Chen Zhou @ 2020-05-09  9:18 UTC (permalink / raw)
  To: davem; +Cc: sparclinux, linux-kernel, chenzhou10

snprintf() returns the number of bytes that would be written,
which may be greater than the the actual length to be written.

show_pciobppath_attr() should return the number of bytes printed
into the buffer. This is the return value of scnprintf().

Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
---
 arch/sparc/kernel/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 5ed43828e078..a41ad562ed4e 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -593,7 +593,7 @@ show_pciobppath_attr(struct device * dev, struct device_attribute * attr, char *
 	pdev = to_pci_dev(dev);
 	dp = pdev->dev.of_node;
 
-	return snprintf (buf, PAGE_SIZE, "%pOF\n", dp);
+	return scnprintf(buf, PAGE_SIZE, "%pOF\n", dp);
 }
 
 static DEVICE_ATTR(obppath, S_IRUSR | S_IRGRP | S_IROTH, show_pciobppath_attr, NULL);
-- 
2.20.1


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

* [PATCH -next 2/2] sparc: use snprintf() in show_pciobppath_attr() in vio.c
  2020-05-09  9:18 [PATCH -next 0/2] sparc: use snprintf() in show() methods Chen Zhou
  2020-05-09  9:18 ` [PATCH -next 1/2] sparc: use snprintf() in show_pciobppath_attr() in pci.c Chen Zhou
@ 2020-05-09  9:18 ` Chen Zhou
  2020-05-09 11:40 ` [PATCH -next 0/2] sparc: use snprintf() in show() methods Joe Perches
  2020-05-13 22:36 ` David Miller
  3 siblings, 0 replies; 7+ messages in thread
From: Chen Zhou @ 2020-05-09  9:18 UTC (permalink / raw)
  To: davem; +Cc: sparclinux, linux-kernel, chenzhou10

snprintf() returns the number of bytes that would be written,
which may be greater than the the actual length to be written.

show_pciobppath_attr() should return the number of bytes printed
into the buffer. This is the return value of scnprintf().

Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
---
 arch/sparc/kernel/vio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sparc/kernel/vio.c b/arch/sparc/kernel/vio.c
index c7cad9b7bba7..4f57056ed463 100644
--- a/arch/sparc/kernel/vio.c
+++ b/arch/sparc/kernel/vio.c
@@ -193,7 +193,7 @@ show_pciobppath_attr(struct device *dev, struct device_attribute *attr,
 	vdev = to_vio_dev(dev);
 	dp = vdev->dp;
 
-	return snprintf (buf, PAGE_SIZE, "%pOF\n", dp);
+	return scnprintf(buf, PAGE_SIZE, "%pOF\n", dp);
 }
 
 static DEVICE_ATTR(obppath, S_IRUSR | S_IRGRP | S_IROTH,
-- 
2.20.1


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

* Re: [PATCH -next 0/2] sparc: use snprintf() in show() methods
  2020-05-09  9:18 [PATCH -next 0/2] sparc: use snprintf() in show() methods Chen Zhou
  2020-05-09  9:18 ` [PATCH -next 1/2] sparc: use snprintf() in show_pciobppath_attr() in pci.c Chen Zhou
  2020-05-09  9:18 ` [PATCH -next 2/2] sparc: use snprintf() in show_pciobppath_attr() in vio.c Chen Zhou
@ 2020-05-09 11:40 ` Joe Perches
  2020-05-11  1:24   ` chenzhou
  2020-05-13 22:36 ` David Miller
  3 siblings, 1 reply; 7+ messages in thread
From: Joe Perches @ 2020-05-09 11:40 UTC (permalink / raw)
  To: Chen Zhou, davem; +Cc: sparclinux, linux-kernel

On Sat, 2020-05-09 at 17:18 +0800, Chen Zhou wrote:
> snprintf() returns the number of bytes that would be written,
> which may be greater than the the actual length to be written.
[]
> Chen Zhou (2):
>   sparc: use snprintf() in show_pciobppath_attr() in pci.c
>   sparc: use snprintf() in show_pciobppath_attr() in vio.c

Your subjects are a bit off: snprintf vs scnprintf



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

* Re: [PATCH -next 0/2] sparc: use snprintf() in show() methods
  2020-05-09 11:40 ` [PATCH -next 0/2] sparc: use snprintf() in show() methods Joe Perches
@ 2020-05-11  1:24   ` chenzhou
  2020-05-11  1:32     ` Joe Perches
  0 siblings, 1 reply; 7+ messages in thread
From: chenzhou @ 2020-05-11  1:24 UTC (permalink / raw)
  To: Joe Perches, davem; +Cc: sparclinux, linux-kernel

Sorry, i made a mistake, should be scnprintf().


On 2020/5/9 19:40, Joe Perches wrote:
> On Sat, 2020-05-09 at 17:18 +0800, Chen Zhou wrote:
>> snprintf() returns the number of bytes that would be written,
>> which may be greater than the the actual length to be written.
> []
>> Chen Zhou (2):
>>   sparc: use snprintf() in show_pciobppath_attr() in pci.c
>>   sparc: use snprintf() in show_pciobppath_attr() in vio.c
> Your subjects are a bit off: snprintf vs scnprintf
>
>
>
>



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

* Re: [PATCH -next 0/2] sparc: use snprintf() in show() methods
  2020-05-11  1:24   ` chenzhou
@ 2020-05-11  1:32     ` Joe Perches
  0 siblings, 0 replies; 7+ messages in thread
From: Joe Perches @ 2020-05-11  1:32 UTC (permalink / raw)
  To: chenzhou, davem; +Cc: sparclinux, linux-kernel

On Mon, 2020-05-11 at 09:24 +0800, chenzhou wrote:
> Sorry, i made a mistake, should be scnprintf().

No worries.

But why do you think this is useful?
Is it likely that either snprint length will exceed PAGE_SIZE?

> 
> On 2020/5/9 19:40, Joe Perches wrote:
> > On Sat, 2020-05-09 at 17:18 +0800, Chen Zhou wrote:
> > > snprintf() returns the number of bytes that would be written,
> > > which may be greater than the the actual length to be written.
> > []
> > > Chen Zhou (2):
> > >   sparc: use snprintf() in show_pciobppath_attr() in pci.c
> > >   sparc: use snprintf() in show_pciobppath_attr() in vio.c
> > Your subjects are a bit off: snprintf vs scnprintf
> > 
> > 
> > 
> > 
> 
> 


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

* Re: [PATCH -next 0/2] sparc: use snprintf() in show() methods
  2020-05-09  9:18 [PATCH -next 0/2] sparc: use snprintf() in show() methods Chen Zhou
                   ` (2 preceding siblings ...)
  2020-05-09 11:40 ` [PATCH -next 0/2] sparc: use snprintf() in show() methods Joe Perches
@ 2020-05-13 22:36 ` David Miller
  3 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2020-05-13 22:36 UTC (permalink / raw)
  To: chenzhou10; +Cc: sparclinux, linux-kernel

From: Chen Zhou <chenzhou10@huawei.com>
Date: Sat, 9 May 2020 17:18:47 +0800

> snprintf() returns the number of bytes that would be written,
> which may be greater than the the actual length to be written.
> 	    
> show() methods should return the number of bytes printed into the
> buffer. This is the return value of scnprintf().

Series applied with Subject lines corrected.

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

end of thread, other threads:[~2020-05-13 22:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-09  9:18 [PATCH -next 0/2] sparc: use snprintf() in show() methods Chen Zhou
2020-05-09  9:18 ` [PATCH -next 1/2] sparc: use snprintf() in show_pciobppath_attr() in pci.c Chen Zhou
2020-05-09  9:18 ` [PATCH -next 2/2] sparc: use snprintf() in show_pciobppath_attr() in vio.c Chen Zhou
2020-05-09 11:40 ` [PATCH -next 0/2] sparc: use snprintf() in show() methods Joe Perches
2020-05-11  1:24   ` chenzhou
2020-05-11  1:32     ` Joe Perches
2020-05-13 22:36 ` David Miller

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).