public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tomas Borquez <tomasborquez13@gmail.com>
To: jic23@kernel.org
Cc: andy@kernel.org, andriy.shevchenko@intel.com,
	dlechner@baylibre.com, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org, nuno.sa@analog.com,
	Tomas Borquez <tomasborquez13@gmail.com>
Subject: [PATCH v3] iio: isl29018.c: replace sprintf with safer alternatives
Date: Wed, 26 Nov 2025 17:32:40 -0300	[thread overview]
Message-ID: <20251126203240.13466-1-tomasborquez13@gmail.com> (raw)
In-Reply-To: <20251126172432.5532-1-tomasborquez13@gmail.com>

This patch replaces sprintf() with sysfs_emit() and sysfs_emit_at() safer alternative
with no functional changes.

Signed-off-by: Tomas Borquez <tomasborquez13@gmail.com>
---
V2:
- Fixed recipient list to include all reviewers (no code changes)
V3:
- Improved patch description and fixed indentation

 drivers/iio/light/isl29018.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/light/isl29018.c b/drivers/iio/light/isl29018.c
index 1b4c184230..b6ab726d1d 100644
--- a/drivers/iio/light/isl29018.c
+++ b/drivers/iio/light/isl29018.c
@@ -273,9 +273,9 @@ static ssize_t in_illuminance_scale_available_show
 
 	mutex_lock(&chip->lock);
 	for (i = 0; i < ARRAY_SIZE(isl29018_scales[chip->int_time]); ++i)
-		len += sprintf(buf + len, "%d.%06d ",
-			       isl29018_scales[chip->int_time][i].scale,
-			       isl29018_scales[chip->int_time][i].uscale);
+		len += sysfs_emit_at(buf, len, "%d.%06d ",
+				     isl29018_scales[chip->int_time][i].scale,
+				     isl29018_scales[chip->int_time][i].uscale);
 	mutex_unlock(&chip->lock);
 
 	buf[len - 1] = '\n';
@@ -293,8 +293,8 @@ static ssize_t in_illuminance_integration_time_available_show
 	int len = 0;
 
 	for (i = 0; i < ARRAY_SIZE(isl29018_int_utimes[chip->type]); ++i)
-		len += sprintf(buf + len, "0.%06d ",
-			       isl29018_int_utimes[chip->type][i]);
+		len += sysfs_emit_at(buf, len, "0.%06d ",
+				     isl29018_int_utimes[chip->type][i]);
 
 	buf[len - 1] = '\n';
 
@@ -330,7 +330,7 @@ static ssize_t proximity_on_chip_ambient_infrared_suppression_show
 	 * Return the "proximity scheme" i.e. if the chip does on chip
 	 * infrared suppression (1 means perform on chip suppression)
 	 */
-	return sprintf(buf, "%d\n", chip->prox_scheme);
+	return sysfs_emit(buf, "%d\n", chip->prox_scheme);
 }
 
 static ssize_t proximity_on_chip_ambient_infrared_suppression_store
-- 
2.43.0


  parent reply	other threads:[~2025-11-26 20:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-26 17:24 [PATCH v2] iio: isl29018.c: replace sprintf with safer alternatives Tomas Borquez
2025-11-26 19:35 ` Andy Shevchenko
2025-11-26 20:43   ` Tomas Borquez
2025-12-07 16:02     ` Jonathan Cameron
2025-11-26 20:32 ` Tomas Borquez [this message]
2025-11-26 21:09   ` [PATCH v3] " Andy Shevchenko
2025-11-26 21:46     ` Tomas Borquez
2025-11-26 21:54       ` Andy Shevchenko
2025-12-07 16:04         ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251126203240.13466-1-tomasborquez13@gmail.com \
    --to=tomasborquez13@gmail.com \
    --cc=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox