From 6dbac4bee8196ab89f3876e1256c41b71cdd214d Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Thu, 25 Apr 2024 15:11:31 +0100 Subject: [PATCH] aggregate-tally: Remove ability to stop iteration Previously, the callback passed to emer_aggregate_tally_iter() or emer_aggregate_tally_iter_before() would return a value from the EmerTallyIterResult enum, either CONTINUE or STOP. The iteration logic would stop iteration if the callback returned STOP. (Actually it performed a bitwise comparison, but since the only documented values were 0 or 1 it's the same thing.) This functionality is unused, and has been broken since commit c56d656ea46176ecd405a0ba4f1ed93ed21cdd27. In the case where the loop was terminated early by the callback, 'ret' would still hold SQLITE_ROW, which would then be passed to our check_sqlite_error() helper (via the CHECK() macro). This macro considers any value other than SQLITE_OK or SQLITE_DONE to be an error. Rather than try to fix it, we can just remove it without loss of functionality. https://phabricator.endlessm.com/T35331 --- daemon/emer-aggregate-tally.c | 8 +------- daemon/emer-aggregate-tally.h | 7 +------ daemon/emer-daemon.c | 4 +--- tests/daemon/test-aggregate-tally.c | 4 +--- tools/print-aggregates.c | 4 +--- 5 files changed, 5 insertions(+), 22 deletions(-) diff --git a/daemon/emer-aggregate-tally.c b/daemon/emer-aggregate-tally.c index 053c740..cf4bae3 100644 --- a/daemon/emer-aggregate-tally.c +++ b/daemon/emer-aggregate-tally.c @@ -612,22 +612,16 @@ emer_aggregate_tally_iter_internal (EmerAggregateTally *self, guint32 counter = column_to_uint32 (stmt, 4); const char *event_date = (const char *) sqlite3_column_text (stmt, 5); uuid_t event_id = { 0 }; - EmerTallyIterResult result; column_to_uuid (stmt, 1, event_id); - result = func (unix_user_id, event_id, - payload, - counter, event_date, user_data); + func (unix_user_id, event_id, payload, counter, event_date, user_data); if (flags & EMER_TALLY_ITER_FLAG_DELETE) { const sqlite3_int64 row_id = sqlite3_column_int64 (stmt, 0); g_array_append_val (rows_to_delete, row_id); } - - if (result & EMER_TALLY_ITER_STOP) - break; } /* Close the cursor before we try to delete the rows it returned */ diff --git a/daemon/emer-aggregate-tally.h b/daemon/emer-aggregate-tally.h index 1cbbdcc..2f59fbd 100644 --- a/daemon/emer-aggregate-tally.h +++ b/daemon/emer-aggregate-tally.h @@ -32,18 +32,13 @@ typedef enum { EMER_TALLY_ITER_FLAG_DELETE = 1 << 0, } EmerTallyIterFlags; -typedef enum { - EMER_TALLY_ITER_CONTINUE = 0, - EMER_TALLY_ITER_STOP = 1, -} EmerTallyIterResult; - typedef enum { EMER_TALLY_DAILY_EVENTS, EMER_TALLY_MONTHLY_EVENTS, } EmerTallyType; -typedef EmerTallyIterResult (*EmerTallyIterFunc) (guint32 unix_user_id, +typedef void (*EmerTallyIterFunc) (guint32 unix_user_id, uuid_t event_id, GVariant *payload, guint32 counter, diff --git a/daemon/emer-daemon.c b/daemon/emer-daemon.c index c8cc8f4..5f5955c 100644 --- a/daemon/emer-daemon.c +++ b/daemon/emer-daemon.c @@ -1118,7 +1118,7 @@ split_aggregate_timers (EmerDaemon *self, emer_aggregate_timer_impl_split (timer_impl, monotonic_time_us); } -static EmerTallyIterResult +static void buffer_aggregate_event_to_queue (guint32 unix_user_id, uuid_t event_uuid, GVariant *payload, @@ -1133,8 +1133,6 @@ buffer_aggregate_event_to_queue (guint32 unix_user_id, date, counter, payload); - - return EMER_TALLY_ITER_CONTINUE; } static inline gboolean diff --git a/tests/daemon/test-aggregate-tally.c b/tests/daemon/test-aggregate-tally.c index 7b1887f..3423a53 100644 --- a/tests/daemon/test-aggregate-tally.c +++ b/tests/daemon/test-aggregate-tally.c @@ -176,7 +176,7 @@ test_aggregate_tally_store_events (struct Fixture *fixture, g_assert_no_error (error); } -static EmerTallyIterResult +static void tally_iter_func (guint32 unix_user_id, uuid_t event_id, GVariant *payload, @@ -187,8 +187,6 @@ tally_iter_func (guint32 unix_user_id, GPtrArray *events = user_data; g_ptr_array_add (events, aggregate_event_new (unix_user_id, event_id, payload, counter, date)); - - return EMER_TALLY_ITER_CONTINUE; } static void diff --git a/tools/print-aggregates.c b/tools/print-aggregates.c index 0e2bf8f..ab4c778 100644 --- a/tools/print-aggregates.c +++ b/tools/print-aggregates.c @@ -35,7 +35,7 @@ static const char *HEADER = " Counter " "Payload\n"; -static EmerTallyIterResult +static void print_event (guint32 unix_user_id, uuid_t event_id, GVariant *payload, @@ -59,8 +59,6 @@ print_event (guint32 unix_user_id, event_id_str, counter, payload_str ?: ""); - - return EMER_TALLY_ITER_CONTINUE; } static gboolean