From: Timo Sirainen Date: Tue, 16 Mar 2021 17:13:23 +0000 (+0200) Subject: lib: Reformat lib-event to avoid long lines X-Git-Tag: 2.3.16~317 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3460178be874ff4049dc5bebf25f6126a6ebbf6;p=thirdparty%2Fdovecot%2Fcore.git lib: Reformat lib-event to avoid long lines --- diff --git a/src/lib/lib-event.c b/src/lib/lib-event.c index cd716f88f0..daf1c8312f 100644 --- a/src/lib/lib-event.c +++ b/src/lib/lib-event.c @@ -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; } } diff --git a/src/lib/lib-event.h b/src/lib/lib-event.h index 4d6f8750cd..2e64e21c8b 100644 --- a/src/lib/lib-event.h +++ b/src/lib/lib-event.h @@ -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 : \