Patchwork [U-Boot,02/39] GCC4.6: Squash warnings in common/usb.c

login
register
mail settings
Submitter Marek Vasut
Date Oct. 22, 2011, 12:16 a.m.
Message ID <1319242654-15534-3-git-send-email-marek.vasut@gmail.com>
Download mbox | patch
Permalink /patch/121096/
State Accepted
Commit 88ec8c1246bd13a9620a97b0007ca4162fcf5197
Headers show

Comments

Marek Vasut - Oct. 22, 2011, 12:16 a.m.
usb.c: In function ‘usb_parse_config’:
usb.c:331:17: warning: variable ‘ch’ set but not used
[-Wunused-but-set-variable]
usb.c: In function ‘usb_hub_port_connect_change’:
usb.c:1123:29: warning: variable ‘portchange’ set but not used
[-Wunused-but-set-variable]
usb.c: In function ‘usb_hub_configure’:
usb.c:1183:25: warning: variable ‘hubsts’ set but not used
[-Wunused-but-set-variable]

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Mike Frysinger <vapier@gentoo.org>
---
 common/usb.c |   21 +++++++--------------
 1 files changed, 7 insertions(+), 14 deletions(-)
Stefano Babic - Oct. 24, 2011, 12:15 p.m.
On 10/22/2011 02:16 AM, Marek Vasut wrote:
> usb.c: In function ‘usb_parse_config’:
> usb.c:331:17: warning: variable ‘ch’ set but not used
> [-Wunused-but-set-variable]
> usb.c: In function ‘usb_hub_port_connect_change’:
> usb.c:1123:29: warning: variable ‘portchange’ set but not used
> [-Wunused-but-set-variable]
> usb.c: In function ‘usb_hub_configure’:
> usb.c:1183:25: warning: variable ‘hubsts’ set but not used
> [-Wunused-but-set-variable]
> 
> Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Mike Frysinger <vapier@gentoo.org>
> ---
>  common/usb.c |   21 +++++++--------------
>  1 files changed, 7 insertions(+), 14 deletions(-)
> 
> diff --git a/common/usb.c b/common/usb.c
> index 2cd50db..bed5116 100644
> --- a/common/usb.c
> +++ b/common/usb.c
> @@ -56,16 +56,16 @@
>  #endif
>  
>  #ifdef DEBUG
> -#define USB_DEBUG
> -#define USB_HUB_DEBUG
> -#endif
> -
> -#ifdef	USB_DEBUG
> -#define	USB_PRINTF(fmt, args...)	printf(fmt , ##args)
> +#define USB_DEBUG	1
> +#define USB_HUB_DEBUG	1

Why do you nedd to set a value when then later to check only with #ifdef
if it is defined or not ?

>  #else
> -#define USB_PRINTF(fmt, args...)
> +#define USB_DEBUG	0
> +#define USB_HUB_DEBUG	0

Maybe #undef ?

Best regards,
Stefano babic
Marek Vasut - Oct. 24, 2011, 12:22 p.m.
Hi Stefano,

actually the value is checked by debug_cond().

Cheers
Wolfgang Denk - Oct. 24, 2011, 7:37 p.m.
Dear Marek Vasut,

In message <201110241422.30837.marek.vasut@gmail.com> you wrote:
> 
> actually the value is checked by debug_cond().

Consider prefixing these names with a double underscore to make more
visibale that these are internally used and not for plain mortal users
to mess with.

Best regards,

Wolfgang Denk
Marek Vasut - Oct. 25, 2011, 12:09 a.m.
> Dear Marek Vasut,
> 
> In message <201110241422.30837.marek.vasut@gmail.com> you wrote:
> > actually the value is checked by debug_cond().
> 
> Consider prefixing these names with a double underscore to make more
> visibale that these are internally used and not for plain mortal users
> to mess with.
> 
> Best regards,
> 
> Wolfgang Denk

Hi Wolfgang,

will do. Do you plan to start merging this stuff (or parts of it)?

Cheers

Patch

diff --git a/common/usb.c b/common/usb.c
index 2cd50db..bed5116 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -56,16 +56,16 @@ 
 #endif
 
 #ifdef DEBUG
-#define USB_DEBUG
-#define USB_HUB_DEBUG
-#endif
-
-#ifdef	USB_DEBUG
-#define	USB_PRINTF(fmt, args...)	printf(fmt , ##args)
+#define USB_DEBUG	1
+#define USB_HUB_DEBUG	1
 #else
-#define USB_PRINTF(fmt, args...)
+#define USB_DEBUG	0
+#define USB_HUB_DEBUG	0
 #endif
 
+#define USB_PRINTF(fmt, args...)	debug_cond(USB_DEBUG, fmt, ##args)
+#define USB_HUB_PRINTF(fmt, args...)	debug_cond(USB_HUB_DEBUG, fmt, ##args)
+
 #define USB_BUFSIZ	512
 
 static struct usb_device usb_dev[USB_MAX_DEVICE];
@@ -968,13 +968,6 @@  void usb_scan_devices(void)
  * Probes device for being a hub and configurate it
  */
 
-#ifdef	USB_HUB_DEBUG
-#define	USB_HUB_PRINTF(fmt, args...)	printf(fmt , ##args)
-#else
-#define USB_HUB_PRINTF(fmt, args...)
-#endif
-
-
 static struct usb_hub_device hub_dev[USB_MAX_HUB];
 static int usb_hub_index;