[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87pnen3av8.fsf@kernel.org>
Date: Sun, 09 Feb 2020 19:54:03 +0200
From: Felipe Balbi <balbi@...nel.org>
To: Colin King <colin.king@...onical.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-usb@...r.kernel.org
Cc: kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] usb: dwc3: debug: remove redundant call to strlen
Colin King <colin.king@...onical.com> writes:
> From: Colin Ian King <colin.king@...onical.com>
>
> The call to strlen is redundant since the return value is assigned
> to variable len but not subsequently used. Remove the redundant
> call.
>
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King <colin.king@...onical.com>
> ---
> drivers/usb/dwc3/debug.h | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/usb/dwc3/debug.h b/drivers/usb/dwc3/debug.h
> index e56beb9d1e36..ee964352c8e2 100644
> --- a/drivers/usb/dwc3/debug.h
> +++ b/drivers/usb/dwc3/debug.h
> @@ -296,8 +296,6 @@ static inline const char *dwc3_ep_event_string(char *str, size_t size,
> status & DEPEVT_STATUS_TRANSFER_ACTIVE ?
> " (Active)" : " (Not Active)");
>
> - len = strlen(str);
> -
looking at the code here. The problem is elsewhere:
| case DWC3_DEPEVT_XFERNOTREADY:
| len = strlen(str);
| snprintf(str + len, size - len, "Transfer Not Ready [%d]%s",
| event->parameters,
| status & DEPEVT_STATUS_TRANSFER_ACTIVE ?
| " (Active)" : " (Not Active)");
|
| len = strlen(str);
|
| /* Control Endpoints */
| if (epnum <= 1) {
| int phase = DEPEVT_STATUS_CONTROL_PHASE(event->status);
| switch (phase) {
| case DEPEVT_STATUS_CONTROL_DATA:
| snprintf(str + ret, size - ret,
| " [Data Phase]");
| break;
| case DEPEVT_STATUS_CONTROL_STATUS:
| snprintf(str + ret, size - ret,
| " [Status Phase]");
these two should use str + len and size - len. However, a better fix
would be drop the usage of strlen() and just use the return value from
snprintf().
Do you want to produce that patch, instead? It could be two patches:
1. replace ret with len in these two cases (a bug fix, possibly
Cc stable)
2. drop usage of strlen() in the entire function (a new feature,
for v5.7
--
balbi
Download attachment "signature.asc" of type "application/pgp-signature" (833 bytes)
Powered by blists - more mailing lists