This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] malloc: unobfuscate an assert


From: Joern Engel <joern@purestorage.org>

Assert was defined such that by default one gets 'variable set but not
used' style warnings.  It is better to prevent them by changing the
assert define than by littering all callsites with workarounds.

JIRA: PURE-27597
---
 tpc/malloc2.13/arena.h  | 3 +--
 tpc/malloc2.13/malloc.c | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/tpc/malloc2.13/arena.h b/tpc/malloc2.13/arena.h
index d038565f84d3..85373466928f 100644
--- a/tpc/malloc2.13/arena.h
+++ b/tpc/malloc2.13/arena.h
@@ -486,8 +486,7 @@ static void mbind_memory(void *mem, size_t size, int node)
 
 	assert(max_node < sizeof(unsigned long));
 	err = mbind(mem, size, MPOL_PREFERRED, &node_mask, max_node, MPOL_F_STATIC_NODES);
-	if (err)
-		assert(!err);
+	assert(!err);
 }
 
 /* Create a new heap.  size is automatically rounded up to a multiple
diff --git a/tpc/malloc2.13/malloc.c b/tpc/malloc2.13/malloc.c
index 461621c11250..0a71065a7b90 100644
--- a/tpc/malloc2.13/malloc.c
+++ b/tpc/malloc2.13/malloc.c
@@ -316,7 +316,7 @@ extern "C" {
 #include <assert.h>
 #else
 #undef  assert
-#define assert(x) ((void)0)
+#define assert(x) if (0 && !(x)) { ; }
 #endif
 
 /*
-- 
2.7.0.rc3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]