From: Josef 'Jeff' Sipek Date: Wed, 19 Oct 2016 16:33:02 +0000 (-0400) Subject: data-stack: T_BEGIN should use file & line number as the t_push marker X-Git-Tag: 2.3.0.rc1~2687 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9d69283efe8ff56a3b9adb813dc79f7d910ace6a;p=thirdparty%2Fdovecot%2Fcore.git data-stack: T_BEGIN should use file & line number as the t_push marker Using a function name is not unique if there is more than one T_BEGIN in a function. Therefore, switch the marker passed into t_push to be the concatenation of __FILE__ and __LINE__. --- diff --git a/src/lib/data-stack.h b/src/lib/data-stack.h index 5ea1237ae6..7725489c3e 100644 --- a/src/lib/data-stack.h +++ b/src/lib/data-stack.h @@ -43,7 +43,7 @@ extern unsigned int data_stack_frame_id; is called. Returns the current stack frame number, which can be used to detect missing t_pop() calls: - x = t_push(__func__); .. if (!t_pop(x)) abort(); + x = t_push(marker); .. if (!t_pop(x)) abort(); In DEBUG mode, t_push_named() makes a temporary allocation for the name, but is safe to call in a loop as it performs the allocation within its own @@ -58,9 +58,10 @@ bool t_pop(data_stack_frame_t *id) ATTR_HOT; void t_pop_last_unsafe(void); /* Usage: T_BEGIN { code } T_END */ +#define T_CAT2(a,b) (a ":" #b) #define T_BEGIN \ STMT_START { \ - data_stack_frame_t _data_stack_cur_id = t_push(__func__); + data_stack_frame_t _data_stack_cur_id = t_push(T_CAT2(__FILE__, __LINE__)); #define T_END \ STMT_START { \ if (unlikely(!t_pop(&_data_stack_cur_id))) \