Re: [PATCH v3 3/3] iio: imu: st_lsm6dsx: add support for rotation sensor

From: Andy Shevchenko

Date: Tue Jan 20 2026 - 04:36:10 EST


On Tue, Jan 20, 2026 at 10:28:15AM +0100, Francesco Lavra wrote:
> On Mon, 2026-01-19 at 12:33 +0200, Andy Shevchenko wrote:
> > On Mon, Jan 19, 2026 at 11:04:49AM +0100, Francesco Lavra wrote:

...

> > > +       snprintf(sensor->name, sizeof(sensor->name), "%s_sf", name);
> >
> > Does GCC complain on this (`make W=1` build)?
> > Since this can cut the string and we don't check the return value, the Q
> > is:
> > is this okay to have a reduced string?
>
> gcc does not complain with W=1. sensor->name is appropriately sized to
> accommodate the longest possible name; if it wasn't, the string would be
> cut in the accel and gyro IIO devices too (which use a longer suffix than
> "_sf").

Right, the question is if compiler can prove that or not.

We have several patches in input subsystem to hide the warning by switching
to scnprintf(), which I consider not the best approach, but still it depends
if we care about cut or not. If we do, we should check for overflow.

--
With Best Regards,
Andy Shevchenko