Skip to content

PCI: Replace use of snprintf() with scnprintf() in show() functions

Krzysztof Wilczyński linux-pci 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3PCI: Replace use of snprintf() with scnprintf() in resource_alignment_show()drivers/pci/pci.c+1 -10 replies
2/3PCI: sysfs: Replace use of snprintf() with scnprintf() in driver_override_show()drivers/pci/pci-sysfs.c+1 -10 replies
3/3PCI/P2PDMA: Replace use of snprintf() with scnprintf() in show() functionsdrivers/pci/p2pdma.c+4 -40 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] PCI: Replace use of snprintf() with scnprintf() in show() functions

Replace use of snprintf() with scnprintf() in order to adhere to the rules in Documentation/filesystems/sysfs.txt, as per:

show() must not use snprintf() when formatting the value to be returned to user space. If you can guarantee that an overflow will never happen you can use sprintf() otherwise you must use scnprintf().

Also resolve the following Coccinelle warnings, for example:

drivers/pci/p2pdma.c:69:8-16: WARNING: use scnprintf or sprintf drivers/pci/p2pdma.c:78:8-16: WARNING: use scnprintf or sprintf drivers/pci/p2pdma.c:56:8-16: WARNING: use scnprintf or sprintf

The Coccinelle warning was added in commit abfc19ff202d ("coccinelle:
api: add device_attr_show script").

There is no change to the functionality.

Related:
https://patchwork.kernel.org/patch/9946759/#20969333
https://lwn.net/Articles/69419

Krzysztof Wilczyński (3):
PCI: Replace use of snprintf() with scnprintf() in
resource_alignment_show()
PCI: sysfs: Replace use of snprintf() with scnprintf() in
driver_override_show()
PCI/P2PDMA: Replace use of snprintf() with scnprintf() in show()
functions

 drivers/pci/p2pdma.c    | 8 ++++----
 drivers/pci/pci-sysfs.c | 2 +-
 drivers/pci/pci.c       | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
2.28.0