Re: [PATCH] net: dsa: realtek: rtl8365mb: replace deprecated strncpy with ethtool_sprintf

From: Vladimir Oltean
Date: Tue Oct 10 2023 - 18:06:55 EST


On Tue, Oct 10, 2023 at 02:48:07PM -0700, Justin Stitt wrote:
> On Tue, Oct 10, 2023 at 10:36 AM Justin Stitt <justinstitt@xxxxxxxxxx> wrote:
> > > Is there any particular reason why you opted for the "%s" printf format
> > > specifier when you could have simply given mib->name as the single
> > > argument? This comment applies to all the ethtool_sprintf() patches
> > > you've submitted.
> >
> > Yeah, it causes a -Wformat-security warning for me. I briefly mentioned it
> > in one of my first patches like this [1].
>
> For more context, here's some warnings in the wild:
> https://lore.kernel.org/netdev/20231003183603.3887546-3-jesse.brandeburg@xxxxxxxxx/
>
> >
> > [1]: https://lore.kernel.org/all/20231005-strncpy-drivers-net-dsa-lan9303-core-c-v2-1-feb452a532db@xxxxxxxxxx/

Yeah, ok. It's a false positive warning, but I guess it would be too
hard for the compiler to figure that out.