Simple code motion.
---
lib/Makefile.am | 1 +
lib/aio.c | 78 -----------------------------------
lib/is-state.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 106 insertions(+), 78 deletions(-)
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 312545e..72d2d0b 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -42,6 +42,7 @@ libnbd_la_SOURCES = \
flags.c \
handle.c \
internal.h \
+ is-state.c \
nbd-protocol.h \
poll.c \
protocol.c \
diff --git a/lib/aio.c b/lib/aio.c
index a129af2..38e0318 100644
--- a/lib/aio.c
+++ b/lib/aio.c
@@ -48,84 +48,6 @@ nbd_unlocked_aio_notify_write (struct nbd_handle *h)
return nbd_internal_run (h, notify_write);
}
-/* NB: is_locked = false, may_set_error = false. */
-int
-nbd_unlocked_aio_is_created (struct nbd_handle *h)
-{
- return h->state == STATE_START;
-}
-
-static int
-is_connecting_group (enum state_group group)
-{
- switch (group) {
- case GROUP_TOP:
- return 0;
- case GROUP_CONNECT:
- case GROUP_CONNECT_TCP:
- case GROUP_CONNECT_COMMAND:
- case GROUP_MAGIC:
- case GROUP_OLDSTYLE:
- case GROUP_NEWSTYLE:
- return 1;
- default:
- return is_connecting_group (nbd_internal_state_group_parent (group));
- }
-}
-
-/* NB: is_locked = false, may_set_error = false. */
-int
-nbd_unlocked_aio_is_connecting (struct nbd_handle *h)
-{
- enum state_group group = nbd_internal_state_group (h->state);
-
- return is_connecting_group (group);
-}
-
-/* NB: is_locked = false, may_set_error = false. */
-int
-nbd_unlocked_aio_is_ready (struct nbd_handle *h)
-{
- return h->state == STATE_READY;
-}
-
-static int
-is_processing_group (enum state_group group)
-{
- switch (group) {
- case GROUP_TOP:
- return 0;
- case GROUP_ISSUE_COMMAND:
- case GROUP_REPLY:
- return 1;
- default:
- return is_processing_group (nbd_internal_state_group_parent (group));
- }
-}
-
-/* NB: is_locked = false, may_set_error = false. */
-int
-nbd_unlocked_aio_is_processing (struct nbd_handle *h)
-{
- enum state_group group = nbd_internal_state_group (h->state);
-
- return is_processing_group (group);
-}
-
-/* NB: is_locked = false, may_set_error = false. */
-int
-nbd_unlocked_aio_is_dead (struct nbd_handle *h)
-{
- return h->state == STATE_DEAD;
-}
-
-/* NB: is_locked = false, may_set_error = false. */
-int
-nbd_unlocked_aio_is_closed (struct nbd_handle *h)
-{
- return h->state == STATE_CLOSED;
-}
-
int
nbd_unlocked_aio_command_completed (struct nbd_handle *h,
int64_t handle)
diff --git a/lib/is-state.c b/lib/is-state.c
new file mode 100644
index 0000000..5ed2ee9
--- /dev/null
+++ b/lib/is-state.c
@@ -0,0 +1,105 @@
+/* NBD client library in userspace
+ * Copyright (C) 2013-2019 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <errno.h>
+#include <inttypes.h>
+
+#include "internal.h"
+
+/* NB: is_locked = false, may_set_error = false. */
+int
+nbd_unlocked_aio_is_created (struct nbd_handle *h)
+{
+ return h->state == STATE_START;
+}
+
+static int
+is_connecting_group (enum state_group group)
+{
+ switch (group) {
+ case GROUP_TOP:
+ return 0;
+ case GROUP_CONNECT:
+ case GROUP_CONNECT_TCP:
+ case GROUP_CONNECT_COMMAND:
+ case GROUP_MAGIC:
+ case GROUP_OLDSTYLE:
+ case GROUP_NEWSTYLE:
+ return 1;
+ default:
+ return is_connecting_group (nbd_internal_state_group_parent (group));
+ }
+}
+
+/* NB: is_locked = false, may_set_error = false. */
+int
+nbd_unlocked_aio_is_connecting (struct nbd_handle *h)
+{
+ enum state_group group = nbd_internal_state_group (h->state);
+
+ return is_connecting_group (group);
+}
+
+/* NB: is_locked = false, may_set_error = false. */
+int
+nbd_unlocked_aio_is_ready (struct nbd_handle *h)
+{
+ return h->state == STATE_READY;
+}
+
+static int
+is_processing_group (enum state_group group)
+{
+ switch (group) {
+ case GROUP_TOP:
+ return 0;
+ case GROUP_ISSUE_COMMAND:
+ case GROUP_REPLY:
+ return 1;
+ default:
+ return is_processing_group (nbd_internal_state_group_parent (group));
+ }
+}
+
+/* NB: is_locked = false, may_set_error = false. */
+int
+nbd_unlocked_aio_is_processing (struct nbd_handle *h)
+{
+ enum state_group group = nbd_internal_state_group (h->state);
+
+ return is_processing_group (group);
+}
+
+/* NB: is_locked = false, may_set_error = false. */
+int
+nbd_unlocked_aio_is_dead (struct nbd_handle *h)
+{
+ return h->state == STATE_DEAD;
+}
+
+/* NB: is_locked = false, may_set_error = false. */
+int
+nbd_unlocked_aio_is_closed (struct nbd_handle *h)
+{
+ return h->state == STATE_CLOSED;
+}
--
2.21.0