public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] iio: isl29018.c: replace sprintf with safer alternatives
@ 2025-11-26 17:24 Tomas Borquez
  2025-11-26 19:35 ` Andy Shevchenko
  2025-11-26 20:32 ` [PATCH v3] " Tomas Borquez
  0 siblings, 2 replies; 9+ messages in thread
From: Tomas Borquez @ 2025-11-26 17:24 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
	linux-kernel, Tomas Borquez

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)

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

diff --git a/drivers/iio/light/isl29018.c b/drivers/iio/light/isl29018.c
index 1b4c18423..d00e951c5 100644
--- a/drivers/iio/light/isl29018.c
+++ b/drivers/iio/light/isl29018.c
@@ -273,7 +273,7 @@ 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 ",
+		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);
@@ -293,7 +293,7 @@ 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 ",
+		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


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

* Re: [PATCH v2] iio: isl29018.c: replace sprintf with safer alternatives
  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-11-26 20:32 ` [PATCH v3] " Tomas Borquez
  1 sibling, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2025-11-26 19:35 UTC (permalink / raw)
  To: Tomas Borquez
  Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	linux-iio, linux-kernel

On Wed, Nov 26, 2025 at 02:24:32PM -0300, Tomas Borquez wrote:
> This patch replaces sprintf with sysfs_emit and sysfs_emit_at safer alternative

sprintf()
"...sysfs_emit() and sysfs_emit_at()..."

alternatives

OR

"...sysfs_emit() or sysfs_emit_at()..."

> with no functional changes.

...

> -		len += sprintf(buf + len, "%d.%06d ",
> +		len += sysfs_emit_at(buf, len, "%d.%06d ",
>  			       isl29018_scales[chip->int_time][i].scale,
>  			       isl29018_scales[chip->int_time][i].uscale);

Forgot to update indentation.

...

>  	for (i = 0; i < ARRAY_SIZE(isl29018_int_utimes[chip->type]); ++i)
> -		len += sprintf(buf + len, "0.%06d ",
> +		len += sysfs_emit_at(buf, len, "0.%06d ",
>  			       isl29018_int_utimes[chip->type][i]);

Ditto.

-- 
With Best Regards,
Andy Shevchenko



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

* [PATCH v3] iio: isl29018.c: replace sprintf with safer alternatives
  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:32 ` Tomas Borquez
  2025-11-26 21:09   ` Andy Shevchenko
  1 sibling, 1 reply; 9+ messages in thread
From: Tomas Borquez @ 2025-11-26 20:32 UTC (permalink / raw)
  To: jic23
  Cc: andy, andriy.shevchenko, dlechner, linux-iio, linux-kernel,
	nuno.sa, Tomas Borquez

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


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

* Re: [PATCH v2] iio: isl29018.c: replace sprintf with safer alternatives
  2025-11-26 19:35 ` Andy Shevchenko
@ 2025-11-26 20:43   ` Tomas Borquez
  2025-12-07 16:02     ` Jonathan Cameron
  0 siblings, 1 reply; 9+ messages in thread
From: Tomas Borquez @ 2025-11-26 20:43 UTC (permalink / raw)
  To: andriy.shevchenko; +Cc: jic23, linux-iio, linux-kernel, Tomas Borquez

Thanks for the review Andy!
> sprintf()
> "...sysfs_emit() and sysfs_emit_at()..."
> 
> alternatives
> 
> OR
> 
> "...sysfs_emit() or sysfs_emit_at()..."

...

> Forgot to update indentation.

Updated both commit message and indentation in v3

Tomas

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

* Re: [PATCH v3] iio: isl29018.c: replace sprintf with safer alternatives
  2025-11-26 20:32 ` [PATCH v3] " Tomas Borquez
@ 2025-11-26 21:09   ` Andy Shevchenko
  2025-11-26 21:46     ` Tomas Borquez
  0 siblings, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2025-11-26 21:09 UTC (permalink / raw)
  To: Tomas Borquez; +Cc: jic23, andy, dlechner, linux-iio, linux-kernel, nuno.sa

On Wed, Nov 26, 2025 at 05:32:40PM -0300, Tomas Borquez wrote:
> This patch replaces sprintf() with sysfs_emit() and sysfs_emit_at() safer alternative

This is a bit too long. Usually in the commit message the ~75 is a good
threshold.

> with no functional changes.

Code wise LGTM,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

P.S. Do NOT resend if not asked so. Jonathan may amend this whilst applying.
Also note, this most likely misses the v6.19-rc1, so we have plenty of time,
no rush with it.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v3] iio: isl29018.c: replace sprintf with safer alternatives
  2025-11-26 21:09   ` Andy Shevchenko
@ 2025-11-26 21:46     ` Tomas Borquez
  2025-11-26 21:54       ` Andy Shevchenko
  0 siblings, 1 reply; 9+ messages in thread
From: Tomas Borquez @ 2025-11-26 21:46 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: jic23, andy, dlechner, linux-iio, linux-kernel, nuno.sa

On Wed, Nov 26, 2025 at 11:09:07PM +0200, Andy Shevchenko wrote:
> This is a bit too long. Usually in the commit message the ~75 is a good
> threshold.
> 
...
> P.S. Do NOT resend if not asked so. Jonathan may amend this whilst applying.
> Also note, this most likely misses the v6.19-rc1, so we have plenty of time,
> no rush with it.
Ah I see, my bad, its my first patch so I'm still adjusting to the workflow.
Thanks for the feedback, will keep everything in mind!

Tomas

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

* Re: [PATCH v3] iio: isl29018.c: replace sprintf with safer alternatives
  2025-11-26 21:46     ` Tomas Borquez
@ 2025-11-26 21:54       ` Andy Shevchenko
  2025-12-07 16:04         ` Jonathan Cameron
  0 siblings, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2025-11-26 21:54 UTC (permalink / raw)
  To: Tomas Borquez; +Cc: jic23, andy, dlechner, linux-iio, linux-kernel, nuno.sa

On Wed, Nov 26, 2025 at 06:46:18PM -0300, Tomas Borquez wrote:
> On Wed, Nov 26, 2025 at 11:09:07PM +0200, Andy Shevchenko wrote:
> > This is a bit too long. Usually in the commit message the ~75 is a good
> > threshold.

...

> > P.S. Do NOT resend if not asked so. Jonathan may amend this whilst applying.
> > Also note, this most likely misses the v6.19-rc1, so we have plenty of time,
> > no rush with it.

> Ah I see, my bad, its my first patch so I'm still adjusting to the workflow.
> Thanks for the feedback, will keep everything in mind!

NP and welcome aboard!

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2] iio: isl29018.c: replace sprintf with safer alternatives
  2025-11-26 20:43   ` Tomas Borquez
@ 2025-12-07 16:02     ` Jonathan Cameron
  0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2025-12-07 16:02 UTC (permalink / raw)
  To: Tomas Borquez; +Cc: andriy.shevchenko, linux-iio, linux-kernel

On Wed, 26 Nov 2025 17:43:33 -0300
Tomas Borquez <tomasborquez13@gmail.com> wrote:

> Thanks for the review Andy!
> > sprintf()
> > "...sysfs_emit() and sysfs_emit_at()..."
> > 
> > alternatives
> > 
> > OR
> > 
> > "...sysfs_emit() or sysfs_emit_at()..."  
> 
> ...
> 
> > Forgot to update indentation.  
> 
> Updated both commit message and indentation in v3
Hi Tomas

I moaning a bit about this today as I have a very long
email backlog.  This comment belongs only in the changelog
of v3.  Sending a reply here just adds noise to the email
queue of reviewers. i.e. Don't reply to just say this.

Jonathan

> 
> Tomas


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

* Re: [PATCH v3] iio: isl29018.c: replace sprintf with safer alternatives
  2025-11-26 21:54       ` Andy Shevchenko
@ 2025-12-07 16:04         ` Jonathan Cameron
  0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2025-12-07 16:04 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Tomas Borquez, andy, dlechner, linux-iio, linux-kernel, nuno.sa

On Wed, 26 Nov 2025 23:54:21 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Wed, Nov 26, 2025 at 06:46:18PM -0300, Tomas Borquez wrote:
> > On Wed, Nov 26, 2025 at 11:09:07PM +0200, Andy Shevchenko wrote:  
> > > This is a bit too long. Usually in the commit message the ~75 is a good
> > > threshold.  
> 
> ...
I tweaked the title as well to be:
iio: light: isl29018: replace sprintf() with safer alternatives

Applied to my currently local only togreg branch. I'll rebase on rc1 once it
is out and then it will turn up in linux-next etc.

> 
> > > P.S. Do NOT resend if not asked so. Jonathan may amend this whilst applying.
> > > Also note, this most likely misses the v6.19-rc1, so we have plenty of time,
> > > no rush with it.  
> 
> > Ah I see, my bad, its my first patch so I'm still adjusting to the workflow.
> > Thanks for the feedback, will keep everything in mind!  
> 
> NP and welcome aboard!
> 
Seconded!

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

end of thread, other threads:[~2025-12-07 16:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH v3] " Tomas Borquez
2025-11-26 21:09   ` Andy Shevchenko
2025-11-26 21:46     ` Tomas Borquez
2025-11-26 21:54       ` Andy Shevchenko
2025-12-07 16:04         ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox