usb: gadget: configfs: Fix set but not used variable warning
PATCH 1/1 usb: gadget: configfs: Fix set but not used variable warning
Fix a -Wunused-but-set-variable warning in gadget_string_s_store()
--- drivers/usb/gadget/configfs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/usb/gadget/configfs.c +1 -3
@@ -821,13 +821,11 @@ static ssize_t gadget_string_s_store(struct config_item *item, const char *page, {struct gadget_string *string =to_gadget_string (item);int size =min (sizeof (string->string), len +1 ); -int ret;if (len >USB_MAX_STRING_LEN )return -EINVAL ; - ret =strscpy (string->string, page, size); -return len; +return strscpy (string->string, page, size); }CONFIGFS_ATTR (gadget_string_, s);
Signature · 1 line
2.34.1
Quoted 1 line · Daniel Scally
Fix a -Wunused-but-set-variable warning in
gadget_string_s_store()
A side comment below.
...
drivers/usb/gadget/configfs.c static ssize_t gadget_string_s_store(struct config_item *item, const char *page, · line 828
Quoted 6 lines
drivers/usb/gadget/configfs.c +1
-2if (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.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Hi Andy
Quoted 6 lines · Andy Shevchenko
Quoted 1 line · Daniel Scally
Fix a -Wunused-but-set-variable warning in
gadget_string_s_store()A side comment below.
...
Quoted 9 lines
drivers/usb/gadget/configfs.c static ssize_t gadget_string_s_store(struct config_item *item, const char *page, · line 828
Quoted 6 lines
if (len >
USB_MAX_STRING_LEN)
return-EINVAL;drivers/usb/gadget/configfs.c +1
-2- 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 thestrscpy()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.
Quoted 4 lines · Dan Scally
Quoted 3 lines · Andy Shevchenko
Quoted 1 line · Daniel Scally
Fix a -Wunused-but-set-variable warning in
gadget_string_s_store()A side comment below.
...
Quoted 11 lines
Quoted 8 lines
drivers/usb/gadget/configfs.c static ssize_t gadget_string_s_store(struct config_item *item, const char *page, · line 828
Quoted 5 lines
if (len >
USB_MAX_STRING_LEN)
return-EINVAL;drivers/usb/gadget/configfs.c +1
-2- 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 thestrscpy()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.
Signature · 2 lines
With Best Regards, Andy Shevchenko