]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
data-stack: T_BEGIN should use file & line number as the t_push marker
authorJosef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
Wed, 19 Oct 2016 16:33:02 +0000 (12:33 -0400)
committerGitLab <gitlab@git.dovecot.net>
Wed, 2 Nov 2016 21:21:59 +0000 (23:21 +0200)
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__.

src/lib/data-stack.h

index 5ea1237ae65e4c45dafa70ac62896c640756d224..7725489c3e9ebf294ef7d58025113f73966a41f2 100644 (file)
@@ -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))) \