From afbd9e4968473d8e5454a9f123d2b7a987905da3 Mon Sep 17 00:00:00 2001
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date: Fri, 17 Mar 2017 15:56:11 +0100
Subject: [PATCH] Add do/while to fix usage in if blocks

---
 control/descriptor.h | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/control/descriptor.h b/control/descriptor.h
index a70f19221..e60b3909f 100644
--- a/control/descriptor.h
+++ b/control/descriptor.h
@@ -208,21 +208,25 @@ inline static int morse_desc_islocal( const MORSE_desc_t *A, int m, int n )
     unsigned __morse_need_submit = 0; \
     RUNTIME_BEGIN_ACCESS_DECLARATION
 
-#define MORSE_ACCESS_R(A, Am, An) \
+#define MORSE_ACCESS_R(A, Am, An) do { \
     if (morse_desc_islocal(A, Am, An)) __morse_need_submit = 1; \
-    RUNTIME_ACCESS_R(A, Am, An)
+    RUNTIME_ACCESS_R(A, Am, An) \
+} while(0)
 
-#define MORSE_ACCESS_W(A, Am, An) \
+#define MORSE_ACCESS_W(A, Am, An) do { \
     if (morse_desc_islocal(A, Am, An)) __morse_need_submit = 1; \
-    RUNTIME_ACCESS_W(A, Am, An)
+    RUNTIME_ACCESS_W(A, Am, An) \
+} while(0)
 
-#define MORSE_ACCESS_RW(A, Am, An) \
+#define MORSE_ACCESS_RW(A, Am, An) do { \
     if (morse_desc_islocal(A, Am, An)) __morse_need_submit = 1; \
-    RUNTIME_ACCESS_RW(A, Am, An)
+    RUNTIME_ACCESS_RW(A, Am, An) \
+} while(0)
 
-#define MORSE_RANK_CHANGED(rank) \
+#define MORSE_RANK_CHANGED(rank) do {\
     __morse_need_submit = 1; \
-    RUNTIME_RANK_CHANGED(rank)
+    RUNTIME_RANK_CHANGED(rank) \
+} while (0)
 
 #define MORSE_END_ACCESS_DECLARATION \
     RUNTIME_END_ACCESS_DECLARATION \
-- 
GitLab