Re: [PATCH] iio: proximity: srf08: replace sprintf with sysfs_emit

From: Andy Shevchenko

Date: Mon Apr 20 2026 - 03:27:33 EST


On Fri, Apr 17, 2026 at 07:52:04PM -0500, Maxwell Doose wrote:
> This patch replaces sprintf function calls with sysfs_emit and

sysfs_emit()

> sysfs_emit_at. This removes unsafe functions and makes the driver more

sysfs_emit_at()

> stable and modern, by ensuring that boundary checks take place.

...

> - return sprintf(buf, "%d.%03d\n", data->range_mm / 1000,
> + return sysfs_emit(buf, "%d.%03d\n", data->range_mm / 1000,
> data->range_mm % 1000);

While at it, we may rewrap it to follow the logical split:

return sysfs_emit(buf, "%d.%03d\n",
data->range_mm / 1000, data->range_mm % 1000);

No need to resend for this. And maybe Jonathan has better idea of this.

--
With Best Regards,
Andy Shevchenko