On Fri, Feb 10, 2023 at 04:03:52PM +0000, Dan Scally wrote: > On 10/02/2023 15:54, Andy Shevchenko wrote: > > On Thu, Feb 09, 2023 at 09:43:59AM +0000, Daniel Scally wrote: > > > Fix a -Wunused-but-set-variable warning in gadget_string_s_store() > > A side comment below. ... > > > if (len > USB_MAX_STRING_LEN) > > > return -EINVAL; > > > - ret = strscpy(string->string, page, size); > > > - return len; > > > + return strscpy(string->string, page, size); > > Do you need above check with strscpy()? You may supply the maximum length > > and negative error code from the strscpy() will indicate the cut. > > > It would still copy the truncated string in that case though, correct? Seems > cleaner to me to just fail and leave the string as-is, but I don't > particularly mind either way. Good point. Yes, depending on the nature of the data we copy it (my proposal) may or may not be a good idea. -- With Best Regards, Andy Shevchenko