]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: If DEBUG is enabled, use a pointer type for data_stack_frame_t
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 1 Sep 2016 05:41:28 +0000 (08:41 +0300)
committerGitLab <gitlab@git.dovecot.net>
Fri, 2 Sep 2016 07:50:29 +0000 (10:50 +0300)
This allows telling static analyzers to treat t_push() and t_pop() similarly
to malloc()/free() and check for leaks.

src/lib/data-stack.c
src/lib/data-stack.h

index 7e071502300ffc99d68ddc2bd28292a0fe6b635f..88939ed7a2cf98cde454043e682ecc8e79c0b5a4 100644 (file)
@@ -67,6 +67,12 @@ struct stack_frame_block {
 #endif
 };
 
+#ifdef DEBUG
+struct data_stack_frame {
+       int dummy;
+};
+#endif
+
 data_stack_frame_t data_stack_frame = 0;
 
 static bool data_stack_initialized = FALSE;
@@ -571,7 +577,7 @@ void data_stack_init(void)
                return;
        }
        data_stack_initialized = TRUE;
-       data_stack_frame = 1;
+       data_stack_frame = (data_stack_frame_t)1;
 
        outofmem_area.block.size = outofmem_area.block.left =
                sizeof(outofmem_area) - sizeof(outofmem_area.block);
index 6867c08a9a4cc55cd72670c5e8163a0bc531babf..b15b12dbfce3d45a07ffe7daf0ab1ed635c4bc16 100644 (file)
       overflows.
 */
 
+#ifndef DEBUG
 typedef unsigned int data_stack_frame_t;
+#else
+typedef struct data_stack_frame *data_stack_frame_t;
+#endif
 
 extern data_stack_frame_t data_stack_frame;