qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3 2/3] raw-posix: raw_co_get_block_status() ret


From: Max Reitz
Subject: Re: [Qemu-devel] [PATCH v3 2/3] raw-posix: raw_co_get_block_status() return value
Date: Thu, 23 Oct 2014 09:29:36 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

On 2014-10-22 at 19:00, Eric Blake wrote:
On 10/22/2014 09:57 AM, Max Reitz wrote:
Instead of generating the full return value thrice in try_fiemap(),
try_seek_hole() and as a fall-back in raw_co_get_block_status() itself,
generate the value only in raw_co_get_block_status().

While at it, also remove the pnum parameter from try_fiemap() and
try_seek_hole().

Suggested-by: Kevin Wolf <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
---
  block/raw-posix.c | 28 ++++++++++++++--------------
  1 file changed, 14 insertions(+), 14 deletions(-)
Reviewed-by: Eric Blake <address@hidden>

-    ret = try_seek_hole(bs, start, &data, &hole, pnum);
+    ret = try_seek_hole(bs, start, &data, &hole);
      if (ret < 0) {
-        ret = try_fiemap(bs, start, &data, &hole, nb_sectors, pnum);
+        ret = try_fiemap(bs, start, &data, &hole, nb_sectors);
          if (ret < 0) {
              /* Assume everything is allocated. */
              data = 0;
              hole = start + nb_sectors * BDRV_SECTOR_SIZE;
-            ret = BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | start;
+            ret = 0;
          }
      }
+ assert(ret >= 0);
I'm not sure the assertion adds much (the lines above are fairly easy to
reason about ret always being set), but it does protect against later
code addition, so I'm not opposed to leaving it.

I just liked it there to make clear that the previous code always goes into a fallback, so while some parts of it may throw errors, after everything is done, we're fine. The compiler will hopefully optimize it out anyway.

Max



reply via email to

[Prev in Thread] Current Thread [Next in Thread]