]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Perform most of the event logging within data stack frame
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 26 Apr 2021 11:14:45 +0000 (14:14 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Tue, 4 May 2021 07:02:35 +0000 (07:02 +0000)
src/lib/event-log.c
src/lib/test-event-log.c

index d0bcc69fc4afa01e05ca1d5f9330f6e218597c58..f9dceb204ed8c0ce10fb9df5d321335c352b5f1a 100644 (file)
@@ -24,7 +24,9 @@ void e_error(struct event *event,
        va_list args;
 
        va_start(args, fmt);
-       event_logv(event, &params, fmt, args);
+       T_BEGIN {
+               event_logv(event, &params, fmt, args);
+       } T_END;
        va_end(args);
 }
 
@@ -41,7 +43,9 @@ void e_warning(struct event *event,
        va_list args;
 
        va_start(args, fmt);
-       event_logv(event, &params, fmt, args);
+       T_BEGIN {
+               event_logv(event, &params, fmt, args);
+       } T_END;
        va_end(args);
 }
 
@@ -58,7 +62,9 @@ void e_info(struct event *event,
        va_list args;
 
        va_start(args, fmt);
-       event_logv(event, &params, fmt, args);
+       T_BEGIN {
+               event_logv(event, &params, fmt, args);
+       } T_END;
        va_end(args);
 }
 
@@ -75,7 +81,9 @@ void e_debug(struct event *event,
        va_list args;
 
        va_start(args, fmt);
-       event_logv(event, &params, fmt, args);
+       T_BEGIN {
+               event_logv(event, &params, fmt, args);
+       } T_END;
        va_end(args);
 }
 
@@ -92,7 +100,9 @@ void e_log(struct event *event, enum log_type level,
        va_list args;
 
        va_start(args, fmt);
-       event_logv(event, &params, fmt, args);
+       T_BEGIN {
+               event_logv(event, &params, fmt, args);
+       } T_END;
        va_end(args);
 }
 
index 1be4c9ee1e53eace4e8a78a6680e409b24dc7cf5..286a9810abe6e365b7063c8238d2a985b8f6b6dd 100644 (file)
@@ -2463,8 +2463,12 @@ static void test_event_log_message(void)
                }
                event = parent;
 
-               if (test->result_str_out != NULL)
-                       params.base_str_out = t_str_new(256);
+               if (test->result_str_out != NULL) {
+                       /* Use small value so buffer size grows. This way the
+                          unit test fails if anyone attempts to add data-stack
+                          frame to event_log(). */
+                       params.base_str_out = t_str_new(1);
+               }
                event_log(event, &params, "TEXT");
 
                test_assert_strcmp(test->result, test_output);