Re: [PATCH v1 1/1] usb: f_mass_storage: Bump local buffer size in fsg_common_create_luns()

From: Andy Shevchenko

Date: Mon Aug 17 2026 - 12:35:43 EST


On Mon, Aug 17, 2026 at 09:47:45AM -0400, Alan Stern wrote:
> On Mon, Aug 17, 2026 at 12:47:34PM +0200, Andy Shevchenko wrote:
> > GCC is not happy about the buffer size:
> >
> > drivers/usb/gadget/function/f_mass_storage.c:2970:48: error: ‘%d’ directive output may be truncated writing between 1 and 9 bytes into a region of size 5 [-Werror=format-truncation=]
> >
> > Bump the size to get it enough for all possible values.
> >
> > Note, the existing comment is wrong as size 8 for the whole buffer doesn't
> > cover 100 mil numbers, hence drop it altogether.
>
> It seems highly unlikely that anyone would ever want to create 100 million
> LUNs.

Completely agree (but see below).

> Why not limit the number of LUNs to some more reasonable value, like 1000?

I chose the robust way as different versions of the compiler may or may not
that limit (yes, we had such a case in the past [1] and it required to replace
also specifier and variable type altogether. Given that, I'm not feeling to
rework that way. Up to you to implement, though. If you think this patch is
not good enough, consider this then as a bug report (with `make W=1` it breaks
the build, exactly what my case is).

Thanks for the review.

[1]: 239afba8b9f3 ("leds: pca955x: Avoid potential overflow when filling default_label (take 2)")

--
With Best Regards,
Andy Shevchenko