Skip to contentSkip to conversation

GCC4.6: Convert various empty macros to inline functions

PATCH New Marek Vasut 4 participants 10 messages Sep 23, 2011 – Sep 24, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 GCC4.6: Convert various empty macros to inline functions

Fixes problems similar to the following ones:

cmd_date.c: In function ?do_date?:
cmd_date.c:50:6: warning: variable ?old_bus? set but not used [-Wunused-but-set-variable]

---
 common/usb.c     |    4 ++--
 include/common.h |    4 ++--
 include/i2c.h    |    5 ++++-
 3 files changed, 8 insertions(+), 5 deletions(-)
common/usb.c +2 -2
index a401c09..a5f9e9f 100644
@@ -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
 
 
include/common.h +2 -2
index d244bd4..5c6822a 100644
@@ -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(const char *fmt, ...) {}
 #endif	/* DEBUG */
 
 #ifdef DEBUG
include/i2c.h +4 -1
index 8ceb4c8..323150d 100644
@@ -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 */
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 2/2 GCC4.6: Remove unused "port" variable in cmd_usb.c

---
 common/cmd_usb.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
common/cmd_usb.c +1 -2
index cd4d417..8c87265 100644
@@ -281,7 +281,7 @@ static inline char *portspeed(int speed)
 void usb_show_tree_graph(struct usb_device *dev, char *pre)
 {
 	int i, index;
-	int has_child, last_child, port;
+	int has_child, last_child;
 
 	index = strlen(pre);
 	printf(" %s", pre);
@@ -300,7 +300,6 @@ void usb_show_tree_graph(struct usb_device *dev, char *pre)
 				/* found our pointer, see if we have a
 				 * little sister
 				 */
-				port = i;
 				while (i++ < dev->parent->maxchild) {
 					if (dev->parent->children[i] != NULL) {
 						/* found a sister */
Signature · 1 line
1.7.5.4
#2 lore raw

PATCH 2/2 GCC4.6: Remove unused "port" variable in cmd_usb.c

Hi,

2011/9/23 Marek Vasut <[email protected]>:

Quoted 19 lines

---
?common/cmd_usb.c | ? ?3 +--
?1 files changed, 1 insertions(+), 2 deletions(-)

common/cmd_usb.c +1 -1
index cd4d417..8c87265 100644
@@ -281,7 +281,7 @@ static inline char *portspeed(int speed)
 ?void usb_show_tree_graph(struct usb_device *dev, char *pre)
 ?{
 ? ? ? ?int i, index;
- ? ? ? int has_child, last_child, port;
+ ? ? ? int has_child, last_child;
 
 ? ? ? ?index = strlen(pre);
 ? ? ? ?printf(" %s", pre);
@@ -300,7 +300,6 @@ void usb_show_tree_graph(struct usb_device *dev, char *pre)
Quoted 7 lines

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?/* found our pointer, see if we have a ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? * little sister
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? */
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? port = i;
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?while (i++ < dev->parent->maxchild) { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?if (dev->parent->children[i] != NULL) { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?/* found a sister */

If it was not part of a patch-series, I would have pulled it in directly...

Kind regards,

Remy

#3 lore raw

PATCH 1/2 GCC4.6: Convert various empty macros to inline functions

In reply to Marek Vasut

include/common.h typedef volatile unsigned char vu_char; · line 124

Quoted 5 lines · On Friday, September 23, 2011 15:09:52 Marek Vasut wrote:
include/common.h +1 -1
 
-#define debugX(level,fmt,args...)
+static inline void debugX(const char *fmt, ...) {}

NAK: you broke debugX()

personally i'd prefer we unify these like we did with the assert(), but this change is better than nothing
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110923/ce8ec9bd/attachment.pgp

#4 lore raw

PATCH 1/2 GCC4.6: Convert various empty macros to inline functions

Quoted 8 lines · On Friday, September 23, 2011 15:09:52 Marek Vasut wrote:

include/common.h typedef volatile unsigned char vu_char; · line 124

Quoted 5 lines
include/common.h +1 -1
 
-#define debugX(level,fmt,args...)
+static inline void debugX(const char *fmt, ...) {}

NAK:? you broke debugX()

oh, right, good catch. But is this macro even used anyway?

Quoted 4 lines

personally i'd prefer we unify these like we did with the assert(), but this? change is better than nothing
-mike

#5 lore raw

PATCH 1/2 GCC4.6: Convert various empty macros to inline functions

Quoted 10 lines · On Friday, September 23, 2011 17:52:35 Marek Vasut wrote:
Quoted 8 lines · On Friday, September 23, 2011 15:09:52 Marek Vasut wrote:

include/common.h typedef volatile unsigned char vu_char; · line 124

Quoted 5 lines
include/common.h +1 -1
 
-#define debugX(level,fmt,args...)
+static inline void debugX(const char *fmt, ...) {}

NAK: you broke debugX()

oh, right, good catch. But is this macro even used anyway?

grep says yes, a little
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110923/e5fc465b/attachment.pgp

#6 lore raw

PATCH 1/2 GCC4.6: Convert various empty macros to inline functions

Quoted 10 lines · Mike Frysinger
Quoted 9 lines · On Friday, September 23, 2011 17:52:35 Marek Vasut wrote:
Quoted 8 lines · On Friday, September 23, 2011 15:09:52 Marek Vasut wrote:

include/common.h typedef volatile unsigned char vu_char; · line 124

Quoted 5 lines
include/common.h +1 -1
 
-#define debugX(level,fmt,args...)
+static inline void debugX(const char *fmt, ...) {}

NAK: you broke debugX()

Quoted 4 lines
Quoted 1 line

oh, right, good catch. But is this macro even used anyway?

grep says yes, a little
-mike

Maybe we should just squash it and get rid of it altogether ?

#7 lore raw

PATCH 1/2 GCC4.6: Convert various empty macros to inline functions

Quoted 11 lines · On Friday, September 23, 2011 20:40:25 Marek Vasut wrote:
Quoted 10 lines · Mike Frysinger
Quoted 9 lines · On Friday, September 23, 2011 17:52:35 Marek Vasut wrote:
Quoted 8 lines · On Friday, September 23, 2011 15:09:52 Marek Vasut wrote:

include/common.h typedef volatile unsigned char vu_char; · line 124

Quoted 5 lines
include/common.h +1 -1
 
-#define debugX(level,fmt,args...)
+static inline void debugX(const char *fmt, ...) {}

NAK: you broke debugX()

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

oh, right, good catch. But is this macro even used anyway?

grep says yes, a little

Maybe we should just squash it and get rid of it altogether ?

i've rarely found a need for this sort of style of debug logging, so i wouldn't mind seeing it go
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110924/ed6f5ad5/attachment.pgp

#8 lore raw

PATCH 1/1 GCC4.6: Convert various empty macros to inline functions

In reply to Marek Vasut

Fixes problems similar to the following ones:

cmd_date.c: In function ?do_date?:
cmd_date.c:50:6: warning: variable ?old_bus? set but not used [-Wunused-but-set-variable]

---
 common/usb.c     |    4 ++--
 include/common.h |    4 ++--
 include/i2c.h    |    5 ++++-
 3 files changed, 8 insertions(+), 5 deletions(-)
common/usb.c +2 -2
index a401c09..a5f9e9f 100644
@@ -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
 
 
include/common.h +2 -2
index d244bd4..aeb2d84 100644
@@ -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
include/i2c.h +4 -1
index 8ceb4c8..323150d 100644
@@ -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 */
Signature · 1 line
1.7.5.4
#9 lore raw

PATCH v2 1/2 GCC4.6: Convert various empty macros to inline functions

In reply to Marek Vasut

Fixes problems similar to the following ones:

cmd_date.c: In function ?do_date?:
cmd_date.c:50:6: warning: variable ?old_bus? set but not used [-Wunused-but-set-variable]

---
 common/usb.c     |    4 ++--
 include/common.h |    4 ++--
 include/i2c.h    |    5 ++++-
 3 files changed, 8 insertions(+), 5 deletions(-)

V2: Correct debugX()

common/usb.c +2 -2
index a401c09..a5f9e9f 100644
@@ -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
 
 
include/common.h +2 -2
index d244bd4..aeb2d84 100644
@@ -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
include/i2c.h +4 -1
index 8ceb4c8..323150d 100644
@@ -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 */
Signature · 1 line
1.7.5.4