mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] fix brown paper bag bug introduced with compile time loglevel
@ 2013-02-15 15:30 Sascha Hauer
  2013-02-15 15:39 ` [PATCH v2] " Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Sascha Hauer @ 2013-02-15 15:30 UTC (permalink / raw)
  To: barebox

__dev_printf is a define which uses a local variable 'ret'. This
means that whenever someone does a dev_*(dev, "ret: %d\n", ret);
ret will be 0.

Fix this by removing the variable. The return value of dev_* is
never checked anyway.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---

I'm glad it was myself who stumbled upon this...

 include/printk.h |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/include/printk.h b/include/printk.h
index 1d45616..3f8f786 100644
--- a/include/printk.h
+++ b/include/printk.h
@@ -23,10 +23,8 @@ int dev_printf(const struct device_d *dev, const char *format, ...)
 
 #define __dev_printf(level, dev, format, args...) \
 	({	\
-		int ret = 0; \
 		if (level <= LOGLEVEL) \
-			ret = dev_printf(dev, format, ##args);	\
-		ret;						\
+			dev_printf(dev, format, ##args);	\
 	 })
 
 
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH v2] fix brown paper bag bug introduced with compile time loglevel
  2013-02-15 15:30 [PATCH] fix brown paper bag bug introduced with compile time loglevel Sascha Hauer
@ 2013-02-15 15:39 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2013-02-15 15:39 UTC (permalink / raw)
  To: barebox

__dev_printf is a define which uses a local variable 'ret'. This
means that whenever someone does a dev_*(dev, "ret: %d\n", ret);
ret will be 0.

Fix this by writing this without a local variable.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 include/printk.h |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/include/printk.h b/include/printk.h
index 1d45616..3de8905 100644
--- a/include/printk.h
+++ b/include/printk.h
@@ -23,10 +23,7 @@ int dev_printf(const struct device_d *dev, const char *format, ...)
 
 #define __dev_printf(level, dev, format, args...) \
 	({	\
-		int ret = 0; \
-		if (level <= LOGLEVEL) \
-			ret = dev_printf(dev, format, ##args);	\
-		ret;						\
+		(level) <= LOGLEVEL ? dev_printf((dev), (format), ##args) : 0; \
 	 })
 
 
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-02-15 15:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-15 15:30 [PATCH] fix brown paper bag bug introduced with compile time loglevel Sascha Hauer
2013-02-15 15:39 ` [PATCH v2] " Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox