Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1622857 > unrolled thread

[PATCH RESEND v2] Staging: lustre cleanup macros in libcfs_private.h

Started byCraig Inches <Craig@craiginches.com>
First post2017-04-13 11:30 +0200
Last post2017-04-18 11:50 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH RESEND v2] Staging: lustre cleanup macros in libcfs_private.h Craig Inches <Craig@craiginches.com> - 2017-04-13 11:30 +0200
    Re: [PATCH RESEND v2] Staging: lustre cleanup macros in  libcfs_private.h Greg KH <gregkh@linuxfoundation.org> - 2017-04-14 10:20 +0200
    Re: [lustre-devel] [PATCH RESEND v2] Staging: lustre cleanup macros  in     libcfs_private.h "Dilger, Andreas" <andreas.dilger@intel.com> - 2017-04-18 11:50 +0200

#1622857 — [PATCH RESEND v2] Staging: lustre cleanup macros in libcfs_private.h

FromCraig Inches <Craig@craiginches.com>
Date2017-04-13 11:30 +0200
Subject[PATCH RESEND v2] Staging: lustre cleanup macros in libcfs_private.h
Message-ID<tvJeH-Wr-33@gated-at.bofh.it>
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>
---
Changes in v2:
    - Kept statements together
    - Kept operator on previous line

 .../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..e774c75 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

[toc] | [next] | [standalone]


#1623556 — Re: [PATCH RESEND v2] Staging: lustre cleanup macros in libcfs_private.h

FromGreg KH <gregkh@linuxfoundation.org>
Date2017-04-14 10:20 +0200
SubjectRe: [PATCH RESEND v2] Staging: lustre cleanup macros in libcfs_private.h
Message-ID<tw4Cu-7aA-5@gated-at.bofh.it>
In reply to#1622857
On Thu, Apr 13, 2017 at 10:24:41AM +0100, Craig Inches 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>
> ---
> Changes in v2:
>     - Kept statements together
>     - Kept operator on previous line

Why RESEND?

> 
>  .../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..e774c75 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)			 \

I need a lustre maintainer to ack this one before I can take it.
Perhaps there was a good reasaon do { } while is used here...

thanks,

greg k-h

[toc] | [prev] | [next] | [standalone]


#1625194 — Re: [lustre-devel] [PATCH RESEND v2] Staging: lustre cleanup macros in libcfs_private.h

From"Dilger, Andreas" <andreas.dilger@intel.com>
Date2017-04-18 11:50 +0200
SubjectRe: [lustre-devel] [PATCH RESEND v2] Staging: lustre cleanup macros in libcfs_private.h
Message-ID<txxVM-4zJ-21@gated-at.bofh.it>
In reply to#1622857
On Apr 13, 2017, at 03:24, 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>

I don't think there was any particular reason for "do { } while(0)" here except
force of habit.

Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>

> ---
> Changes in v2:
>    - Kept statements together
>    - Kept operator on previous line
> 
> .../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..e774c75 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
> 
> _______________________________________________
> lustre-devel mailing list
> lustre-devel@lists.lustre.org
> http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org

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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web