linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Staging: lustre cleanup macros in libcfs_private.h
@ 2017-04-03 21:13 Craig Inches
  2017-04-05 10:14 ` Dilger, Andreas
  0 siblings, 1 reply; 2+ messages in thread
From: Craig Inches @ 2017-04-03 21:13 UTC (permalink / raw)
  To: oleg.drokin, andreas.dilger, jsimmons, gregkh, john.hammond
  Cc: lustre-devel, devel, linux-kernel, Craig Inches

This resolves a checkpatch warning that "Single statement macros should
not use a do {} while (0) loop" by removing the loop and adjusting line
length accordingly.

Signed-off-by: Craig Inches <Craig@craiginches.com>
---
 .../lustre/include/linux/libcfs/libcfs_private.h   | 51 +++++++---------------
 1 file changed, 15 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
index 2dae857..150454f 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
@@ -87,12 +87,9 @@ do {								    \
 #define LIBCFS_VMALLOC_SIZE	(2 << PAGE_SHIFT) /* 2 pages */
 #endif
 
-#define LIBCFS_ALLOC_PRE(size, mask)					    \
-do {									    \
-	LASSERT(!in_interrupt() ||					    \
-		((size) <= LIBCFS_VMALLOC_SIZE &&			    \
-		 !gfpflags_allow_blocking(mask)));			    \
-} while (0)
+#define LIBCFS_ALLOC_PRE(size, mask)					\
+	LASSERT(!in_interrupt() || ((size) <= LIBCFS_VMALLOC_SIZE	\
+		&& !gfpflags_allow_blocking(mask)))
 
 #define LIBCFS_ALLOC_POST(ptr, size)					    \
 do {									    \
@@ -187,46 +184,28 @@ void  cfs_array_free(void *vars);
 #if LASSERT_ATOMIC_ENABLED
 
 /** 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)
+#define LASSERT_ATOMIC_EQ(a, v) LASSERTF(atomic_read(a) == v,		\
+					 "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)
+#define LASSERT_ATOMIC_NE(a, v) LASSERTF(atomic_read(a) != v,		\
+					 "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)
+#define LASSERT_ATOMIC_LT(a, v) LASSERTF(atomic_read(a) < v,		\
+					 "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)
+#define LASSERT_ATOMIC_LE(a, v) LASSERTF(atomic_read(a) <= v,		\
+					 "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)
+#define LASSERT_ATOMIC_GT(a, v) LASSERTF(atomic_read(a) > v,		\
+					 "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)
+#define LASSERT_ATOMIC_GE(a, v) LASSERTF(atomic_read(a) >= v,		\
+					 "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)			 \
-- 
2.10.2

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

* Re: [PATCH] Staging: lustre cleanup macros in libcfs_private.h
  2017-04-03 21:13 [PATCH] Staging: lustre cleanup macros in libcfs_private.h Craig Inches
@ 2017-04-05 10:14 ` Dilger, Andreas
  0 siblings, 0 replies; 2+ messages in thread
From: Dilger, Andreas @ 2017-04-05 10:14 UTC (permalink / raw)
  To: Craig Inches
  Cc: Drokin, Oleg, jsimmons, gregkh, Hammond, John, lustre-devel,
	devel, linux-kernel

On Apr 3, 2017, at 15:13, Craig Inches <craig@craiginches.com> wrote:
> 
> This resolves a checkpatch warning that "Single statement macros should
> not use a do {} while (0) loop" by removing the loop and adjusting line
> length accordingly.
> 
> Signed-off-by: Craig Inches <Craig@craiginches.com>
> ---
> .../lustre/include/linux/libcfs/libcfs_private.h   | 51 +++++++---------------
> 1 file changed, 15 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
> index 2dae857..150454f 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
> @@ -87,12 +87,9 @@ do {								    \
> #define LIBCFS_VMALLOC_SIZE	(2 << PAGE_SHIFT) /* 2 pages */
> #endif
> 
> -#define LIBCFS_ALLOC_PRE(size, mask)					    \
> -do {									    \
> -	LASSERT(!in_interrupt() ||					    \
> -		((size) <= LIBCFS_VMALLOC_SIZE &&			    \
> -		 !gfpflags_allow_blocking(mask)));			    \
> -} while (0)
> +#define LIBCFS_ALLOC_PRE(size, mask)					\
> +	LASSERT(!in_interrupt() || ((size) <= LIBCFS_VMALLOC_SIZE	\
> +		&& !gfpflags_allow_blocking(mask)))

(style) keep operators at the end of the previous line, rather than the start
of the continued line

> 
> #define LIBCFS_ALLOC_POST(ptr, size)					    \
> do {									    \
> @@ -187,46 +184,28 @@ void  cfs_array_free(void *vars);
> #if LASSERT_ATOMIC_ENABLED
> 
> /** 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)
> +#define LASSERT_ATOMIC_EQ(a, v) LASSERTF(atomic_read(a) == v,		\
> +					 "value: %d\n", atomic_read((a)))

Minor nit - in cases like this where you need to split the line anyway, it
is cleaner (IMHO) to keep the whole statement together:

#define LASSERT_ATOMIC_EQ(a, v)						\
	LASSERTF(atomic_read(a) == v, "value: %d\n", atomic_read((a)))

Cheers, Andreas

> 
> /** 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)
> +#define LASSERT_ATOMIC_NE(a, v) LASSERTF(atomic_read(a) != v,		\
> +					 "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)
> +#define LASSERT_ATOMIC_LT(a, v) LASSERTF(atomic_read(a) < v,		\
> +					 "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)
> +#define LASSERT_ATOMIC_LE(a, v) LASSERTF(atomic_read(a) <= v,		\
> +					 "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)
> +#define LASSERT_ATOMIC_GT(a, v) LASSERTF(atomic_read(a) > v,		\
> +					 "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)
> +#define LASSERT_ATOMIC_GE(a, v) LASSERTF(atomic_read(a) >= v,		\
> +					 "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)			 \
> -- 
> 2.10.2
> 

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation

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

end of thread, other threads:[~2017-04-05 10:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-03 21:13 [PATCH] Staging: lustre cleanup macros in libcfs_private.h Craig Inches
2017-04-05 10:14 ` Dilger, Andreas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).