[Gluster-devel] Query regarding GF_ASSERT macro
Atin Mukherjee
amukherj at redhat.com
Thu Jan 2 06:14:10 UTC 2014
I think GF_ASSERT macro should be modified such that in case of no debug build if x is NULL, after logging an error message it should abort i.e. by calling assert(). This fix is required as there are places where consecutive GF_ASSERT macro has been called like :
GF_ASSERT (shandle);
GF_ASSERT (shandle->path);
(store.c : function : gf_store_unlink_tmppath)
Current code:
#ifdef DEBUG
#define GF_ASSERT(x) assert (x);
#else
#define GF_ASSERT(x) \
do { \
if (!(x)) { \
gf_log_callingfn ("", GF_LOG_ERROR, \
"Assertion failed: " #x); \
} \
} while (0)
#endif
Modified code:
#ifdef DEBUG
#define GF_ASSERT(x) assert (x);
#else
#define GF_ASSERT(x) \
do { \
if (!(x)) { \
gf_log_callingfn ("", GF_LOG_ERROR, \
"Assertion failed: " #x); \
assert (x); \
} \
} while (0)
#endif
Please let me know your opinion on this.
Regards,
Atin Mukherjee
Senior Software Engineer
E-9, Extn : 73196, Direct : 08039245196, Mobile: +919739491377
Email - amukherj at redhat.com
More information about the Gluster-devel
mailing list