Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1523601 > unrolled thread

[PATCH] usb: dwc3: avoid empty-body warning

Started byArnd Bergmann <arnd@arndb.de>
First post2016-11-16 16:40 +0100
Last post2016-11-17 19:10 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] usb: dwc3: avoid empty-body warning Arnd Bergmann <arnd@arndb.de> - 2016-11-16 16:40 +0100
    Re: [PATCH] usb: dwc3: avoid empty-body warning Felipe Balbi <balbi@kernel.org> - 2016-11-17 12:30 +0100
      Re: [PATCH] usb: dwc3: avoid empty-body warning Arnd Bergmann <arnd@arndb.de> - 2016-11-17 19:10 +0100

#1523601 — [PATCH] usb: dwc3: avoid empty-body warning

FromArnd Bergmann <arnd@arndb.de>
Date2016-11-16 16:40 +0100
Subject[PATCH] usb: dwc3: avoid empty-body warning
Message-ID<sEatz-4HA-3@gated-at.bofh.it>
Building with W=1, we get a warning about harmless empty statements:

drivers/usb/dwc3/ep0.c: In function 'dwc3_ep0_handle_intf':
drivers/usb/dwc3/ep0.c:491:4: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]

gcc does not warn about {} here, so maybe use that instead.
Alternatively, the code could be removed entirely as it does
nothing.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
This has been present in the driver for a while, but the code
just moved around, so it showed up as a new warning for me.
I hope to eventually address all W=1 warnings as they tend to
find real bugs elsewhere and we may as well fix it now that the
code has changed.
---
 drivers/usb/dwc3/ep0.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 2b22ea7263d8..1e93cfc8f88b 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -486,12 +486,12 @@ static int dwc3_ep0_handle_intf(struct dwc3 *dwc,
 
 	switch (wValue) {
 	case USB_INTRF_FUNC_SUSPEND:
-		if (wIndex & USB_INTRF_FUNC_SUSPEND_LP)
+		if (wIndex & USB_INTRF_FUNC_SUSPEND_LP) {
 			/* XXX enable Low power suspend */
-			;
-		if (wIndex & USB_INTRF_FUNC_SUSPEND_RW)
+		}
+		if (wIndex & USB_INTRF_FUNC_SUSPEND_RW) {
 			/* XXX enable remote wakeup */
-			;
+		}
 		break;
 	default:
 		ret = -EINVAL;
-- 
2.9.0

[toc] | [next] | [standalone]


#1524397

FromFelipe Balbi <balbi@kernel.org>
Date2016-11-17 12:30 +0100
Message-ID<sEt3c-8sS-15@gated-at.bofh.it>
In reply to#1523601

[Multipart message — attachments visible in raw view] — view raw

Hi,

Arnd Bergmann <arnd@arndb.de> writes:
> Building with W=1, we get a warning about harmless empty statements:
>
> drivers/usb/dwc3/ep0.c: In function 'dwc3_ep0_handle_intf':
> drivers/usb/dwc3/ep0.c:491:4: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
>
> gcc does not warn about {} here, so maybe use that instead.
> Alternatively, the code could be removed entirely as it does
> nothing.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> This has been present in the driver for a while, but the code
> just moved around, so it showed up as a new warning for me.
> I hope to eventually address all W=1 warnings as they tend to
> find real bugs elsewhere and we may as well fix it now that the
> code has changed.

Thank you, the only problem is that now checkpatch.pl warns. I'll just
remove the code and turn it into a comment. Authorship kept, let me know
if you're okay with me adding your S-o-b:

8<------------------------------------------------------------------------

From ea97b854e5c4437975c5d0e887488390410cfb30 Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <arnd@arndb.de>
Date: Wed, 16 Nov 2016 16:37:30 +0100
Subject: [PATCH] usb: dwc3: ep0: avoid empty-body warning

Building with W=1, we get a warning about harmless empty statements:

drivers/usb/dwc3/ep0.c: In function 'dwc3_ep0_handle_intf':
drivers/usb/dwc3/ep0.c:491:4: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]

Instead of adding empty braces which would introduce checkpatch.pl
warnings, we're just removing the code which doesn't do anything and
making sure we return 0 so USBCV tool is happy.

NYET-Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
---
 drivers/usb/dwc3/ep0.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 2b22ea7263d8..4c0664640862 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -486,12 +486,13 @@ static int dwc3_ep0_handle_intf(struct dwc3 *dwc,
 
 	switch (wValue) {
 	case USB_INTRF_FUNC_SUSPEND:
-		if (wIndex & USB_INTRF_FUNC_SUSPEND_LP)
-			/* XXX enable Low power suspend */
-			;
-		if (wIndex & USB_INTRF_FUNC_SUSPEND_RW)
-			/* XXX enable remote wakeup */
-			;
+		/*
+		 * REVISIT: Ideally we would enable some low power mode here,
+		 * however it's unclear what we should be doing here.
+		 *
+		 * For now, we're not doing anything, just making sure we return
+		 * 0 so USB Command Verifier tests pass without any errors.
+		 */
 		break;
 	default:
 		ret = -EINVAL;
-- 
2.10.1



-- 
balbi

[toc] | [prev] | [next] | [standalone]


#1524629

FromArnd Bergmann <arnd@arndb.de>
Date2016-11-17 19:10 +0100
Message-ID<sEzii-48J-23@gated-at.bofh.it>
In reply to#1524397
On Thursday, November 17, 2016 1:23:43 PM CET Felipe Balbi wrote:
> Arnd Bergmann <arnd@arndb.de> writes:
> > Building with W=1, we get a warning about harmless empty statements:
> >
> > drivers/usb/dwc3/ep0.c: In function 'dwc3_ep0_handle_intf':
> > drivers/usb/dwc3/ep0.c:491:4: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
> >
> > gcc does not warn about {} here, so maybe use that instead.
> > Alternatively, the code could be removed entirely as it does
> > nothing.
> >
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > ---
> > This has been present in the driver for a while, but the code
> > just moved around, so it showed up as a new warning for me.
> > I hope to eventually address all W=1 warnings as they tend to
> > find real bugs elsewhere and we may as well fix it now that the
> > code has changed.
> 
> Thank you, the only problem is that now checkpatch.pl warns. I'll just
> remove the code and turn it into a comment. Authorship kept, let me know
> if you're okay with me adding your S-o-b:

Ah, good point. The same problem exists in other places too,
I have to remember this when sending patches. Maybe I can
add something like

#define do_nothing() do {} while (0) 

> 8<------------------------------------------------------------------------
> 
> From ea97b854e5c4437975c5d0e887488390410cfb30 Mon Sep 17 00:00:00 2001
> From: Arnd Bergmann <arnd@arndb.de>
> Date: Wed, 16 Nov 2016 16:37:30 +0100
> Subject: [PATCH] usb: dwc3: ep0: avoid empty-body warning
> 
> Building with W=1, we get a warning about harmless empty statements:
> 
> drivers/usb/dwc3/ep0.c: In function 'dwc3_ep0_handle_intf':
> drivers/usb/dwc3/ep0.c:491:4: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
> 
> Instead of adding empty braces which would introduce checkpatch.pl
> warnings, we're just removing the code which doesn't do anything and
> making sure we return 0 so USBCV tool is happy.
> 
> NYET-Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>

Looks good to me.

	Arnd

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web