public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: usbip: remove unnecessary cmd variable
@ 2024-06-28 10:46 Xiaobo Liu
  2024-06-28 17:15 ` Shuah Khan
  0 siblings, 1 reply; 2+ messages in thread
From: Xiaobo Liu @ 2024-06-28 10:46 UTC (permalink / raw)
  To: valentina.manea.m, shuah, i; +Cc: gregkh, linux-usb, linux-kernel, cppcoffee

There are two redundant if conditions that can be simplified to directly use pdu->u.cmd_submit.

Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
---
 drivers/usb/usbip/usbip_common.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/usb/usbip/usbip_common.c b/drivers/usb/usbip/usbip_common.c
index a2b2da125..74a01a265 100644
--- a/drivers/usb/usbip/usbip_common.c
+++ b/drivers/usb/usbip/usbip_common.c
@@ -568,17 +568,9 @@ static void correct_endian_ret_unlink(struct usbip_header_ret_unlink *pdu,
 
 void usbip_header_correct_endian(struct usbip_header *pdu, int send)
 {
-	__u32 cmd = 0;
-
-	if (send)
-		cmd = pdu->base.command;
-
 	correct_endian_basic(&pdu->base, send);
 
-	if (!send)
-		cmd = pdu->base.command;
-
-	switch (cmd) {
+	switch (pdu->base.command) {
 	case USBIP_CMD_SUBMIT:
 		correct_endian_cmd_submit(&pdu->u.cmd_submit, send);
 		break;
-- 
2.34.1


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

* Re: [PATCH] usb: usbip: remove unnecessary cmd variable
  2024-06-28 10:46 [PATCH] usb: usbip: remove unnecessary cmd variable Xiaobo Liu
@ 2024-06-28 17:15 ` Shuah Khan
  0 siblings, 0 replies; 2+ messages in thread
From: Shuah Khan @ 2024-06-28 17:15 UTC (permalink / raw)
  To: Xiaobo Liu, valentina.manea.m, shuah, i
  Cc: gregkh, linux-usb, linux-kernel, Shuah Khan

On 6/28/24 04:46, Xiaobo Liu wrote:
> There are two redundant if conditions that can be simplified to directly use pdu->u.cmd_submit.
> 

I see you sent the same patch twice without indicating that it is a
resend with a change in subject line.

How did you determine this change is necessary?

> Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
> ---
>   drivers/usb/usbip/usbip_common.c | 10 +---------
>   1 file changed, 1 insertion(+), 9 deletions(-)
> 
> diff --git a/drivers/usb/usbip/usbip_common.c b/drivers/usb/usbip/usbip_common.c
> index a2b2da125..74a01a265 100644
> --- a/drivers/usb/usbip/usbip_common.c
> +++ b/drivers/usb/usbip/usbip_common.c
> @@ -568,17 +568,9 @@ static void correct_endian_ret_unlink(struct usbip_header_ret_unlink *pdu,
>   
>   void usbip_header_correct_endian(struct usbip_header *pdu, int send)
>   {
> -	__u32 cmd = 0;
> -
> -	if (send)
> -		cmd = pdu->base.command;
> -
>   	correct_endian_basic(&pdu->base, send);

Did you check what correct_endian_basic() does and why
it is important to check "send" and assign "cmd"

>   
> -	if (!send)
> -		cmd = pdu->base.command;

It is necessary to assign the command after calling
> -
> -	switch (cmd) {
> +	switch (pdu->base.command) {
>   	case USBIP_CMD_SUBMIT:
>   		correct_endian_cmd_submit(&pdu->u.cmd_submit, send);
>   		break;

This patch will introduce an error. NAK on this patch.

thanks,
-- Shuah

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

end of thread, other threads:[~2024-06-28 17:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-28 10:46 [PATCH] usb: usbip: remove unnecessary cmd variable Xiaobo Liu
2024-06-28 17:15 ` Shuah Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox