iio: isl29018.c: replace sprintf with safer alternatives
PATCH v2 1/1 iio: isl29018.c: replace sprintf with safer alternatives
This patch replaces sprintf with sysfs_emit and sysfs_emit_at safer alternative with no functional changes.
---
V2:
- Fixed recipient list to include all reviewers (no code changes)
drivers/iio/light/isl29018.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/light/isl29018.c +3 -3
@@ -273,7 +273,7 @@ static ssize_t in_illuminance_scale_available_showmutex_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_showint 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
Signature · 1 line
2.43.0
Quoted 1 line · Tomas Borquez
This patch replaces sprintf with
sysfs_emitandsysfs_emit_atsafer alternative
sprintf()
"...sysfs_emit() and sysfs_emit_at()..."
alternatives
OR
"...sysfs_emit() or sysfs_emit_at()..."
Quoted 1 line
with no functional changes.
...
drivers/iio/light/isl29018.c static ssize_t in_illuminance_scale_available_show · line 278
Quoted 4 lines
drivers/iio/light/isl29018.c +1
-1- 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.
...
drivers/iio/light/isl29018.c static ssize_t in_illuminance_integration_time_available_show · line 297
Quoted 4 lines
drivers/iio/light/isl29018.c +1
-1for (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.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v3 1/1 iio: isl29018.c: replace sprintf with safer alternatives
In reply to Tomas BorquezThis patch replaces sprintf() with sysfs_emit() and sysfs_emit_at() safer alternative with no functional changes.
---
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(-)
drivers/iio/light/isl29018.c +6 -6
@@ -273,9 +273,9 @@ static ssize_t in_illuminance_scale_available_showmutex_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_showint 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
Signature · 1 line
2.43.0
Thanks for the review Andy!
Quoted 8 lines
sprintf()
"...sysfs_emit() andsysfs_emit_at()..."alternatives
OR
"...sysfs_emit() or
sysfs_emit_at()..."
...
Quoted 1 line
Forgot to update indentation.
Updated both commit message and indentation in v3
Tomas
Quoted 1 line · Tomas Borquez
This patch replaces
sprintf()withsysfs_emit()andsysfs_emit_at()safer alternative
This is a bit too long. Usually in the commit message the ~75 is a good threshold.
Quoted 1 line
with no functional changes.
Code wise LGTM,
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.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 3 lines · Andy Shevchenko
This is a bit too long. Usually in the commit message the ~75 is a good threshold.
...
Quoted 3 lines
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
Quoted 3 lines · Tomas Borquez
Quoted 2 lines · Andy Shevchenko
This is a bit too long. Usually in the commit message the ~75 is a good threshold.
...
Quoted 6 lines
Quoted 3 lines
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!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerQuoted 8 lines · On Wed, 26 Nov 2025 17:43:33 -0300 Tomas Borquez <[email protected]>…
Thanks for the review Andy!
Quoted 7 lines
sprintf()
"...sysfs_emit() andsysfs_emit_at()..."alternatives
OR
Quoted 7 lines
Quoted 1 line
"...sysfs_emit() or
sysfs_emit_at()..."...
Quoted 1 line
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
Quoted 2 lines
Tomas
Jonathan Cameron
maintainerQuoted 6 lines · On Wed, 26 Nov 2025 23:54:21 +0200 Andy Shevchenko…
Quoted 3 lines · Tomas Borquez
Quoted 2 lines · Andy Shevchenko
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.
Quoted 10 lines
Quoted 7 lines
Quoted 4 lines
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!