Commit ee5c8023 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Tim Shimmin

[XFS] fix ASSERT and ASSERT_ALWAYS

- remove the != 0 inside the unlikely in ASSERT_ALWAYS because sparse now
  complains about comparisons 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
  assertion in the assfail message and don't overflow sparse's
  stringification buffer leading to sparse error messages.

SGI-PV: 968555
SGI-Modid: xfs-linux-melb:xfs-kern:29310a
Signed-off-by: default avatarChristoph Hellwig <hch@infradead.org>
Signed-off-by: default avatarDavid Chinner <dgc@sgi.com>
Signed-off-by: default avatarTim Shimmin <tes@sgi.com>
parent 34521c5e
...@@ -34,10 +34,10 @@ extern void cmn_err(int, char *, ...) ...@@ -34,10 +34,10 @@ extern void cmn_err(int, char *, ...)
extern void assfail(char *expr, char *f, int l); extern void assfail(char *expr, char *f, int l);
#define ASSERT_ALWAYS(expr) \ #define ASSERT_ALWAYS(expr) \
(unlikely((expr) != 0) ? (void)0 : assfail(#expr, __FILE__, __LINE__)) (unlikely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__))
#ifndef DEBUG #ifndef DEBUG
# define ASSERT(expr) ((void)0) #define ASSERT(expr) ((void)0)
#ifndef STATIC #ifndef STATIC
# define STATIC static noinline # define STATIC static noinline
...@@ -49,8 +49,10 @@ extern void assfail(char *expr, char *f, int l); ...@@ -49,8 +49,10 @@ extern void assfail(char *expr, char *f, int l);
#else /* DEBUG */ #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 #ifndef STATIC
# define STATIC noinline # define STATIC noinline
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment