All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: storage: freecom: drop useless assignment in init_freecom()
@ 2023-11-29 20:43 Sergey Shtylyov
  2023-12-04  7:04 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 5+ messages in thread
From: Sergey Shtylyov @ 2023-11-29 20:43 UTC (permalink / raw)
  To: Alan Stern, Greg Kroah-Hartman, linux-usb, usb-storage

In init_freecom(), the results of usb_stor_control_msg() calls are stored
in the local variable and then printed out by usb_stor_dbg() (if enabled),
except for the 1st call, the result of which is completely ignored.  Drop
the useless assignment.

Found by Linux Verification Center (linuxtesting.org) with the Svace static
analysis tool.

Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>

---
This patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo...

 drivers/usb/storage/freecom.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: usb/drivers/usb/storage/freecom.c
===================================================================
--- usb.orig/drivers/usb/storage/freecom.c
+++ usb/drivers/usb/storage/freecom.c
@@ -446,7 +446,7 @@ static int init_freecom(struct us_data *
 	 * all our packets.  No need to allocate any extra buffer space.
 	 */
 
-	result = usb_stor_control_msg(us, us->recv_ctrl_pipe,
+	usb_stor_control_msg(us, us->recv_ctrl_pipe,
 			0x4c, 0xc0, 0x4346, 0x0, buffer, 0x20, 3*HZ);
 	buffer[32] = '\0';
 	usb_stor_dbg(us, "String returned from FC init is: %s\n", buffer);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: storage: freecom: drop useless assignment in init_freecom()
  2023-11-29 20:43 [PATCH] usb: storage: freecom: drop useless assignment in init_freecom() Sergey Shtylyov
@ 2023-12-04  7:04 ` Greg Kroah-Hartman
  2023-12-07 16:16   ` Sergey Shtylyov
  0 siblings, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2023-12-04  7:04 UTC (permalink / raw)
  To: Sergey Shtylyov; +Cc: Alan Stern, linux-usb, usb-storage

On Wed, Nov 29, 2023 at 11:43:50PM +0300, Sergey Shtylyov wrote:
> In init_freecom(), the results of usb_stor_control_msg() calls are stored
> in the local variable and then printed out by usb_stor_dbg() (if enabled),
> except for the 1st call, the result of which is completely ignored.  Drop
> the useless assignment.

Instead, you should check the return value and handle it properly, don't
just drop the checking entirely, that's not good.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: storage: freecom: drop useless assignment in init_freecom()
  2023-12-04  7:04 ` Greg Kroah-Hartman
@ 2023-12-07 16:16   ` Sergey Shtylyov
  2024-01-22 18:26     ` Sergey Shtylyov
  0 siblings, 1 reply; 5+ messages in thread
From: Sergey Shtylyov @ 2023-12-07 16:16 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Alan Stern, linux-usb, usb-storage

On 12/4/23 10:04 AM, Greg Kroah-Hartman wrote:
[...]
>> In init_freecom(), the results of usb_stor_control_msg() calls are stored
>> in the local variable and then printed out by usb_stor_dbg() (if enabled),
>> except for the 1st call, the result of which is completely ignored.  Drop
>> the useless assignment.
> 
> Instead, you should check the return value and handle it properly, don't
> just drop the checking entirely, that's not good.

   Hmm... I wonder if you'd actually read the patch...
   I'm not dropping any checking because there's none, even at the further
call sites of usb_stor_control_msg() -- the most init_freecom() currently
is doing is printing out the result of the calls...

> thanks,
> 
> greg k-h

MBR, Sergey

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: storage: freecom: drop useless assignment in init_freecom()
  2023-12-07 16:16   ` Sergey Shtylyov
@ 2024-01-22 18:26     ` Sergey Shtylyov
  2024-01-22 18:53       ` Alan Stern
  0 siblings, 1 reply; 5+ messages in thread
From: Sergey Shtylyov @ 2024-01-22 18:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Alan Stern, linux-usb, usb-storage

On 12/7/23 7:16 PM, Sergey Shtylyov wrote:

[...]
>>> In init_freecom(), the results of usb_stor_control_msg() calls are stored
>>> in the local variable and then printed out by usb_stor_dbg() (if enabled),
>>> except for the 1st call, the result of which is completely ignored.  Drop
>>> the useless assignment.
>>
>> Instead, you should check the return value and handle it properly, don't
>> just drop the checking entirely, that's not good.
> 
>    Hmm... I wonder if you'd actually read the patch...
>    I'm not dropping any checking because there's none, even at the further
> call sites of usb_stor_control_msg() -- the most init_freecom() currently
> is doing is printing out the result of the calls...

   Alan, haven't heard your opinion on this patch... What do you think?

[...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: storage: freecom: drop useless assignment in init_freecom()
  2024-01-22 18:26     ` Sergey Shtylyov
@ 2024-01-22 18:53       ` Alan Stern
  0 siblings, 0 replies; 5+ messages in thread
From: Alan Stern @ 2024-01-22 18:53 UTC (permalink / raw)
  To: Sergey Shtylyov; +Cc: Greg Kroah-Hartman, linux-usb, usb-storage

On Mon, Jan 22, 2024 at 09:26:51PM +0300, Sergey Shtylyov wrote:
> On 12/7/23 7:16 PM, Sergey Shtylyov wrote:
> 
> [...]
> >>> In init_freecom(), the results of usb_stor_control_msg() calls are stored
> >>> in the local variable and then printed out by usb_stor_dbg() (if enabled),
> >>> except for the 1st call, the result of which is completely ignored.  Drop
> >>> the useless assignment.
> >>
> >> Instead, you should check the return value and handle it properly, don't
> >> just drop the checking entirely, that's not good.
> > 
> >    Hmm... I wonder if you'd actually read the patch...
> >    I'm not dropping any checking because there's none, even at the further
> > call sites of usb_stor_control_msg() -- the most init_freecom() currently
> > is doing is printing out the result of the calls...
> 
>    Alan, haven't heard your opinion on this patch... What do you think?

Oh, sorry about that.  There's nothing wrong with the patch.  None of 
the return values in that function are used for anything other than 
debug log messages.  (It's a little surprising that the original author 
of this driver didn't put any error checking here.)

Greg, feel free to merge the patch.

Acked-by: Alan Stern <stern@rowland.harvard.edu>

Alan Stern

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-01-22 18:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-29 20:43 [PATCH] usb: storage: freecom: drop useless assignment in init_freecom() Sergey Shtylyov
2023-12-04  7:04 ` Greg Kroah-Hartman
2023-12-07 16:16   ` Sergey Shtylyov
2024-01-22 18:26     ` Sergey Shtylyov
2024-01-22 18:53       ` Alan Stern

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.