This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] malloc: unobfuscate an assert
- From: Joern Engel <joern at purestorage dot com>
- To: "GNU C. Library" <libc-alpha at sourceware dot org>
- Cc: Siddhesh Poyarekar <siddhesh dot poyarekar at gmail dot com>, Joern Engel <joern at purestorage dot org>
- Date: Mon, 25 Jan 2016 16:24:58 -0800
- Subject: [PATCH] malloc: unobfuscate an assert
- Authentication-results: sourceware.org; auth=none
- References: <1453767942-19369-1-git-send-email-joern at purestorage dot com>
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