Skip to contentSkip to conversation

qemu-nbd: drop loop which can never loop

PATCH Applied Stefan Hajnoczi 3 participants 4 messages Jan 5, 2012 – Jan 6, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu-nbd: drop loop which can never loop

For some reason nbd_client_thread() has a do..while loop which can never loop, the condition is bogus because we would take a goto instead. Drop the loop.

---
 qemu-nbd.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
qemu-nbd.c +4 -6
index 155b058..eb61c33 100644
@@ -202,12 +202,10 @@ static void *nbd_client_thread(void *arg)
     int ret;
     pthread_t show_parts_thread;
 
-    do {
-        sock = unix_socket_outgoing(sockpath);
-        if (sock == -1) {
-            goto out;
-        }
-    } while (sock == -1);
+    sock = unix_socket_outgoing(sockpath);
+    if (sock == -1) {
+        goto out;
+    }
 
     ret = nbd_receive_negotiate(sock, NULL, &nbdflags,
                                 &size, &blocksize);
Signature · 1 line
1.7.7.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 21 lines · Stefan Hajnoczi

For some reason nbd_client_thread() has a do..while loop which can never loop, the condition is bogus because we would take a goto instead. Drop the loop.

---
  qemu-nbd.c |   10 ++++------
  1 files changed, 4 insertions(+), 6 deletions(-)
qemu-nbd.c +0 -3
index 155b058..eb61c33 100644
@@ -202,12 +202,10 @@ static void *nbd_client_thread(void *arg)
      int ret;
      pthread_t show_parts_thread;
 
-    do {
-        sock = unix_socket_outgoing(sockpath);
-        if (sock == -1) {

qemu-nbd.c static void *nbd_client_thread(void *arg) · line 211

Quoted 10 lines
qemu-nbd.c +4 -3
-            goto out;
-        }
-    } while (sock == -1);
+    sock = unix_socket_outgoing(sockpath);
+    if (sock == -1) {
+        goto out;
+    }
 
      ret = nbd_receive_negotiate(sock, NULL,&nbdflags,
                                  &size,&blocksize);

It used to loop until commit f1ef555. When I simplified the loop I failed to actually remove it.

I suppose it will get in through your trivial patches tree, won't it?

Paolo

#2 lore raw
Quoted 1 line · Paolo Bonzini

I suppose it will get in through your trivial patches tree, won't it?

Yes

#3 lore raw
In reply to Stefan Hajnoczi
Quoted 9 lines · Stefan Hajnoczi

For some reason nbd_client_thread() has a do..while loop which can never loop, the condition is bogus because we would take a goto instead. Drop the loop.

---
 qemu-nbd.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

Applied to the trivial patches -next tree:
https://github.com/stefanha/qemu/commits/trivial-patches-next

Stefan