[Libguestfs] [libnbd PATCH v2 1/6] states: Tweak comment in OPT_GO state handler

Eric Blake eblake at redhat.com
Thu Sep 21 20:58:00 UTC 2023


While auditing code, I stumbled across a confusing comment which
references a state name that does not exist.  In addition to improving
the comment, I added an assertion, since there is action at a distance
(prepare_for_reply_payload is in states-newstyle.c) for ignoring the
oversized payload.

Signed-off-by: Eric Blake <eblake at redhat.com>
Reviewed-by: Richard W.M. Jones <rjones at redhat.com>
Reviewed-by: Laszlo Ersek <lersek at redhat.com>
---
 generator/states-newstyle-opt-go.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/generator/states-newstyle-opt-go.c b/generator/states-newstyle-opt-go.c
index 2ef440d4..5bc9a9ae 100644
--- a/generator/states-newstyle-opt-go.c
+++ b/generator/states-newstyle-opt-go.c
@@ -149,8 +149,11 @@  NEWSTYLE.OPT_GO.CHECK_REPLY:

   switch (reply) {
   case NBD_REP_INFO:
-    if (len > maxpayload /* see RECV_NEWSTYLE_OPT_GO_REPLY */)
+    if (len > maxpayload) {
+      /* See prepare_for_reply_payload, used in RECV_REPLY */
+      assert (h->rbuf == NULL);
       debug (h, "skipping large NBD_REP_INFO");
+    }
     else {
       uint16_t info;
       uint64_t exportsize;
-- 
2.41.0



More information about the Libguestfs mailing list