public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] DSPBRIDGE: Fix macros that break when inside an if/else
@ 2009-07-07 15:02 Ameya Palande
  2009-07-07 15:02 ` [PATCHv2 2/4] DSPBRIDGE: Heuristic fixes of strlen/malloc out by one Ameya Palande
  2009-07-09 23:51 ` [PATCH 1/4] DSPBRIDGE: Fix macros that break when inside an if/else Guzman Lugo, Fernando
  0 siblings, 2 replies; 18+ messages in thread
From: Ameya Palande @ 2009-07-07 15:02 UTC (permalink / raw)
  To: linux-omap; +Cc: x0095840, h-kanigeri2, ext-phil.2.carmody

From: Phil Carmody <ext-phil.2.carmody@nokia.com>

cp_{to,fm}_usr break if between an if and an else (with no {}).

http://www.faqs.org/faqs/C-faq/abridged/
10.4: What's the best way to write a multi-statement macro?
A:    #define Func() do {stmt1; stmt2; ... } while(0) /* (no trailing ;) */

Signed-off-by: Phil Carmody <ext-phil.2.carmody@nokia.com>
---
 drivers/dsp/bridge/pmgr/wcd.c |   42 ++++++++++++++++++++++------------------
 1 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/drivers/dsp/bridge/pmgr/wcd.c b/drivers/dsp/bridge/pmgr/wcd.c
index 86812c6..aaf3019 100644
--- a/drivers/dsp/bridge/pmgr/wcd.c
+++ b/drivers/dsp/bridge/pmgr/wcd.c
@@ -147,25 +147,29 @@
 
 /* Following two macros should ideally have do{}while(0) */
 
-#define cp_fm_usr(dest, src, status, elements)    \
-    if (DSP_SUCCEEDED(status)) {\
-	    if (unlikely(src == NULL) ||				\
-		unlikely(copy_from_user(dest, src, elements * sizeof(*(dest))))) { \
-		GT_1trace(WCD_debugMask, GT_7CLASS, \
-		"copy_from_user failed, src=0x%x\n", src);  \
-		status = DSP_EPOINTER ; \
-	} \
-    }
-
-#define cp_to_usr(dest, src, status, elements)    \
-    if (DSP_SUCCEEDED(status)) {\
-	    if (unlikely(dest == NULL) ||				\
-		unlikely(copy_to_user(dest, src, elements * sizeof(*(src))))) { \
-		GT_1trace(WCD_debugMask, GT_7CLASS, \
-		"copy_to_user failed, dest=0x%x\n", dest); \
-		status = DSP_EPOINTER ;\
-	} \
-    }
+#define cp_fm_usr(dest, src, status, elements)	\
+    do {						\
+	if (DSP_SUCCEEDED(status)) {			\
+	    if (unlikely((src) == NULL) ||		\
+		unlikely(copy_from_user(dest, src, (elements) * sizeof(*(dest))))) { \
+		GT_1trace(WCD_debugMask, GT_7CLASS,	\
+			  "copy_from_user failed, src=0x%x\n", src);	\
+		(status) = DSP_EPOINTER ;				\
+	    }						\
+	}						\
+    } while (0)
+
+#define cp_to_usr(dest, src, status, elements) \
+    do {						\
+	if (DSP_SUCCEEDED(status)) {			\
+	    if (unlikely((dest) == NULL) ||				\
+		unlikely(copy_to_user(dest, src, (elements) * sizeof(*(src))))) { \
+		GT_1trace(WCD_debugMask, GT_7CLASS,	\
+			  "copy_to_user failed, dest=0x%x\n", dest);	\
+		(status) = DSP_EPOINTER ;		\
+	    }						\
+	}						\
+    } while (0)
 
 /* Device IOCtl function pointer */
 struct WCD_Cmd {
-- 
1.6.2.4


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

end of thread, other threads:[~2009-07-14 20:23 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-07 15:02 [PATCH 1/4] DSPBRIDGE: Fix macros that break when inside an if/else Ameya Palande
2009-07-07 15:02 ` [PATCHv2 2/4] DSPBRIDGE: Heuristic fixes of strlen/malloc out by one Ameya Palande
2009-07-07 15:02   ` [PATCHv2 3/4] DSPBRIDGE: PROCWRAP_Load function cleanup in a complete mess Ameya Palande
2009-07-07 15:02     ` [PATCH 4/4] DSPBRIDGE: Remove unnecessary conditions from some for loops Ameya Palande
2009-07-09 23:53       ` Guzman Lugo, Fernando
2009-07-09 23:58     ` [PATCHv2 3/4] DSPBRIDGE: PROCWRAP_Load function cleanup in a complete mess Guzman Lugo, Fernando
2009-07-13 12:35       ` [PATCHv3 " Ameya Palande
2009-07-09 23:52   ` [PATCHv2 2/4] DSPBRIDGE: Heuristic fixes of strlen/malloc out by one Guzman Lugo, Fernando
2009-07-09 23:51 ` [PATCH 1/4] DSPBRIDGE: Fix macros that break when inside an if/else Guzman Lugo, Fernando
2009-07-13 12:38   ` [PATCHv2 " Ameya Palande
2009-07-13 12:42     ` Ameya Palande
2009-07-14 11:02   ` [PATCH " Phil Carmody
2009-07-14 11:05     ` Menon, Nishanth
2009-07-14 11:17       ` Ameya Palande
2009-07-14 11:20       ` Phil Carmody
2009-07-14 12:30         ` Hiroshi DOYU
2009-07-14 13:17           ` Phil Carmody
2009-07-14 20:22             ` Hiroshi DOYU

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