sparc: use snprintf() in show() methods
cover sparc: use snprintf() in show() methods
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(-)
Signature · 1 line
2.20.1
PATCH 1/2 sparc: use snprintf() in show_pciobppath_attr() in pci.c
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().
--- arch/sparc/kernel/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sparc/kernel/pci.c +1 -1
@@ -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);
Signature · 1 line
2.20.1
PATCH 2/2 sparc: use snprintf() in show_pciobppath_attr() in vio.c
In reply to Chen Zhousnprintf() 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().
--- arch/sparc/kernel/vio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sparc/kernel/vio.c +1 -1
@@ -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,
Signature · 1 line
2.20.1
Quoted 2 lines · Chen Zhou
snprintf()returns the number of bytes that would be written, which may be greater than the the actual length to be written.
[]
Quoted 3 lines
Chen Zhou (2):
sparc: usesnprintf()inshow_pciobppath_attr()inpci.c
sparc: usesnprintf()inshow_pciobppath_attr()invio.c
Your subjects are a bit off: snprintf vs scnprintf
Sorry, i made a mistake, should be scnprintf().
Quoted 12 lines · Joe Perches
Quoted 2 lines · Chen Zhou
snprintf()returns the number of bytes that would be written, which may be greater than the the actual length to be written.[]
Quoted 3 lines
Chen Zhou (2):
sparc: usesnprintf()inshow_pciobppath_attr()inpci.c
sparc: usesnprintf()inshow_pciobppath_attr()invio.cYour subjects are a bit off: snprintf vs scnprintf
Quoted 1 line · chenzhou
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?
Quoted 16 lines · Joe Perches
Quoted 12 lines · Chen Zhou
Quoted 2 lines
snprintf()returns the number of bytes that would be written, which may be greater than the the actual length to be written.[]
Quoted 3 lines
Chen Zhou (2):
sparc: usesnprintf()inshow_pciobppath_attr()inpci.c
sparc: usesnprintf()inshow_pciobppath_attr()invio.cYour subjects are a bit off: snprintf vs scnprintf
David Miller
maintainerFrom: Chen Zhou <[email protected]>
Date: Sat, 9 May 2020 17:18:47 +0800
Quoted 5 lines
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 ofscnprintf().
Series applied with Subject lines corrected.