talloc: fix TALLOC_VERSION_* mismatch detection
authorStefan Metzmacher <metze@samba.org>
Tue, 14 Feb 2017 11:33:32 +0000 (12:33 +0100)
committerStefan Metzmacher <metze@samba.org>
Tue, 21 Feb 2017 23:14:34 +0000 (00:14 +0100)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Wed Feb 22 00:14:34 CET 2017 on sn-devel-144

lib/talloc/talloc.c
lib/talloc/talloc.h
lib/talloc/wscript

index 8bdd4b6653a72bb4b22ed74196c9f1bc5ca06941..7721fa4a9c6d7d59c3f85b82eaeeae2b3f09d4b7 100644 (file)
 #include <sys/auxv.h>
 #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;
                }
index b0917b5e176a6aac776b5e4f2010c97585cf89d2..227f745fab1ef67bda689bd216ff3d2e86af8375 100644 (file)
@@ -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);
index 8ce4f590a4aebf7f4f99e80018891b6d2f0072a8..d77de261cc810b15dbb48ead54eb6689979328f0 100644 (file)
@@ -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: