]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Rename event_find_field*() to event_find_field_recursive*()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 16 Mar 2021 17:09:06 +0000 (19:09 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Tue, 27 Apr 2021 10:55:32 +0000 (10:55 +0000)
This clarifies how it works.

src/auth/test-auth-request-fields.c
src/lib-dict/dict.c
src/lib/event-filter.c
src/lib/lib-event.c
src/lib/lib-event.h
src/lib/test-event-filter-expr.c
src/lib/test-event-filter.c
src/stats/event-exporter-fmt-json.c
src/stats/event-exporter-fmt-tab-text.c
src/stats/stats-metrics.c

index ad4d3da07dad2ee151698881d4104cda6a5b0f88..e43a1bf0f30daac92e42f2162968efcf7c29904c 100644 (file)
@@ -88,7 +88,7 @@ static void test_auth_request_fields_list(void)
 
                if (test->event_field != NULL) {
                        const char *value =
-                               event_find_field_str(request->event, test->event_field);
+                               event_find_field_recursive_str(request->event, test->event_field);
                        test_assert_idx(null_strcmp(value, test->value) == 0, i);
                }
        }
@@ -126,15 +126,15 @@ static void test_auth_request_fields_secured(void)
 
        test_assert(auth_request_import(request, "secured", ""));
        test_assert(test_auth_request_export_cmp(request, "secured", ""));
-       test_assert(null_strcmp(event_find_field_str(request->event, "transport"), "trusted") == 0);
+       test_assert(null_strcmp(event_find_field_recursive_str(request->event, "transport"), "trusted") == 0);
 
        test_assert(auth_request_import(request, "secured", "tls"));
        test_assert(test_auth_request_export_cmp(request, "secured", "tls"));
-       test_assert(null_strcmp(event_find_field_str(request->event, "transport"), "TLS") == 0);
+       test_assert(null_strcmp(event_find_field_recursive_str(request->event, "transport"), "TLS") == 0);
 
        test_assert(auth_request_import(request, "secured", "blah"));
        test_assert(test_auth_request_export_cmp(request, "secured", ""));
-       test_assert(null_strcmp(event_find_field_str(request->event, "transport"), "trusted") == 0);
+       test_assert(null_strcmp(event_find_field_recursive_str(request->event, "transport"), "trusted") == 0);
        test_auth_request_deinit(request);
 }
 
index b1d40a17b67bab2212ea1c4f81efb5deb94fa112..2682af099b2e87e3061191fa0d52d66e6a7f9ee5 100644 (file)
@@ -219,7 +219,7 @@ void dict_post_api_callback(struct dict *dict)
 static void dict_lookup_finished(struct event *event, int ret, const char *error)
 {
        i_assert(ret >= 0 || error != NULL);
-       const char *key = event_find_field_str(event, "key");
+       const char *key = event_find_field_recursive_str(event, "key");
        if (ret < 0)
                event_add_str(event, "error", error);
        else if (ret == 0)
index 434f7c85cf580700712222dbc072563eebbefa91..f04b0822001d9cb36af55a79d2c8f8ab8f4bc47f 100644 (file)
@@ -525,7 +525,7 @@ event_match_field(struct event *event, const struct event_field *wanted_field,
        const struct event_field *field;
 
        /* wanted_field has the value in all available formats */
-       field = event_find_field(event, wanted_field->key);
+       field = event_find_field_recursive(event, wanted_field->key);
        if (field == NULL) {
                /* field="" matches nonexistent field */
                return wanted_field->value.str[0] == '\0';
index 8f214810b6ba270c6eff6bf4122745627e0be91e..cd716f88f0e4f43f3cf2260b214492af2e859b27 100644 (file)
@@ -98,7 +98,7 @@ event_find_category(const struct event *event,
                    const struct event_category *category);
 
 static struct event_field *
-event_find_field_int(const struct event *event, const char *key);
+event_find_field(const struct event *event, const char *key);
 
 static void event_set_changed(struct event *event)
 {
@@ -194,7 +194,7 @@ bool event_has_all_fields(struct event *event, const struct event *other)
        if (!array_is_created(&other->fields))
                return TRUE;
        array_foreach_modifiable(&other->fields, fld) {
-               if (event_find_field_int(event, fld->key) == NULL)
+               if (event_find_field(event, fld->key) == NULL)
                        return FALSE;
        }
        return TRUE;
@@ -793,7 +793,7 @@ event_add_category(struct event *event, struct event_category *category)
 }
 
 static struct event_field *
-event_find_field_int(const struct event *event, const char *key)
+event_find_field(const struct event *event, const char *key)
 {
        struct event_field *field;
 
@@ -808,12 +808,12 @@ event_find_field_int(const struct event *event, const char *key)
 }
 
 const struct event_field *
-event_find_field(const struct event *event, const char *key)
+event_find_field_recursive(const struct event *event, const char *key)
 {
        const struct event_field *field;
 
        do {
-               if ((field = event_find_field_int(event, key)) != NULL)
+               if ((field = event_find_field(event, key)) != NULL)
                        return field;
                event = event->parent;
        } while (event != NULL);
@@ -821,11 +821,11 @@ event_find_field(const struct event *event, const char *key)
 }
 
 const char *
-event_find_field_str(const struct event *event, const char *key)
+event_find_field_recursive_str(const struct event *event, const char *key)
 {
        const struct event_field *field;
 
-       field = event_find_field(event, key);
+       field = event_find_field_recursive(event, key);
        if (field == NULL)
                return NULL;
 
@@ -847,7 +847,7 @@ event_get_field(struct event *event, const char *key)
 {
        struct event_field *field;
 
-       field = event_find_field_int(event, key);
+       field = event_find_field(event, key);
        if (field == NULL) {
                if (!array_is_created(&event->fields))
                        p_array_init(&event->fields, event->pool, 8);
@@ -892,7 +892,7 @@ event_inc_int(struct event *event, const char *key, intmax_t num)
 {
        struct event_field *field;
 
-       field = event_find_field_int(event, key);
+       field = event_find_field(event, key);
        if (field == NULL || field->value_type != EVENT_FIELD_VALUE_TYPE_INTMAX)
                return event_add_int(event, key, num);
 
index 2c6ab2bbcf57c4f941f742384dd95e224dc7de91..4d6f8750cd3616e6db49327951c1bf81869a8616 100644 (file)
@@ -301,12 +301,12 @@ void event_get_last_duration(const struct event *event,
 /* Returns field for a given key, or NULL if it doesn't exist. If the key
    isn't found from the event itself, find it from parent events. */
 const struct event_field *
-event_find_field(const struct event *event, const char *key);
+event_find_field_recursive(const struct event *event, const char *key);
 /* Returns the given key's value as string, or NULL if it doesn't exist.
    If the field isn't stored as a string, the result is allocated from
    data stack. */
 const char *
-event_find_field_str(const struct event *event, const char *key);
+event_find_field_recursive_str(const struct event *event, const char *key);
 /* Returns all key=value fields that the event has.
    Parent events' fields aren't returned. */
 const struct event_field *
index 7ed2f55dfdf4301a93fc71a03b5d5a5a84026d00..0af8a982ebdfc5bc9a9a461861489f94d16e1dc7 100644 (file)
@@ -41,8 +41,8 @@ static void do_test_expr(const char *filter_string, struct event *event,
        test_begin(t_strdup_printf("%.*s log type + event {a=%s, b=%s} + filter '%s' (exp %s)",
                                   3, /* truncate the type name to avoid CI seeing 'warning' messages */
                                   event_filter_category_from_log_type(log_type),
-                                  event_find_field_str(event, "a"),
-                                  event_find_field_str(event, "b"),
+                                  event_find_field_recursive_str(event, "a"),
+                                  event_find_field_recursive_str(event, "b"),
                                   filter_string,
                                   expected ? "true" : "false"));
 
index cbaccccb5e33565cbe262bf6f184ab40b985d090..3a3b6e4d22bfc2a7a459ddef1a41a7890e9acab9 100644 (file)
@@ -140,13 +140,13 @@ static void test_event_filter_inc_int(void)
        filter = event_filter_create();
        event_filter_add(filter, &query);
 
-       const struct event_field *f = event_find_field(root, "int");
+       const struct event_field *f = event_find_field_recursive(root, "int");
        i_assert(f == NULL);
        test_assert(!event_filter_match(filter, root, &failure_ctx));
 
        event_inc_int(root, "int", 7);
        test_assert(!event_filter_match(filter, root, &failure_ctx));
-       f = event_find_field(root, "int");
+       f = event_find_field_recursive(root, "int");
        i_assert(f != NULL);
        test_assert_strcmp(f->key, "int");
        test_assert(f->value_type == EVENT_FIELD_VALUE_TYPE_INTMAX);
@@ -154,7 +154,7 @@ static void test_event_filter_inc_int(void)
 
        event_inc_int(root, "int", 7);
        test_assert(event_filter_match(filter, root, &failure_ctx));
-       f = event_find_field(root, "int");
+       f = event_find_field_recursive(root, "int");
        i_assert(f != NULL);
        test_assert_strcmp(f->key, "int");
        test_assert(f->value_type == EVENT_FIELD_VALUE_TYPE_INTMAX);
index ce98911a81bd6aab482bfd9b53cb4b7d0ddb4d91..4d1f10716562b9a60babcd49933dbaca3300fe85 100644 (file)
@@ -150,7 +150,7 @@ static void json_export_fields(string_t *dest, struct event *event,
                        const char *name = fields[i].field_key;
                        const struct event_field *field;
 
-                       field = event_find_field(event, name);
+                       field = event_find_field_recursive(event, name);
                        if (field == NULL)
                                continue; /* doesn't exist, skip it */
 
index 2b8ea01f3d7b0659acfb8be659c4c5195cdfc2bc..aab48189fa62ddcdc661d96a09f957da8aac98f3 100644 (file)
@@ -132,7 +132,7 @@ static void tabtext_export_fields(string_t *dest, struct event *event,
                        const char *name = fields[i].field_key;
                        const struct event_field *field;
 
-                       field = event_find_field(event, name);
+                       field = event_find_field_recursive(event, name);
                        if (field == NULL)
                                continue; /* doesn't exist, skip it */
 
index 66f6ecd26dce843a7059bffc6573a15d45c3ce6e..f4de66dd2fc09b2e095f70ed1c08cdbad88ca982 100644 (file)
@@ -426,7 +426,8 @@ static void
 stats_metric_group_by(struct metric *metric, struct event *event, pool_t pool)
 {
        const struct stats_metric_settings_group_by *group_by = &metric->group_by[0];
-       const struct event_field *field = event_find_field(event, group_by->field);
+       const struct event_field *field =
+               event_find_field_recursive(event, group_by->field);
        struct metric *sub_metric;
        struct metric_value value;
 
@@ -479,7 +480,8 @@ static void
 stats_metric_event_field(struct event *event, const char *fieldname,
                         struct stats_dist *stats)
 {
-       const struct event_field *field = event_find_field(event, fieldname);
+       const struct event_field *field =
+               event_find_field_recursive(event, fieldname);
        intmax_t num = 0;
 
        if (field == NULL)