]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Reformat lib-event to avoid long lines
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 16 Mar 2021 17:13:23 +0000 (19:13 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Tue, 27 Apr 2021 10:55:32 +0000 (10:55 +0000)
src/lib/lib-event.c
src/lib/lib-event.h

index cd716f88f0e4f43f3cf2260b214492af2e859b27..daf1c8312f9a5acda165200dc947bbe66d1c7582 100644 (file)
@@ -147,7 +147,8 @@ event_call_callbacks_noargs(struct event *event,
 void event_copy_categories(struct event *to, struct event *from)
 {
        unsigned int cat_count;
-       struct event_category *const *categories = event_get_categories(from, &cat_count);
+       struct event_category *const *categories =
+               event_get_categories(from, &cat_count);
        for (unsigned int i = 1; i <= cat_count; i++)
                event_add_category(to, categories[cat_count-i]);
 }
@@ -342,8 +343,10 @@ struct event *event_minimize(struct event *event)
        skip_bound = NULL;
        for (; cur != NULL; cur = cur->parent) {
                if (cur->sent_to_stats_id == 0 &&
-                   (!array_is_created(&cur->fields) || array_is_empty(&cur->fields)) &&
-                   (!array_is_created(&cur->categories) || array_is_empty(&cur->categories)))
+                   (!array_is_created(&cur->fields) ||
+                    array_is_empty(&cur->fields)) &&
+                   (!array_is_created(&cur->categories) ||
+                    array_is_empty(&cur->categories)))
                        continue;
 
                skip_bound = cur;
@@ -413,7 +416,8 @@ event_create_passthrough(struct event *parent, const char *source_filename,
        if (!parent->passthrough) {
                if (event_last_passthrough != NULL) {
                        /* API is being used in a wrong or dangerous way */
-                       i_panic("Can't create multiple passthrough events - finish the earlier with ->event()");
+                       i_panic("Can't create multiple passthrough events - "
+                               "finish the earlier with ->event()");
                }
                struct event *event =
                        event_create(parent, source_filename, source_linenum);
@@ -654,7 +658,8 @@ struct event_category *event_category_find_registered(const char *name)
        return NULL;
 }
 
-static struct event_internal_category *event_category_find_internal(const char *name)
+static struct event_internal_category *
+event_category_find_internal(const char *name)
 {
        struct event_internal_category *const *internal;
 
@@ -672,15 +677,18 @@ event_get_registered_categories(unsigned int *count_r)
        return array_get(&event_registered_categories_representative, count_r);
 }
 
-static void event_category_add_to_array(struct event_internal_category *internal)
+static void
+event_category_add_to_array(struct event_internal_category *internal)
 {
        struct event_category *representative = &internal->representative;
 
        array_push_back(&event_registered_categories_internal, &internal);
-       array_push_back(&event_registered_categories_representative, &representative);
+       array_push_back(&event_registered_categories_representative,
+                       &representative);
 }
 
-static struct event_category *event_category_register(struct event_category *category)
+static struct event_category *
+event_category_register(struct event_category *category)
 {
        struct event_internal_category *internal = category->internal;
        event_category_callback_t *const *callbackp;
@@ -722,7 +730,8 @@ static struct event_category *event_category_register(struct event_category *cat
                if ((category->parent != NULL) &&
                    (internal->parent != category->parent->internal)) {
                        /* case 4 */
-                       struct event_internal_category *other = category->parent->internal;
+                       struct event_internal_category *other =
+                               category->parent->internal;
 
                        i_panic("event category parent mismatch detected: "
                                "category %p internal %p (%s), "
@@ -739,8 +748,10 @@ static struct event_category *event_category_register(struct event_category *cat
 
        category->internal = internal;
 
-       if (!allocated)
-               return &internal->representative; /* not the first registration of this category */
+       if (!allocated) {
+               /* not the first registration of this category */
+               return &internal->representative;
+       }
 
        array_foreach(&event_category_callbacks, callbackp) T_BEGIN {
                (*callbackp)(&internal->representative);
@@ -836,8 +847,8 @@ event_find_field_recursive_str(const struct event *event, const char *key)
                return dec2str(field->value.intmax);
        case EVENT_FIELD_VALUE_TYPE_TIMEVAL:
                return t_strdup_printf("%"PRIdTIME_T".%u",
-                                      field->value.timeval.tv_sec,
-                                      (unsigned int)field->value.timeval.tv_usec);
+                       field->value.timeval.tv_sec,
+                       (unsigned int)field->value.timeval.tv_usec);
        }
        i_unreached();
 }
@@ -921,10 +932,13 @@ event_add_fields(struct event *event,
        for (unsigned int i = 0; fields[i].key != NULL; i++) {
                if (fields[i].value != NULL)
                        event_add_str(event, fields[i].key, fields[i].value);
-               else if (fields[i].value_timeval.tv_sec != 0)
-                       event_add_timeval(event, fields[i].key, &fields[i].value_timeval);
-               else
-                       event_add_int(event, fields[i].key, fields[i].value_intmax);
+               else if (fields[i].value_timeval.tv_sec != 0) {
+                       event_add_timeval(event, fields[i].key,
+                                         &fields[i].value_timeval);
+               } else {
+                       event_add_int(event, fields[i].key,
+                                     fields[i].value_intmax);
+               }
        }
        return event;
 }
@@ -1099,7 +1113,8 @@ void event_export(const struct event *event, string_t *dest)
 
 bool event_import(struct event *event, const char *str, const char **error_r)
 {
-       return event_import_unescaped(event, t_strsplit_tabescaped(str), error_r);
+       return event_import_unescaped(event, t_strsplit_tabescaped(str),
+                                     error_r);
 }
 
 static bool event_import_tv(const char *arg_secs, const char *arg_usecs,
@@ -1170,8 +1185,10 @@ bool event_import_unescaped(struct event *event, const char *const *args,
                        break;
                }
                case EVENT_CODE_TV_LAST_SENT:
-                       if (!event_import_tv(arg, args[1], &event->tv_last_sent, &error)) {
-                               *error_r = t_strdup_printf("Invalid tv_last_sent: %s", error);
+                       if (!event_import_tv(arg, args[1], &event->tv_last_sent,
+                                            &error)) {
+                               *error_r = t_strdup_printf(
+                                       "Invalid tv_last_sent: %s", error);
                                return FALSE;
                        }
                        args++;
@@ -1263,8 +1280,9 @@ void event_unregister_callback(event_callback_t *callback)
 
        array_foreach(&event_handlers, callbackp) {
                if (*callbackp == callback) {
-                       array_delete(&event_handlers,
-                                    array_foreach_idx(&event_handlers, callbackp), 1);
+                       unsigned int idx =
+                               array_foreach_idx(&event_handlers, callbackp);
+                       array_delete(&event_handlers, idx, 1);
                        return;
                }
        }
@@ -1282,8 +1300,10 @@ void event_category_unregister_callback(event_category_callback_t *callback)
 
        array_foreach(&event_category_callbacks, callbackp) {
                if (*callbackp == callback) {
-                       array_delete(&event_category_callbacks,
-                                    array_foreach_idx(&event_category_callbacks, callbackp), 1);
+                       unsigned int idx =
+                               array_foreach_idx(&event_category_callbacks,
+                                                 callbackp);
+                       array_delete(&event_category_callbacks, idx, 1);
                        return;
                }
        }
index 4d6f8750cd3616e6db49327951c1bf81869a8616..2e64e21c8bef614ecbed0eb08d8807f2daa1386c 100644 (file)
@@ -94,10 +94,12 @@ typedef const char *
 event_log_message_callback_t(void *context, enum log_type log_type,
                             const char *message);
 
-/* Returns TRUE if the event has all the categories that the "other" event has (and maybe more). */
+/* Returns TRUE if the event has all the categories that the "other" event has
+   (and maybe more). */
 bool event_has_all_categories(struct event *event, const struct event *other);
-/* Returns TRUE if the event has all the fields that the "other" event has (and maybe more).
-   Only the fields in the events themselves are checked. Parent events' fields are not checked. */
+/* Returns TRUE if the event has all the fields that the "other" event has
+   (and maybe more). Only the fields in the events themselves are checked.
+   Parent events' fields are not checked. */
 bool event_has_all_fields(struct event *event, const struct event *other);
 
 /* Returns the source event duplicated into a new event. Event pointers are
@@ -200,19 +202,20 @@ struct event *
 event_drop_parent_log_prefixes(struct event *event, unsigned int count);
 
 /* Sets event prefix callback, sets log_prefix empty */
-struct event *event_set_log_prefix_callback(struct event *event,
-                                           bool replace,
-                                           event_log_prefix_callback_t *callback,
-                                           void *context);
+struct event *
+event_set_log_prefix_callback(struct event *event, bool replace,
+                             event_log_prefix_callback_t *callback,
+                             void *context);
 #define event_set_log_prefix_callback(event, replace, callback, context) \
        event_set_log_prefix_callback(event, replace, \
                (event_log_prefix_callback_t*)callback, TRUE ? context : \
                CALLBACK_TYPECHECK(callback, const char *(*)(typeof(context))))
 
 /* Sets event message amendment callback */
-struct event *event_set_log_message_callback(struct event *event,
-                                            event_log_message_callback_t *callback,
-                                            void *context);
+struct event *
+event_set_log_message_callback(struct event *event,
+                              event_log_message_callback_t *callback,
+                              void *context);
 #define event_set_log_message_callback(event, callback, context) \
        event_set_log_message_callback(event, \
                (event_log_message_callback_t*)callback, TRUE ? context : \