From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=47902 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PR4rf-0001c1-GG for qemu-devel@nongnu.org; Fri, 10 Dec 2010 10:26:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PR4re-00022S-8l for qemu-devel@nongnu.org; Fri, 10 Dec 2010 10:26:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51751) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PR4re-00020n-1M for qemu-devel@nongnu.org; Fri, 10 Dec 2010 10:26:30 -0500 From: Amit Shah Date: Fri, 10 Dec 2010 20:55:52 +0530 Message-Id: <06778303820b5ae1b44b82d35ac5a0709f8e7578.1291994656.git.amit.shah@redhat.com> In-Reply-To: References: In-Reply-To: References: Subject: [Qemu-devel] [PATCH v2 3/4] virtio-serial: Simplify condition for a while loop List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu list Cc: Amit Shah , Paul Brook 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 --- hw/virtio-serial-bus.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) 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; -- 1.7.3.2