summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/mem-pool.c
diff options
context:
space:
mode:
authorJules.Wang <lancelotds@163.com>2012-08-01 09:37:09 +0800
committerAnand Avati <avati@redhat.com>2012-08-01 19:04:47 -0700
commit9c8fe5beb872f5e1d7824b292cb97b47289cb6bd (patch)
tree7aaf4975e2d880f141cd5381ea1afed16890601b /libglusterfs/src/mem-pool.c
parent980f99e29eed340baf8c9bdcc5d85a36794bde20 (diff)
mem-pool: remove 'if' by asserting condition directly.
before: if (!condition) { GF_ASSERT (0); } after: GF_ASSERT (condition); BUG: 764890 Change-Id: I9894fcc609579f5efd3f98dbff41ca1487ce6dd2 Signed-off-by: Jules Wang <lancelotds@163.com> Reviewed-on: http://review.gluster.com/3762 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'libglusterfs/src/mem-pool.c')
-rw-r--r--libglusterfs/src/mem-pool.c33
1 files changed, 11 insertions, 22 deletions
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c
index 2df47756f7d..50f8fef5a13 100644
--- a/libglusterfs/src/mem-pool.c
+++ b/libglusterfs/src/mem-pool.c
@@ -71,17 +71,11 @@ gf_mem_set_acct_info (xlator_t *xl, char **alloc_ptr,
ptr = (char *) (*alloc_ptr);
- if (!xl) {
- GF_ASSERT (0);
- }
+ GF_ASSERT (xl != NULL);
- if (!(xl->mem_acct.rec)) {
- GF_ASSERT (0);
- }
+ GF_ASSERT (xl->mem_acct.rec != NULL);
- if (type > xl->mem_acct.num_types) {
- GF_ASSERT (0);
- }
+ GF_ASSERT (type <= xl->mem_acct.num_types);
LOCK(&xl->mem_acct.rec[type].lock);
{
@@ -255,20 +249,16 @@ __gf_free (void *free_ptr)
ptr = (char *)free_ptr - 8 - 4;
- if (GF_MEM_HEADER_MAGIC != *(uint32_t *)ptr) {
- //Possible corruption, assert here
- GF_ASSERT (0);
- }
+ //Possible corruption, assert here
+ GF_ASSERT (GF_MEM_HEADER_MAGIC == *(uint32_t *)ptr);
*(uint32_t *)ptr = 0;
ptr = ptr - sizeof(xlator_t *);
memcpy (&xl, ptr, sizeof(xlator_t *));
- if (!xl) {
- //gf_free expects xl to be available
- GF_ASSERT (0);
- }
+ //gf_free expects xl to be available
+ GF_ASSERT (xl != NULL);
if (!xl->mem_acct.rec) {
ptr = (char *)free_ptr - GF_MEM_HEADER_SIZE;
@@ -281,11 +271,10 @@ __gf_free (void *free_ptr)
ptr = ptr - 4;
type = *(uint32_t *)ptr;
- if (GF_MEM_TRAILER_MAGIC != *(uint32_t *)
- ((char *)free_ptr + req_size)) {
- // This points to a memory overrun
- GF_ASSERT (0);
- }
+ // This points to a memory overrun
+ GF_ASSERT (GF_MEM_TRAILER_MAGIC ==
+ *(uint32_t *)((char *)free_ptr + req_size));
+
*(uint32_t *) ((char *)free_ptr + req_size) = 0;
LOCK (&xl->mem_acct.rec[type].lock);