From 16ea6e1308a7d94a501d002ed53529f6d754e940 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 14 Feb 2017 12:33:32 +0100 Subject: [PATCH] talloc: fix TALLOC_VERSION_* mismatch detection Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme Autobuild-User(master): Stefan Metzmacher Autobuild-Date(master): Wed Feb 22 00:14:34 CET 2017 on sn-devel-144 --- lib/talloc/talloc.c | 11 ++++------- lib/talloc/talloc.h | 2 +- lib/talloc/wscript | 4 ++++ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c index 8bdd4b6653a..7721fa4a9c6 100644 --- a/lib/talloc/talloc.c +++ b/lib/talloc/talloc.c @@ -37,17 +37,13 @@ #include #endif -#ifdef TALLOC_BUILD_VERSION_MAJOR #if (TALLOC_VERSION_MAJOR != TALLOC_BUILD_VERSION_MAJOR) #error "TALLOC_VERSION_MAJOR != TALLOC_BUILD_VERSION_MAJOR" #endif -#endif -#ifdef TALLOC_BUILD_VERSION_MINOR #if (TALLOC_VERSION_MINOR != TALLOC_BUILD_VERSION_MINOR) #error "TALLOC_VERSION_MINOR != TALLOC_BUILD_VERSION_MINOR" #endif -#endif /* Special macros that are no-ops except when run under Valgrind on * x86. They've moved a little bit from valgrind 1.0.4 to 1.9.4 */ @@ -82,8 +78,9 @@ static unsigned int talloc_magic = ( ~TALLOC_FLAG_MASK & ( TALLOC_MAGIC_BASE + - (TALLOC_VERSION_MAJOR << 12) + - (TALLOC_VERSION_MINOR << 4))); + (TALLOC_BUILD_VERSION_MAJOR << 24) + + (TALLOC_BUILD_VERSION_MINOR << 16) + + (TALLOC_BUILD_VERSION_RELEASE << 8))); /* by default we abort when given a bad pointer (such as when talloc_free() is called on a pointer that came from malloc() */ @@ -453,7 +450,7 @@ static inline struct talloc_chunk *talloc_chunk_from_ptr(const void *ptr) const char *pp = (const char *)ptr; struct talloc_chunk *tc = discard_const_p(struct talloc_chunk, pp - TC_HDR_SIZE); if (unlikely((tc->flags & (TALLOC_FLAG_FREE | ~TALLOC_FLAG_MASK)) != talloc_magic)) { - if ((tc->flags & (~0xF)) == talloc_magic) { + if ((tc->flags & (~TALLOC_FLAG_MASK)) == talloc_magic) { talloc_abort_magic(tc->flags & (~TALLOC_FLAG_MASK)); return NULL; } diff --git a/lib/talloc/talloc.h b/lib/talloc/talloc.h index b0917b5e176..227f745fab1 100644 --- a/lib/talloc/talloc.h +++ b/lib/talloc/talloc.h @@ -43,7 +43,7 @@ extern "C" { */ #define TALLOC_VERSION_MAJOR 2 -#define TALLOC_VERSION_MINOR 0 +#define TALLOC_VERSION_MINOR 1 int talloc_version_major(void); int talloc_version_minor(void); diff --git a/lib/talloc/wscript b/lib/talloc/wscript index 8ce4f590a4a..d77de261cc8 100644 --- a/lib/talloc/wscript +++ b/lib/talloc/wscript @@ -42,6 +42,10 @@ def configure(conf): conf.env.standalone_talloc = conf.IN_LAUNCH_DIR() + conf.define('TALLOC_BUILD_VERSION_MAJOR', int(VERSION.split('.')[0])) + conf.define('TALLOC_BUILD_VERSION_MINOR', int(VERSION.split('.')[1])) + conf.define('TALLOC_BUILD_VERSION_RELEASE', int(VERSION.split('.')[2])) + conf.env.disable_python = getattr(Options.options, 'disable_python', False) if not conf.env.standalone_talloc: -- 2.34.1