lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <3ccc1177-9e4c-130b-ab9a-f02169164ac4@synopsys.com>
Date:   Tue, 9 Jun 2020 08:35:50 +0000
From:   Minas Harutyunyan <Minas.Harutyunyan@...opsys.com>
To:     Pavel Machek <pavel@...x.de>,
        Minas Harutyunyan <Minas.Harutyunyan@...opsys.com>
CC:     "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
        "linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
        kernel list <linux-kernel@...r.kernel.org>,
        "trivial@...nel.org" <trivial@...nel.org>
Subject: Re: [PATCH] sr: dwc2/gadget: remove unneccessary if

Hi,

On 6/6/2020 11:05 PM, Pavel Machek wrote:
> Hi!
> 
>>> We don't really need if/else to set variable to 1/0.
>>>
>>> Signed-off-by: Pavel Machek (CIP) <pavel@...x.de>
>>>
>>> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
>>> index 12b98b466287..f9f6fd470c81 100644
>>> --- a/drivers/usb/dwc2/gadget.c
>>> +++ b/drivers/usb/dwc2/gadget.c
>>> @@ -1761,10 +1761,7 @@ static int dwc2_hsotg_process_req_feature(struct dwc2_hsotg *hsotg,
>>>    	case USB_RECIP_DEVICE:
>>>    		switch (wValue) {
>>>    		case USB_DEVICE_REMOTE_WAKEUP:
>>> -			if (set)
>>> -				hsotg->remote_wakeup_allowed = 1;
>>> -			else
>>> -				hsotg->remote_wakeup_allowed = 0;
>>> +			hsotg->remote_wakeup_allowed = set;
>>>    			break;
>>>    
>>>    		case USB_DEVICE_TEST_MODE:
>>>
>>
>> It's good catch, but 'set' declared as 'bool' while
>> 'remote_wakeup_allowed' is 'unsigned int'. Maybe update 'set' type to same.
> 
> I know set is bool. But that should not matter, code is okay and
> compiler will do the right thing:
> 
> pavel@amd:/tmp$ cat delme.c
> #include <stdbool.h>
> 
> void main(void)
> {
>    bool a = false;
>      int b = a;
>   }
>   pavel@amd:/tmp$ gcc -std=c99 -Wall delme.c
>      delme.c:3:6: warning: return type of ‘main’ is not ‘int’ [-Wmain]
>       void main(void)
>             ^
> 	   delme.c: In function ‘main’:
>   delme.c:6:7: warning: unused variable ‘b’
>   [-Wunused-variable]
> 	      int b = a;
> 	             ^
> 
> Best regards,
> 								Pavel
> 

To avoid any possible check patch issues update type of "set" from bool 
to same as "remote_wakeup_allowed".
Please update your patch topic to "usb: dwc2: gadget: remove unnecessary 
if" and resubmit.

Thanks,
Minas

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ