diff mbox

[U-Boot,1/7,V3] GCC4.6: Convert various empty macros to inline functions

Message ID 1317058579-936-1-git-send-email-marek.vasut@gmail.com
State Accepted
Headers show

Commit Message

Marek Vasut Sept. 26, 2011, 5:36 p.m. UTC
Fix the following gcc4.6 problems:

cmd_date.c: In function ‘do_date’:
cmd_date.c:50:6: warning: variable ‘old_bus’ set but not used
[-Wunused-but-set-variable]
asix.c: In function ‘asix_init’:
asix.c:317:6: warning: variable ‘rx_ctl’ set but not used
[-Wunused-but-set-variable]
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]
usb_storage.c: In function ‘usb_stor_CB_reset’:
usb_storage.c:466:6: warning: variable ‘result’ set but not used
[-Wunused-but-set-variable]

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
 common/usb.c         |    4 ++--
 common/usb_storage.c |    2 +-
 include/common.h     |    4 ++--
 include/i2c.h        |    5 ++++-
 4 files changed, 9 insertions(+), 6 deletions(-)

V2: Squash warning in usb_storage.c
V3: update diff description

Comments

Wolfgang Denk Oct. 1, 2011, 9:20 p.m. UTC | #1
Dear Marek Vasut,

In message <1317058579-936-1-git-send-email-marek.vasut@gmail.com> you wrote:
> Fix the following gcc4.6 problems:
> 
> cmd_date.c: In function `do_date´:
> cmd_date.c:50:6: warning: variable `old_bus´ set but not used
> [-Wunused-but-set-variable]
> asix.c: In function `asix_init´:
> asix.c:317:6: warning: variable `rx_ctl´ set but not used
> [-Wunused-but-set-variable]
> 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]
> usb_storage.c: In function `usb_stor_CB_reset´:
> usb_storage.c:466:6: warning: variable `result´ set but not used
> [-Wunused-but-set-variable]
> 
> Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> ---
>  common/usb.c         |    4 ++--
>  common/usb_storage.c |    2 +-
>  include/common.h     |    4 ++--
>  include/i2c.h        |    5 ++++-
>  4 files changed, 9 insertions(+), 6 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk
Wolfgang Denk Oct. 2, 2011, 6:36 p.m. UTC | #2
Dear Marik,

In message <1317058579-936-1-git-send-email-marek.vasut@gmail.com> you wrote:
> Fix the following gcc4.6 problems:
>
> cmd_date.c: In function `do_date´:
> cmd_date.c:50:6: warning: variable `old_bus´ set but not used
> [-Wunused-but-set-variable]
> asix.c: In function `asix_init´:
> asix.c:317:6: warning: variable `rx_ctl´ set but not used
> [-Wunused-but-set-variable]
> 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]
> usb_storage.c: In function `usb_stor_CB_reset´:
> usb_storage.c:466:6: warning: variable `result´ set but not used
> [-Wunused-but-set-variable]
>
> Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> ---
>  common/usb.c         |    4 ++--
>  common/usb_storage.c |    2 +-
>  include/common.h     |    4 ++--
>  include/i2c.h        |    5 ++++-
>  4 files changed, 9 insertions(+), 6 deletions(-)

Unforstunately this patch breaks a number of boards.

Did you by chance forget to run MAKEALL on it?  :-(

Example:

./MAKEALL TQM823L
Configuring for TQM823L board...
tqm8xx_pcmcia.c: In function 'pcmcia_voltage_set':
tqm8xx_pcmcia.c:265: error: 'pcmp' undeclared (first use in this function)
tqm8xx_pcmcia.c:265: error: (Each undeclared identifier is reported only once
tqm8xx_pcmcia.c:265: error: for each function it appears in.)
make[1]: *** [/work/wd/tmp-ppc/drivers/pcmcia/tqm8xx_pcmcia.o] Error 1
make: *** [/work/wd/tmp-ppc/drivers/pcmcia/libpcmcia.o] Error 2
make: *** Waiting for unfinished jobs....
ppc_6xx-size: '/work/wd/tmp-ppc/u-boot': No such file

...
60ce53cf9f408d9ad721f8e7a87d6a564e6d5bac is the first bad commit
commit 60ce53cf9f408d9ad721f8e7a87d6a564e6d5bac
Author: Marek Vasut <marek.vasut@gmail.com>
Date:   Mon Sep 26 19:36:19 2011 +0200

    GCC4.6: Convert various empty macros to inline functions


Please fix.

Thanks.

Best regards,

Wolfgang Denk
Marek Vasut Oct. 2, 2011, 7:08 p.m. UTC | #3
On Sunday, October 02, 2011 08:36:04 PM Wolfgang Denk wrote:
> Dear Marek,
> 
[...]

> 
> Please fix.

Hi Wolfgang,

I have to admit I didn't test ppc boards. But by looking at the TQM pcmcia 
driver, the problem is in the driver itself. That's where I suspect it should be 
fixed.

Can you share the list of broken boards you detected please ?

Thanks!

Cheers
Marek Vasut Oct. 2, 2011, 10:50 p.m. UTC | #4
On Sunday, October 02, 2011 09:08:52 PM Marek Vasut wrote:
> On Sunday, October 02, 2011 08:36:04 PM Wolfgang Denk wrote:
> > Dear Marek,
> 
> [...]
> 
> > Please fix.
> 
> Hi Wolfgang,
> 
> I have to admit I didn't test ppc boards. But by looking at the TQM pcmcia
> driver, the problem is in the driver itself. That's where I suspect it
> should be fixed.
> 
> Can you share the list of broken boards you detected please ?

Hi,

I'm running the compile tests for powerpc arch right now and I noticed many 
problems of this form:

Configuring for PCIPPC2 board...
interrupts.c: In function 'interrupt_init_cpu':
interrupts.c:38: warning: implicit declaration of function 'GTREGREAD'
interrupts.c:38: error: 'LOW_INTERRUPT_CAUSE_REGISTER' undeclared (first use in 
this function)
interrupts.c:38: error: (Each undeclared identifier is reported only once
interrupts.c:38: error: for each function it appears in.)
interrupts.c:39: error: 'HIGH_INTERRUPT_CAUSE_REGISTER' undeclared (first use in 
this function)
interrupts.c:41: error: 'ETHERNET0_INTERRUPT_CAUSE_REGISTER' undeclared (first 
use in this function)
interrupts.c:42: error: 'ETHERNET1_INTERRUPT_CAUSE_REGISTER' undeclared (first 
use in this function)
interrupts.c:43: error: 'ETHERNET2_INTERRUPT_CAUSE_REGISTER' undeclared (first 
use in this function)
interrupts.c:45: error: 'ETHERNET0_INTERRUPT_MASK_REGISTER' undeclared (first 
use in this function)
interrupts.c:46: error: 'ETHERNET1_INTERRUPT_MASK_REGISTER' undeclared (first 
use in this function)
interrupts.c:47: error: 'ETHERNET2_INTERRUPT_MASK_REGISTER' undeclared (first 
use in this function)
make[1]: *** [interrupts.o] Error 1
make: *** [arch/powerpc/cpu/74xx_7xx/lib74xx_7xx.o] Error 2
make: *** Waiting for unfinished jobs....
powerpc-linux-size: './u-boot': No such file

This seems like noone actually tested compiling those boards with DEBUG enabled 
... ever. Anyway, there seems to be an easy fix, add the following into the 
config file:

#ifndef __ASSEMBLY__
#include <galileo/core.h>
#endif

There is a catch I don't quite understand though, that is, some boards include 
board/Marvell/include/mv_gen_reg.h instead. Which should be included in those 
config files? Is there some way to tell please?

=========================================

As for the tqm-pcmcia problem, removing the #ifdef DEBUG fixed the problem with 
no growth in the u-boot.bin size. Though u-boot (elf binary) grew a bit (tested 
with ELDK4.2, gcc 4.2.2):

With no gcc4.6 patches and unfixed:

Configuring for TQM823L board...
   text    data     bss     dec     hex filename
 260523   13960   25704  300187   4949b ./u-boot

--------------------- SUMMARY ----------------------------
Boards compiled: 1
----------------------------------------------------------
[u-boot]$ ls -la u-boot.bin 
-rwxrwxr-x 1 user user 274568 Oct  3 00:10 u-boot.bin


With gcc4.6 patches and removed #ifdef DEBUG:

Configuring for TQM823L board...
   text    data     bss     dec     hex filename
 260547   13960   25704  300211   494b3 ./u-boot

--------------------- SUMMARY ----------------------------
Boards compiled: 1
----------------------------------------------------------
[u-boot]$ ls -la u-boot.bin 
-rwxrwxr-x 1 user user 274568 Oct  3 00:11 u-boot.bin

Cheers
diff mbox

Patch

diff --git a/common/usb.c b/common/usb.c
index a401c09..a5f9e9f 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -63,7 +63,7 @@ 
 #ifdef	USB_DEBUG
 #define	USB_PRINTF(fmt, args...)	printf(fmt , ##args)
 #else
-#define USB_PRINTF(fmt, args...)
+static inline void USB_PRINTF(const char *fmt, ...) {}
 #endif
 
 #define USB_BUFSIZ	512
@@ -970,7 +970,7 @@  void usb_scan_devices(void)
 #ifdef	USB_HUB_DEBUG
 #define	USB_HUB_PRINTF(fmt, args...)	printf(fmt , ##args)
 #else
-#define USB_HUB_PRINTF(fmt, args...)
+static inline void USB_HUB_PRINTF(const char *fmt, ...) {}
 #endif
 
 
diff --git a/common/usb_storage.c b/common/usb_storage.c
index 16667f3..5c56918 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -63,7 +63,7 @@ 
 #ifdef	USB_STOR_DEBUG
 #define USB_STOR_PRINTF(fmt, args...)	printf(fmt , ##args)
 #else
-#define USB_STOR_PRINTF(fmt, args...)
+static inline void USB_STOR_PRINTF(const char *fmt, ...) {}
 #endif
 
 #include <scsi.h>
diff --git a/include/common.h b/include/common.h
index d244bd4..aeb2d84 100644
--- a/include/common.h
+++ b/include/common.h
@@ -120,8 +120,8 @@  typedef volatile unsigned char	vu_char;
 #define debug(fmt,args...)	printf (fmt ,##args)
 #define debugX(level,fmt,args...) if (DEBUG>=level) printf(fmt,##args);
 #else
-#define debug(fmt,args...)
-#define debugX(level,fmt,args...)
+static inline void debug(const char *fmt, ...) {}
+static inline void debugX(int level, const char *fmt, ...) {}
 #endif	/* DEBUG */
 
 #ifdef DEBUG
diff --git a/include/i2c.h b/include/i2c.h
index 8ceb4c8..323150d 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -55,7 +55,10 @@ 
 #else
 #define CONFIG_SYS_MAX_I2C_BUS		1
 #define I2C_GET_BUS()		0
-#define I2C_SET_BUS(a)
+static inline int I2C_SET_BUS(unsigned int bus)
+{
+	return 0;
+}
 #endif
 
 /* define the I2C bus number for RTC and DTT if not already done */