This fixes all appearances of the warning but one, as that one seems to be intentional:

WARNING: Single statement macros should not use a do {} while (0) loop
#1221: FILE: lustre/include/lustre_dlm.h:1221:
+#define LDLM_LOCK_RELEASE(lock)                 \
+do {                                       \
+       /*LDLM_DEBUG((lock), "put");*/          \
+       ldlm_lock_put(lock);                \
+} while (0)

I didn't know if I should touch this debug statement, and if uncommented it would certainly be incorrect to erase the do-while construct.

Regards,
Mario.
>From 01a11dfacba84065a69deed929acaa84d249b7b5 Mon Sep 17 00:00:00 2001
From: "Mario J. Rugiero" <mrugi...@tecnoaccion.com.ar>
Date: Wed, 18 Feb 2015 17:23:39 -0300
Subject: [PATCH] Lustre: single statement macros should not use a do {} while
 (0) loop.

Signed-off-by: Mario J. Rugiero <mrugi...@tecnoaccion.com.ar>
---
 .../lustre/include/linux/libcfs/libcfs_private.h   | 36 ++++++----------------
 .../lustre/include/linux/libcfs/linux/linux-mem.h  |  4 +--
 drivers/staging/lustre/lustre/include/lu_object.h  |  4 +--
 .../lustre/lustre/include/lustre/lustre_idl.h      |  4 +--
 .../staging/lustre/lustre/include/lustre_capa.h    |  4 +--
 drivers/staging/lustre/lustre/include/lustre_dlm.h | 10 +++---
 .../staging/lustre/lustre/include/lustre_export.h  |  4 +--
 drivers/staging/lustre/lustre/include/obd_class.h  |  8 ++---
 8 files changed, 22 insertions(+), 52 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
index 3d86fb5..ac9238a 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
@@ -97,14 +97,10 @@ extern atomic_t libcfs_kmemory;
  */
 
 # define libcfs_kmem_inc(ptr, size)		\
-do {						\
-	atomic_add(size, &libcfs_kmemory);	\
-} while (0)
+	atomic_add(size, &libcfs_kmemory)
 
 # define libcfs_kmem_dec(ptr, size)		\
-do {						\
-	atomic_sub(size, &libcfs_kmemory);	\
-} while (0)
+	atomic_sub(size, &libcfs_kmemory)
 
 # define libcfs_kmem_read()			\
 	atomic_read(&libcfs_kmemory)
@@ -114,11 +110,9 @@ do {						\
 #endif
 
 #define LIBCFS_ALLOC_PRE(size, mask)					    \
-do {									    \
 	LASSERT(!in_interrupt() ||					    \
 		((size) <= LIBCFS_VMALLOC_SIZE &&			    \
-		 ((mask) & __GFP_WAIT) == 0));				    \
-} while (0)
+		 ((mask) & __GFP_WAIT) == 0))
 
 #define LIBCFS_ALLOC_POST(ptr, size)					    \
 do {									    \
@@ -249,45 +243,33 @@ void  cfs_array_free(void *vars);
 
 /** assert value of @a is equal to @v */
 #define LASSERT_ATOMIC_EQ(a, v)				 \
-do {							    \
 	LASSERTF(atomic_read(a) == v,		       \
-		 "value: %d\n", atomic_read((a)));	  \
-} while (0)
+		 "value: %d\n", atomic_read((a)))
 
 /** assert value of @a is unequal to @v */
 #define LASSERT_ATOMIC_NE(a, v)				 \
-do {							    \
 	LASSERTF(atomic_read(a) != v,		       \
-		 "value: %d\n", atomic_read((a)));	  \
-} while (0)
+		 "value: %d\n", atomic_read((a)))
 
 /** assert value of @a is little than @v */
 #define LASSERT_ATOMIC_LT(a, v)				 \
-do {							    \
 	LASSERTF(atomic_read(a) < v,			\
-		 "value: %d\n", atomic_read((a)));	  \
-} while (0)
+		 "value: %d\n", atomic_read((a)))
 
 /** assert value of @a is little/equal to @v */
 #define LASSERT_ATOMIC_LE(a, v)				 \
-do {							    \
 	LASSERTF(atomic_read(a) <= v,		       \
-		 "value: %d\n", atomic_read((a)));	  \
-} while (0)
+		 "value: %d\n", atomic_read((a)))
 
 /** assert value of @a is great than @v */
 #define LASSERT_ATOMIC_GT(a, v)				 \
-do {							    \
 	LASSERTF(atomic_read(a) > v,			\
-		 "value: %d\n", atomic_read((a)));	  \
-} while (0)
+		 "value: %d\n", atomic_read((a)))
 
 /** assert value of @a is great/equal to @v */
 #define LASSERT_ATOMIC_GE(a, v)				 \
-do {							    \
 	LASSERTF(atomic_read(a) >= v,		       \
-		 "value: %d\n", atomic_read((a)));	  \
-} while (0)
+		 "value: %d\n", atomic_read((a)))
 
 /** assert value of @a is great than @v1 and little than @v2 */
 #define LASSERT_ATOMIC_GT_LT(a, v1, v2)			 \
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h
index 0f2fd79..be9006c 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h
@@ -61,8 +61,8 @@
 #define page_index(p)       ((p)->index)
 
 #define memory_pressure_get() (current->flags & PF_MEMALLOC)
-#define memory_pressure_set() do { current->flags |= PF_MEMALLOC; } while (0)
-#define memory_pressure_clr() do { current->flags &= ~PF_MEMALLOC; } while (0)
+#define memory_pressure_set() (current->flags |= PF_MEMALLOC)
+#define memory_pressure_clr() (current->flags &= ~PF_MEMALLOC)
 
 #if BITS_PER_LONG == 32
 /* limit to lowmem on 32-bit systems */
diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h
index 2ddb2b0..fc3f234 100644
--- a/drivers/staging/lustre/lustre/include/lu_object.h
+++ b/drivers/staging/lustre/lustre/include/lu_object.h
@@ -1157,9 +1157,7 @@ struct lu_context_key {
 	}
 
 #define LU_CONTEXT_KEY_INIT(key)			\
-do {						    \
-	(key)->lct_owner = THIS_MODULE;		 \
-} while (0)
+	(key)->lct_owner = THIS_MODULE
 
 int   lu_context_key_register(struct lu_context_key *key);
 void  lu_context_key_degister(struct lu_context_key *key);
diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
index 305ecbe..5382bf4 100644
--- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
+++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
@@ -1777,7 +1777,7 @@ struct obd_ioobj {
 #define IOOBJ_TYPE_MASK		((1U << IOOBJ_MAX_BRW_BITS) - 1)
 #define ioobj_max_brw_get(ioo)	(((ioo)->ioo_max_brw >> IOOBJ_MAX_BRW_BITS) + 1)
 #define ioobj_max_brw_set(ioo, num)					\
-do { (ioo)->ioo_max_brw = ((num) - 1) << IOOBJ_MAX_BRW_BITS; } while (0)
+((ioo)->ioo_max_brw = ((num) - 1) << IOOBJ_MAX_BRW_BITS)
 
 extern void lustre_swab_obd_ioobj (struct obd_ioobj *ioo);
 
@@ -1799,7 +1799,7 @@ extern void lustre_swab_niobuf_remote (struct niobuf_remote *nbr);
 #define OST_LVB_IS_ERR(blocks)					  \
 	((blocks & OST_LVB_ERR_MASK) == OST_LVB_ERR_MASK)
 #define OST_LVB_SET_ERR(blocks, rc)				     \
-	do { blocks = OST_LVB_ERR_INIT + rc; } while (0)
+	(blocks = OST_LVB_ERR_INIT + rc)
 #define OST_LVB_GET_ERR(blocks)    (int)(blocks - OST_LVB_ERR_INIT)
 
 struct ost_lvb_v1 {
diff --git a/drivers/staging/lustre/lustre/include/lustre_capa.h b/drivers/staging/lustre/lustre/include/lustre_capa.h
index fe19534..d246556 100644
--- a/drivers/staging/lustre/lustre/include/lustre_capa.h
+++ b/drivers/staging/lustre/lustre/include/lustre_capa.h
@@ -166,10 +166,8 @@ do {									   \
 } while (0)
 
 #define DEBUG_CAPA_KEY(level, k, fmt, args...)				 \
-do {									   \
 CDEBUG(level, fmt " capability key@%p seq %llu keyid %u\n",		 \
-       ##args, k, capa_key_seq(k), capa_key_keyid(k));			 \
-} while (0)
+       ##args, k, capa_key_seq(k), capa_key_keyid(k))
 
 typedef int (* renew_capa_cb_t)(struct obd_capa *, struct lustre_capa *);
 
diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
index 83bc0a9..6be6079 100644
--- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
+++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
@@ -1309,13 +1309,11 @@ void ldlm_resource_dump(int level, struct ldlm_resource *);
 int ldlm_lock_change_resource(struct ldlm_namespace *, struct ldlm_lock *,
 			      const struct ldlm_res_id *);
 
-#define LDLM_RESOURCE_ADDREF(res) do {				  \
-	lu_ref_add_atomic(&(res)->lr_reference, __func__, current);  \
-} while (0)
+#define LDLM_RESOURCE_ADDREF(res)				  \
+	lu_ref_add_atomic(&(res)->lr_reference, __func__, current)
 
-#define LDLM_RESOURCE_DELREF(res) do {				  \
-	lu_ref_del(&(res)->lr_reference, __func__, current);	  \
-} while (0)
+#define LDLM_RESOURCE_DELREF(res)				  \
+	lu_ref_del(&(res)->lr_reference, __func__, current)
 
 /* ldlm_request.c */
 int ldlm_expired_completion_wait(void *data);
diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h
index 9c06a49..54cc56a 100644
--- a/drivers/staging/lustre/lustre/include/lustre_export.h
+++ b/drivers/staging/lustre/lustre/include/lustre_export.h
@@ -123,9 +123,7 @@ struct nid_stat {
 };
 
 #define nidstat_getref(nidstat)						\
-do {									   \
-	atomic_inc(&(nidstat)->nid_exp_ref_count);			 \
-} while (0)
+	atomic_inc(&(nidstat)->nid_exp_ref_count)
 
 #define nidstat_putref(nidstat)						\
 do {									   \
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
index 4a29261..9a5ad7c 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -1839,14 +1839,10 @@ extern void obd_cleanup_caches(void);
 extern struct kmem_cache *obdo_cachep;
 
 #define OBDO_ALLOC(ptr)						       \
-do {									  \
-	OBD_SLAB_ALLOC_PTR_GFP((ptr), obdo_cachep, GFP_NOFS);             \
-} while (0)
+	OBD_SLAB_ALLOC_PTR_GFP((ptr), obdo_cachep, GFP_NOFS)
 
 #define OBDO_FREE(ptr)							\
-do {									  \
-	OBD_SLAB_FREE_PTR((ptr), obdo_cachep);				\
-} while (0)
+	OBD_SLAB_FREE_PTR((ptr), obdo_cachep)
 
 
 static inline void obdo2fid(struct obdo *oa, struct lu_fid *fid)
-- 
2.3.0

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to