From: Sage Weil Date: Thu, 7 Jun 2012 17:19:09 +0000 (-0700) Subject: deliberately break encoding macros when wrong assert is present X-Git-Tag: v0.48argonaut~104^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fae1d47aae28c612237a85fb9bf324edf13a87c2;p=ceph.git deliberately break encoding macros when wrong assert is present Signed-off-by: Sage Weil --- diff --git a/src/include/assert.h b/src/include/assert.h index 81a37a84be6b..fa49a2f3e0f2 100644 --- a/src/include/assert.h +++ b/src/include/assert.h @@ -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)) diff --git a/src/include/encoding.h b/src/include/encoding.h index 97f1b2073275..abd1257700b6 100644 --- a/src/include/encoding.h +++ b/src/include/encoding.h @@ -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)