public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix ASSERT and ASSERT_ALWAYS
@ 2007-07-14 16:04 Christoph Hellwig
  2007-07-14 16:38 ` Eric Sandeen
  2007-07-16  3:28 ` David Chinner
  0 siblings, 2 replies; 3+ messages in thread
From: Christoph Hellwig @ 2007-07-14 16:04 UTC (permalink / raw)
  To: xfs

 - remove the != 0 inside the unlikely in ASSERT_ALWAYS because sparse now
   complains about comparisms between pointers and 0
 - add a standalone ASSERT implementation because defining it to
   ASSERT_ALWAYS means the string is expanded before the #token passing
   stringification.  This way we get the actual content of the
   assertatio in the assfail message and don't overflow sparse's
   strinification buffer leading to sparse error messages.


Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: linux-2.6-xfs/fs/xfs/support/debug.h
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/support/debug.h	2007-07-14 15:55:12.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/support/debug.h	2007-07-14 15:55:46.000000000 +0200
@@ -34,10 +34,10 @@ extern void cmn_err(int, char *, ...)
 extern void assfail(char *expr, char *f, int l);
 
 #define ASSERT_ALWAYS(expr)	\
-	(unlikely((expr) != 0) ? (void)0 : assfail(#expr, __FILE__, __LINE__))
+	(unlikely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__))
 
 #ifndef DEBUG
-# define ASSERT(expr)	((void)0)
+#define ASSERT(expr)	((void)0)
 
 #ifndef STATIC
 # define STATIC static noinline
@@ -49,8 +49,10 @@ extern void assfail(char *expr, char *f,
 
 #else /* DEBUG */
 
-# define ASSERT(expr)	ASSERT_ALWAYS(expr)
-# include <linux/random.h>
+#include <linux/random.h>
+
+#define ASSERT(expr)	\
+	(unlikely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__))
 
 #ifndef STATIC
 # define STATIC noinline

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

* Re: [PATCH] fix ASSERT and ASSERT_ALWAYS
  2007-07-14 16:04 [PATCH] fix ASSERT and ASSERT_ALWAYS Christoph Hellwig
@ 2007-07-14 16:38 ` Eric Sandeen
  2007-07-16  3:28 ` David Chinner
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Sandeen @ 2007-07-14 16:38 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

Christoph Hellwig wrote:
>  - remove the != 0 inside the unlikely in ASSERT_ALWAYS because sparse now
>    complains about comparisms between pointers and 0
>  - add a standalone ASSERT implementation because defining it to
>    ASSERT_ALWAYS means the string is expanded before the #token passing
>    stringification.  This way we get the actual content of the
>    assertatio in the assfail message and don't overflow sparse's
>    strinification buffer leading to sparse error messages.

Looks fine to me.

-Eric

> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> Index: linux-2.6-xfs/fs/xfs/support/debug.h
> ===================================================================
> --- linux-2.6-xfs.orig/fs/xfs/support/debug.h	2007-07-14 15:55:12.000000000 +0200
> +++ linux-2.6-xfs/fs/xfs/support/debug.h	2007-07-14 15:55:46.000000000 +0200
> @@ -34,10 +34,10 @@ extern void cmn_err(int, char *, ...)
>  extern void assfail(char *expr, char *f, int l);
>  
>  #define ASSERT_ALWAYS(expr)	\
> -	(unlikely((expr) != 0) ? (void)0 : assfail(#expr, __FILE__, __LINE__))
> +	(unlikely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__))
>  
>  #ifndef DEBUG
> -# define ASSERT(expr)	((void)0)
> +#define ASSERT(expr)	((void)0)
>  
>  #ifndef STATIC
>  # define STATIC static noinline
> @@ -49,8 +49,10 @@ extern void assfail(char *expr, char *f,
>  
>  #else /* DEBUG */
>  
> -# define ASSERT(expr)	ASSERT_ALWAYS(expr)
> -# include <linux/random.h>
> +#include <linux/random.h>
> +
> +#define ASSERT(expr)	\
> +	(unlikely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__))
>  
>  #ifndef STATIC
>  # define STATIC noinline
> 
> 

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

* Re: [PATCH] fix ASSERT and ASSERT_ALWAYS
  2007-07-14 16:04 [PATCH] fix ASSERT and ASSERT_ALWAYS Christoph Hellwig
  2007-07-14 16:38 ` Eric Sandeen
@ 2007-07-16  3:28 ` David Chinner
  1 sibling, 0 replies; 3+ messages in thread
From: David Chinner @ 2007-07-16  3:28 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

On Sat, Jul 14, 2007 at 06:04:21PM +0200, Christoph Hellwig wrote:
>  - remove the != 0 inside the unlikely in ASSERT_ALWAYS because sparse now
>    complains about comparisms between pointers and 0
>  - add a standalone ASSERT implementation because defining it to
>    ASSERT_ALWAYS means the string is expanded before the #token passing
>    stringification.  This way we get the actual content of the
>    assertatio in the assfail message and don't overflow sparse's
>    strinification buffer leading to sparse error messages.
> 
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

OK.

Rather than replying to each patch, Christoph - I've taken the
whole set into my queue for 2.6.24. All the warnings and cleanups
look ok and should not be a problem, but I need to have a much
closer look at the bmbt_rec endian notation series before that
goes further.

Cheers,

Dave.
-- 
Dave Chinner
Principal Engineer
SGI Australian Software Group

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

end of thread, other threads:[~2007-07-16  3:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-14 16:04 [PATCH] fix ASSERT and ASSERT_ALWAYS Christoph Hellwig
2007-07-14 16:38 ` Eric Sandeen
2007-07-16  3:28 ` David Chinner

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