[Libguestfs] [nbdkit PATCH v3 06/16] backend: Inline reset_context

Eric Blake eblake at redhat.com
Fri Mar 5 23:31:10 UTC 2021


Now that there is only one caller, we don't need it to live in
internal.h.
---
 server/internal.h | 18 ------------------
 server/backend.c  | 18 ++++++++++++++----
 2 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/server/internal.h b/server/internal.h
index 1add5f36..ff543200 100644
--- a/server/internal.h
+++ b/server/internal.h
@@ -225,24 +225,6 @@ struct context {
   int can_cache;
 };

-static inline void
-reset_context (struct context *h)
-{
-  h->handle = NULL;
-  h->state = 0;
-  h->exportsize = -1;
-  h->can_write = -1;
-  h->can_flush = -1;
-  h->is_rotational = -1;
-  h->can_trim = -1;
-  h->can_zero = -1;
-  h->can_fast_zero = -1;
-  h->can_fua = -1;
-  h->can_multi_conn = -1;
-  h->can_extents = -1;
-  h->can_cache = -1;
-}
-
 DEFINE_VECTOR_TYPE(string_vector, char *);
 struct connection {
   pthread_mutex_t request_lock;
diff --git a/server/backend.c b/server/backend.c
index cebd55ab..e89f0ab4 100644
--- a/server/backend.c
+++ b/server/backend.c
@@ -226,9 +226,20 @@ backend_open (struct backend *b, int readonly, const char *exportname)
                      b->name, readonly, exportname, conn->using_tls);

   assert (conn->contexts[b->i] == NULL);
-  reset_context (c);
-  if (readonly)
-    c->can_write = 0;
+  c->handle = NULL;
+  c->b = b;
+  c->state = 0;
+  c->exportsize = -1;
+  c->can_write = readonly ? 0 : -1;
+  c->can_flush = -1;
+  c->is_rotational = -1;
+  c->can_trim = -1;
+  c->can_zero = -1;
+  c->can_fast_zero = -1;
+  c->can_fua = -1;
+  c->can_multi_conn = -1;
+  c->can_extents = -1;
+  c->can_cache = -1;

   /* Determine the canonical name for default export */
   if (!*exportname) {
@@ -254,7 +265,6 @@ backend_open (struct backend *b, int readonly, const char *exportname)
   }

   c->state |= HANDLE_OPEN;
-  c->b = b;
   return c;
 }

-- 
2.30.1




More information about the Libguestfs mailing list