All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@denx.de>
To: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>
Cc: Pavel Machek <pavel@denx.de>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	kernel list <linux-kernel@vger.kernel.org>,
	"trivial@kernel.org" <trivial@kernel.org>
Subject: Re: [PATCH] sr: dwc2/gadget: remove unneccessary if
Date: Sat, 6 Jun 2020 21:05:07 +0200	[thread overview]
Message-ID: <20200606190507.GA13421@amd> (raw)
In-Reply-To: <4057a9d1-2cf4-78a1-9f29-587a87b523b4@synopsys.com>

[-- Attachment #1: Type: text/plain, Size: 1588 bytes --]

Hi!

> > We don't really need if/else to set variable to 1/0.
> > 
> > Signed-off-by: Pavel Machek (CIP) <pavel@denx.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
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  reply	other threads:[~2020-06-06 19:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-06 15:37 [PATCH] sr: dwc2/gadget: remove unneccessary if Pavel Machek
2020-06-06 15:45 ` Minas Harutyunyan
2020-06-06 19:05   ` Pavel Machek [this message]
2020-06-09  8:35     ` Minas Harutyunyan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200606190507.GA13421@amd \
    --to=pavel@denx.de \
    --cc=Minas.Harutyunyan@synopsys.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=trivial@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.