From bc9b129e956e8dac5f6fcb57b0f8fa6c81baa76e Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 7 Aug 2020 10:52:16 +1000 Subject: [PATCH] libei: rename _NEW state to _HELLO We need a state for *before* we connected to a server (i.e. after ei_new() but before a backend was successfully set up), so let's rename the current NEW state to HELLO and then, later, add a NEW state for that. Signed-off-by: Peter Hutterer --- src/libei-private.h | 2 +- src/libei.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libei-private.h b/src/libei-private.h index 832c028..3d774d5 100644 --- a/src/libei-private.h +++ b/src/libei-private.h @@ -34,7 +34,7 @@ struct ei_backend_interface { }; enum ei_state { - EI_STATE_NEW, /* just connected, server sent hello */ + EI_STATE_BACKEND, /* We have a backend */ EI_STATE_CONNECTING, /* client requested connect */ EI_STATE_CONNECTED, /* server has sent connect */ EI_STATE_DISCONNECTED, diff --git a/src/libei.c b/src/libei.c index 8985616..5765a87 100644 --- a/src/libei.c +++ b/src/libei.c @@ -134,7 +134,7 @@ ei_new(void *user_data) { _cleanup_ei_ struct ei *ei = ei_create(NULL); - ei->state = EI_STATE_NEW; + ei->state = EI_STATE_BACKEND; list_init(&ei->event_queue); list_init(&ei->devices); @@ -669,7 +669,7 @@ connection_dispatch(struct source *source, void *userdata) idx += len; switch (ei->state) { - case EI_STATE_NEW: + case EI_STATE_BACKEND: rc = connection_new_handle_msg(ei, msg); break; case EI_STATE_CONNECTING: @@ -688,7 +688,7 @@ error: ei_disconnect(ei); static const char *states[] = { - "NEW", + "BACKEND", "CONNECTING", "CONNECTED", "DISCONNECTED", @@ -714,7 +714,7 @@ ei_set_connection(struct ei *ei, int fd) _public_ void ei_configure_name(struct ei *ei, const char *name) { - if (ei->state != EI_STATE_NEW) + if (ei->state != EI_STATE_BACKEND) return; if (strlen(name) > 1024) @@ -733,7 +733,7 @@ test_init_unref(const MunitParameter params[], void *user_data) /* need to alloc here so unref can free */ struct ei *ei = ei_new(NULL); - munit_assert_int(ei->state, ==, EI_STATE_NEW); + munit_assert_int(ei->state, ==, EI_STATE_BACKEND); munit_assert(list_empty(&ei->event_queue)); munit_assert(list_empty(&ei->devices)); @@ -773,7 +773,7 @@ test_configure_name(const MunitParameter params[], void *user_data) munit_assert_string_equal(ei.name, "bar"); /* ignore names in all other states */ - for (enum ei_state state = EI_STATE_NEW + 1; + for (enum ei_state state = EI_STATE_HELLO + 1; state <= EI_STATE_DISCONNECTED; state++) { ei.state = state;