]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
deliberately break encoding macros when wrong assert is present
authorSage Weil <sage@inktank.com>
Thu, 7 Jun 2012 17:19:09 +0000 (10:19 -0700)
committerSage Weil <sage@inktank.com>
Thu, 7 Jun 2012 17:19:09 +0000 (10:19 -0700)
Signed-off-by: Sage Weil <sage@inktank.com>
src/include/assert.h
src/include/encoding.h

index 81a37a84be6bf1ea8af1388cbaf568ca5ae080b3..fa49a2f3e0f2b581652a44e716aee5d88ebe4117 100644 (file)
@@ -39,12 +39,12 @@ struct FailedAssertion {
    C9x has a similar variable called __func__, but prefer the GCC one since
    it demangles C++ function names.  */
 # if defined __cplusplus ? __GNUC_PREREQ (2, 6) : __GNUC_PREREQ (2, 4)
-#   define __ASSERT_FUNCTION   __PRETTY_FUNCTION__
+#   define __CEPH_ASSERT_FUNCTION      __PRETTY_FUNCTION__
 # else
 #  if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
-#   define __ASSERT_FUNCTION   __func__
+#   define __CEPH_ASSERT_FUNCTION      __func__
 #  else
-#   define __ASSERT_FUNCTION   ((__const char *) 0)
+#   define __CEPH_ASSERT_FUNCTION      ((__const char *) 0)
 #  endif
 # endif
 
@@ -56,12 +56,12 @@ extern void __ceph_assert_warn(const char *assertion, const char *file, int line
 #define ceph_assert(expr)                                                      \
   ((expr)                                                              \
    ? __CEPH_ASSERT_VOID_CAST (0)                                       \
-   : __ceph_assert_fail (__STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION))
+   : __ceph_assert_fail (__STRING(expr), __FILE__, __LINE__, __CEPH_ASSERT_FUNCTION))
 
 #define assert_warn(expr)                                                      \
   ((expr)                                                              \
    ? __CEPH_ASSERT_VOID_CAST (0)                                       \
-   : __ceph_assert_warn (__STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION))
+   : __ceph_assert_warn (__STRING(expr), __FILE__, __LINE__, __CEPH_ASSERT_FUNCTION))
 
 /*
 #define assert(expr)                                                   \
@@ -111,8 +111,13 @@ using namespace ceph;
 #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)                                                   \
   ((expr)                                                              \
    ? __CEPH_ASSERT_VOID_CAST (0)                                       \
-   : __ceph_assert_fail (__STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION))
+   : __ceph_assert_fail (__STRING(expr), __FILE__, __LINE__, __CEPH_ASSERT_FUNCTION))
 
index 97f1b207327569ae70518abf1bae4b0489fa027b..abd1257700b61f129ae12b6a407ea1dc83d4a6ea 100644 (file)
@@ -20,6 +20,7 @@
 #include "inttypes.h"
 #include "byteorder.h"
 #include "buffer.h"
+#include "assert.h"
 
 using namespace ceph;
 
@@ -58,7 +59,7 @@ inline void decode_raw(T& t, bufferlist::iterator &p)
 
 #define WRITE_RAW_ENCODER(type)                                                \
   inline void encode(const type &v, bufferlist& bl, uint64_t features=0) { encode_raw(v, bl); } \
-  inline void decode(type &v, bufferlist::iterator& p) { decode_raw(v, p); }
+  inline void decode(type &v, bufferlist::iterator& p) { __ASSERT_FUNCTION decode_raw(v, p); }
 
 WRITE_RAW_ENCODER(__u8)
 WRITE_RAW_ENCODER(__s8)