From 299f6ce2b17216a6c09d5345139b9a78f7505b24 Mon Sep 17 00:00:00 2001 From: Humble Devassy Chirammal Date: Fri, 20 Mar 2015 18:57:52 +0530 Subject: libgfapi: revamp glfs_new function Current glfs_new() function is not flexible enough to error out and destroy the struct members or objects initialized just before the error path/condition. This make the structs or objects to continue or left out with partially recorded data in fs and ctx structs and cause crashes/issues later in the code path. This patch avoid the issue. Change-Id: Ie4514b82b24723a46681cc7832a08870afc0cb28 BUG: 1202492 Signed-off-by: Humble Devassy Chirammal Reviewed-on: http://review.gluster.org/9903 Tested-by: Gluster Build System Reviewed-by: Poornima G Reviewed-by: soumya k Reviewed-by: Kaleb KEITHLEY --- libglusterfs/src/mem-pool.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'libglusterfs/src') diff --git a/libglusterfs/src/mem-pool.h b/libglusterfs/src/mem-pool.h index 88ec9705604..2bbb45ae8a7 100644 --- a/libglusterfs/src/mem-pool.h +++ b/libglusterfs/src/mem-pool.h @@ -111,11 +111,13 @@ void* __gf_default_realloc (void *oldptr, size_t size) #define CALLOC(cnt,size) __gf_default_calloc(cnt,size) #define REALLOC(ptr,size) __gf_default_realloc(ptr,size) -#define FREE(ptr) \ - if (ptr != NULL) { \ - free ((void *)ptr); \ - ptr = (void *)0xeeeeeeee; \ - } +#define FREE(ptr) \ + do { \ + if (ptr != NULL) { \ + free ((void *)ptr); \ + ptr = (void *)0xeeeeeeee; \ + } \ + } while (0) #define GF_CALLOC(nmemb, size, type) __gf_calloc (nmemb, size, type, #type) -- cgit