Print this page
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libzpool/common/sys/zfs_context.h
          +++ new/usr/src/lib/libzpool/common/sys/zfs_context.h
↓ open down ↓ 28 lines elided ↑ open up ↑
  29   29  #define _SYS_ZFS_CONTEXT_H
  30   30  
  31   31  #ifdef  __cplusplus
  32   32  extern "C" {
  33   33  #endif
  34   34  
  35   35  #define _SYS_MUTEX_H
  36   36  #define _SYS_RWLOCK_H
  37   37  #define _SYS_CONDVAR_H
  38   38  #define _SYS_SYSTM_H
  39      -#define _SYS_DEBUG_H
  40   39  #define _SYS_T_LOCK_H
  41   40  #define _SYS_VNODE_H
  42   41  #define _SYS_VFS_H
  43   42  #define _SYS_SUNDDI_H
  44   43  #define _SYS_CALLB_H
  45   44  
  46   45  #include <stdio.h>
  47   46  #include <stdlib.h>
  48   47  #include <stddef.h>
  49   48  #include <stdarg.h>
↓ open down ↓ 21 lines elided ↑ open up ↑
  71   70  #include <sys/byteorder.h>
  72   71  #include <sys/list.h>
  73   72  #include <sys/uio.h>
  74   73  #include <sys/zfs_debug.h>
  75   74  #include <sys/sdt.h>
  76   75  #include <sys/kstat.h>
  77   76  #include <sys/u8_textprep.h>
  78   77  #include <sys/sysevent/eventdefs.h>
  79   78  #include <sys/sysevent/dev.h>
  80   79  #include <sys/sunddi.h>
       80 +#include <sys/debug.h>
  81   81  
  82   82  /*
  83   83   * Debugging
  84   84   */
  85   85  
  86   86  /*
  87   87   * Note that we are not using the debugging levels.
  88   88   */
  89   89  
  90   90  #define CE_CONT         0       /* continuation         */
↓ open down ↓ 12 lines elided ↑ open up ↑
 103  103  
 104  104  extern void cmn_err(int, const char *, ...);
 105  105  extern void vcmn_err(int, const char *, __va_list);
 106  106  extern void panic(const char *, ...);
 107  107  extern void vpanic(const char *, __va_list);
 108  108  
 109  109  #define fm_panic        panic
 110  110  
 111  111  extern int aok;
 112  112  
 113      -/* This definition is copied from assert.h. */
 114      -#if defined(__STDC__)
 115      -#if __STDC_VERSION__ - 0 >= 199901L
 116      -#define zverify(EX) (void)((EX) || (aok) || \
 117      -        (__assert_c99(#EX, __FILE__, __LINE__, __func__), 0))
 118      -#else
 119      -#define zverify(EX) (void)((EX) || (aok) || \
 120      -        (__assert(#EX, __FILE__, __LINE__), 0))
 121      -#endif /* __STDC_VERSION__ - 0 >= 199901L */
 122      -#else
 123      -#define zverify(EX) (void)((EX) || (aok) || \
 124      -        (_assert("EX", __FILE__, __LINE__), 0))
 125      -#endif  /* __STDC__ */
 126      -
 127      -
 128      -#define VERIFY  zverify
 129      -#define ASSERT  zverify
 130      -#undef  assert
 131      -#define assert  zverify
 132      -
 133      -extern void __assert(const char *, const char *, int);
 134      -
 135      -#ifdef lint
 136      -#define VERIFY3_IMPL(x, y, z, t)        if (x == z) ((void)0)
 137      -#else
 138      -/* BEGIN CSTYLED */
 139      -#define VERIFY3_IMPL(LEFT, OP, RIGHT, TYPE) do { \
 140      -        const TYPE __left = (TYPE)(LEFT); \
 141      -        const TYPE __right = (TYPE)(RIGHT); \
 142      -        if (!(__left OP __right) && (!aok)) { \
 143      -                char *__buf = alloca(256); \
 144      -                (void) snprintf(__buf, 256, "%s %s %s (0x%llx %s 0x%llx)", \
 145      -                        #LEFT, #OP, #RIGHT, \
 146      -                        (u_longlong_t)__left, #OP, (u_longlong_t)__right); \
 147      -                __assert(__buf, __FILE__, __LINE__); \
 148      -        } \
 149      -_NOTE(CONSTCOND) } while (0)
 150      -/* END CSTYLED */
 151      -#endif /* lint */
 152      -
 153      -#define VERIFY3S(x, y, z)       VERIFY3_IMPL(x, y, z, int64_t)
 154      -#define VERIFY3U(x, y, z)       VERIFY3_IMPL(x, y, z, uint64_t)
 155      -#define VERIFY3P(x, y, z)       VERIFY3_IMPL(x, y, z, uintptr_t)
 156      -
 157      -#ifdef NDEBUG
 158      -#define ASSERT3S(x, y, z)       ((void)0)
 159      -#define ASSERT3U(x, y, z)       ((void)0)
 160      -#define ASSERT3P(x, y, z)       ((void)0)
 161      -#else
 162      -#define ASSERT3S(x, y, z)       VERIFY3S(x, y, z)
 163      -#define ASSERT3U(x, y, z)       VERIFY3U(x, y, z)
 164      -#define ASSERT3P(x, y, z)       VERIFY3P(x, y, z)
 165      -#endif
 166      -
 167  113  /*
 168  114   * DTrace SDT probes have different signatures in userland than they do in
 169  115   * kernel.  If they're being used in kernel code, re-define them out of
 170  116   * existence for their counterparts in libzpool.
 171  117   */
 172  118  
 173  119  #ifdef DTRACE_PROBE
 174  120  #undef  DTRACE_PROBE
 175  121  #define DTRACE_PROBE(a) ((void)0)
 176  122  #endif  /* DTRACE_PROBE */
↓ open down ↓ 456 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX