linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: gyro: adis16136: use scnprintf instead of snprintf
@ 2020-03-18 14:55 Rohit Sarkar
  2020-03-22  0:25 ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Rohit Sarkar @ 2020-03-18 14:55 UTC (permalink / raw)
  To: linux-iio, linux-kernel
  Cc: jic23, rohitsarkar5398, dragos.bogdan, Lars-Peter Clausen,
	Michael Hennerich, Stefan Popa, knaack.h, pmeerw

scnprintf returns the actual number of bytes written into the buffer as
opposed to snprintf which returns the number of bytes that would have
been written if the buffer was big enough. Using the output of snprintf
may lead to difficult to detect bugs.

Thanks,
Rohit

Signed-off-by: Rohit Sarkar <rohitsarkar5398@gmail.com>
---
 drivers/iio/gyro/adis16136.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/gyro/adis16136.c b/drivers/iio/gyro/adis16136.c
index a4c967a5fc5c..0a8bb02dc4b9 100644
--- a/drivers/iio/gyro/adis16136.c
+++ b/drivers/iio/gyro/adis16136.c
@@ -96,7 +96,7 @@ static ssize_t adis16136_show_serial(struct file *file,
 	if (ret)
 		return ret;
 
-	len = snprintf(buf, sizeof(buf), "%.4x%.4x%.4x-%.4x\n", lot1, lot2,
+	len = scnprintf(buf, sizeof(buf), "%.4x%.4x%.4x-%.4x\n", lot1, lot2,
 		lot3, serial);
 
 	return simple_read_from_buffer(userbuf, count, ppos, buf, len);
-- 
2.23.0.385.gbc12974a89


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

end of thread, other threads:[~2020-03-23 16:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-18 14:55 [PATCH] iio: gyro: adis16136: use scnprintf instead of snprintf Rohit Sarkar
2020-03-22  0:25 ` Andy Shevchenko
2020-03-22  6:11   ` Rohit Sarkar
2020-03-22 10:27     ` Andy Shevchenko
2020-03-23 15:04       ` David Laight
2020-03-23 16:05         ` 'Andy Shevchenko'

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