qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Peter Crosthwaite <peter.crosthwaite@xilinx.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PULL 1/6] block: m25p80: sync_page(): Deindent function body.
Date: Mon, 23 Jun 2014 17:31:14 +0800	[thread overview]
Message-ID: <1403515879-14359-2-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1403515879-14359-1-git-send-email-stefanha@redhat.com>

From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>

sync_page() was conditionalizing it's whole fn body on the bdrv being
non-null. Just return for the function immediately on NULL brdv and
get rid of the big if.

Makes implementation consistent with flash_zynq_area().

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/block/m25p80.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index 4076114..e4ef733 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -288,18 +288,20 @@ static void bdrv_sync_complete(void *opaque, int ret)
 
 static void flash_sync_page(Flash *s, int page)
 {
-    if (s->bdrv) {
-        int bdrv_sector, nb_sectors;
-        QEMUIOVector iov;
-
-        bdrv_sector = (page * s->pi->page_size) / BDRV_SECTOR_SIZE;
-        nb_sectors = DIV_ROUND_UP(s->pi->page_size, BDRV_SECTOR_SIZE);
-        qemu_iovec_init(&iov, 1);
-        qemu_iovec_add(&iov, s->storage + bdrv_sector * BDRV_SECTOR_SIZE,
-                                                nb_sectors * BDRV_SECTOR_SIZE);
-        bdrv_aio_writev(s->bdrv, bdrv_sector, &iov, nb_sectors,
-                                                bdrv_sync_complete, NULL);
+    int bdrv_sector, nb_sectors;
+    QEMUIOVector iov;
+
+    if (!s->bdrv) {
+        return;
     }
+
+    bdrv_sector = (page * s->pi->page_size) / BDRV_SECTOR_SIZE;
+    nb_sectors = DIV_ROUND_UP(s->pi->page_size, BDRV_SECTOR_SIZE);
+    qemu_iovec_init(&iov, 1);
+    qemu_iovec_add(&iov, s->storage + bdrv_sector * BDRV_SECTOR_SIZE,
+                   nb_sectors * BDRV_SECTOR_SIZE);
+    bdrv_aio_writev(s->bdrv, bdrv_sector, &iov, nb_sectors, bdrv_sync_complete,
+                    NULL);
 }
 
 static inline void flash_sync_area(Flash *s, int64_t off, int64_t len)
-- 
1.9.3

  reply	other threads:[~2014-06-23  9:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-23  9:31 [Qemu-devel] [PULL 0/6] Block patches Stefan Hajnoczi
2014-06-23  9:31 ` Stefan Hajnoczi [this message]
2014-06-23  9:31 ` [Qemu-devel] [PULL 2/6] block: m25p80: Support read only bdrvs Stefan Hajnoczi
2014-06-23  9:31 ` [Qemu-devel] [PULL 3/6] QemuOpts: check NULL opts in qemu_opt_get functions Stefan Hajnoczi
2014-06-23  9:31 ` [Qemu-devel] [PULL 4/6] sheepdog: fix NULL dereference in sd_create Stefan Hajnoczi
2014-06-23  9:31 ` [Qemu-devel] [PULL 5/6] vl: allow other threads to do qemu_system_vmstop_request Stefan Hajnoczi
2014-06-23  9:31 ` [Qemu-devel] [PULL 6/6] block: asynchronously stop the VM on I/O errors Stefan Hajnoczi
2014-06-23 12:18 ` [Qemu-devel] [PULL 0/6] Block patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1403515879-14359-2-git-send-email-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).