]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
include,common: Remove assert and clobber-foo
authorAdam C. Emerson <aemerson@redhat.com>
Thu, 23 Aug 2018 17:23:41 +0000 (13:23 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Mon, 27 Aug 2018 14:27:22 +0000 (10:27 -0400)
Since everything is using the ceph_assert macro, get rid of the assert
macro in include/assert.h .

As that is no longer a concern, get of macros to break the compile if
our macro gets replaced with the system assert.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/common/dout.h
src/include/assert.h
src/include/encoding.h

index 0c2069bf340211fb088675d96d447ae65b10eb23..d9b3acfec48c0bbf88e0407b729dd1390b168275 100644 (file)
@@ -109,10 +109,8 @@ struct is_dynamic<dynamic_marker_t<T>> : public std::true_type {};
 #define ldlog_p1(cct, sub, lvl)                 \
   (cct->_conf->subsys.should_gather((sub), (lvl)))
 
-// NOTE: depend on magic value in _ASSERT_H so that we detect when
-// /usr/include/assert.h clobbers our fancier version.
 #define dendl_impl std::flush;                         \
-  _ASSERT_H->_log->submit_entry(_dout_e);              \
+  _dout_cct->_log->submit_entry(_dout_e);              \
     }                                          \
   } while (0)
 
index 7bfa28c86ab75f94a937e50bb641d9f7d058a1e0..93a45e85dbb3181ab425441ca531583187d3c1ce 100644 (file)
 # include "acconfig.h"
 #endif
 
-#ifdef __cplusplus
 class CephContext;
 
 namespace ceph {
 
 struct BackTrace;
-#endif
 
 /*
  * For GNU, test specific version features. Otherwise (e.g. LLVM) we'll use
@@ -62,9 +60,7 @@ struct BackTrace;
 # define __CEPH_ASSERT_FUNCTION ((__const char *) 0)
 #endif
 
-#ifdef __cplusplus
 extern void register_assert_context(CephContext *cct);
-#endif
 
 struct assert_data {
   const char *assertion;
@@ -82,31 +78,17 @@ extern void __ceph_assertf_fail(const char *assertion, const char *file, int lin
   __attribute__ ((__noreturn__));
 extern void __ceph_assert_warn(const char *assertion, const char *file, int line, const char *function);
 
-#ifndef CEPH_ASSERT_FAIL_DEPR
-#define CEPH_ASSERT_FAIL_DEPR
-[[deprecated, noreturn]]
-void inline __ceph_assert_fail_depr(const assert_data &ctx) {
-  __ceph_assert_fail(ctx);
-}
-#endif
-
-#ifdef __cplusplus
-# define _CEPH_ASSERT_VOID_CAST static_cast<void>
-#else
-# define _CEPH_ASSERT_VOID_CAST (void)
-#endif
+#define _CEPH_ASSERT_VOID_CAST static_cast<void>
 
 #define assert_warn(expr)                                                      \
   ((expr)                                                              \
    ? _CEPH_ASSERT_VOID_CAST (0)                                        \
    : __ceph_assert_warn (__STRING(expr), __FILE__, __LINE__, __CEPH_ASSERT_FUNCTION))
 
-#ifdef __cplusplus
 }
 
 using namespace ceph;
 
-#endif
 
 /*
  * ceph_abort aborts the program with a nice backtrace.
@@ -121,31 +103,6 @@ using namespace ceph;
                abort();                                                \
        }
 
-#endif
-
-// wipe any prior assert definition
-#ifdef assert
-# undef assert
-#endif
-
-// make _ASSERT_H something that *must* have a value other than what
-// /usr/include/assert.h gives it (nothing!), so that we detect when
-// our assert is clobbered.
-#undef _ASSERT_H
-#define _ASSERT_H _dout_cct
-
-// make __ASSERT_FUNCTION empty (/usr/include/assert.h makes it a function)
-// and make our encoding macros break if it non-empty.
-#undef __ASSERT_FUNCTION
-#define __ASSERT_FUNCTION
-
-#define assert(expr) \
-  do { static const ceph::assert_data assert_data_ctx = \
-   {__STRING(expr), __FILE__, __LINE__, __CEPH_ASSERT_FUNCTION}; \
-   ((expr) \
-   ? _CEPH_ASSERT_VOID_CAST (0)        \
-   : __ceph_assert_fail_depr(assert_data_ctx)); } while(false)
-
 #define ceph_assert(expr)                                                      \
   do { static const ceph::assert_data assert_data_ctx = \
    {__STRING(expr), __FILE__, __LINE__, __CEPH_ASSERT_FUNCTION}; \
@@ -179,3 +136,5 @@ using namespace ceph;
   ((expr)                                                              \
    ? _CEPH_ASSERT_VOID_CAST (0)                                        \
    : __ceph_assertf_fail (__STRING(expr), __FILE__, __LINE__, __CEPH_ASSERT_FUNCTION, __VA_ARGS__))
+
+#endif
index 757bde705c7c7e9a310254ab1a693b4d7fa9bb0e..81e86a0103a1b8b65acbc3482e4e650ab51ee518 100644 (file)
@@ -79,7 +79,7 @@ inline void decode_raw(T& t, bufferlist::const_iterator &p)
 
 #define WRITE_RAW_ENCODER(type)                                                \
   inline void encode(const type &v, ::ceph::bufferlist& bl, uint64_t features=0) { ::ceph::encode_raw(v, bl); } \
-  inline void decode(type &v, ::ceph::bufferlist::const_iterator& p) { __ASSERT_FUNCTION ::ceph::decode_raw(v, p); }
+  inline void decode(type &v, ::ceph::bufferlist::const_iterator& p) { ::ceph::decode_raw(v, p); }
 
 WRITE_RAW_ENCODER(__u8)
 #ifndef _CHAR_IS_SIGNED