public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: xfs@oss.sgi.com
Subject: [PATCH] fix ASSERT and ASSERT_ALWAYS
Date: Sat, 14 Jul 2007 18:04:21 +0200	[thread overview]
Message-ID: <20070714160418.GA7768@lst.de> (raw)

 - 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

             reply	other threads:[~2007-07-14 16:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-14 16:04 Christoph Hellwig [this message]
2007-07-14 16:38 ` [PATCH] fix ASSERT and ASSERT_ALWAYS Eric Sandeen
2007-07-16  3:28 ` David Chinner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070714160418.GA7768@lst.de \
    --to=hch@lst.de \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox