Patchwork [v2,3/4] virtio-serial: Simplify condition for a while loop

login
register
mail settings
Submitter Amit Shah
Date Dec. 10, 2010, 3:25 p.m.
Message ID <06778303820b5ae1b44b82d35ac5a0709f8e7578.1291994656.git.amit.shah@redhat.com>
Download mbox | patch
Permalink /patch/75112/
State New
Headers show

Comments

Amit Shah - Dec. 10, 2010, 3:25 p.m.
Separate out a non-changing condition over the period of a loop into an
if statement before the loop.  This will be used later to re-work the
loop.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 hw/virtio-serial-bus.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

Patch

diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 74ba5ec..ecf0056 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -121,7 +121,10 @@  static void do_flush_queued_data(VirtIOSerialPort *port, VirtQueue *vq,
     assert(port || discard);
     assert(virtio_queue_ready(vq));
 
-    while ((discard || !port->throttled) && virtqueue_pop(vq, &elem)) {
+    if (!discard && port->throttled) {
+        return;
+    }
+    while (virtqueue_pop(vq, &elem)) {
         uint8_t *buf;
         size_t ret, buf_size;