Patchwork [V6,03/14] block: return bool for bdrv_can_snapshot()

login
register
mail settings
Submitter Wayne Xia
Date Feb. 18, 2013, 2:09 p.m.
Message ID <1361196578-19016-4-git-send-email-xiawenc@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/221388/
State New
Headers show

Comments

Wayne Xia - Feb. 18, 2013, 2:09 p.m.
This function should return bool instead of int, just as
bdrv_can_read_snapshot().

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
 block.c               |    8 ++++----
 include/block/block.h |    2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)
Eric Blake - Feb. 19, 2013, 8:48 p.m.
On 02/18/2013 07:09 AM, Wenchao Xia wrote:
>   This function should return bool instead of int, just as
> bdrv_can_read_snapshot().
> 
> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> ---
>  block.c               |    8 ++++----
>  include/block/block.h |    2 +-
>  2 files changed, 5 insertions(+), 5 deletions(-)

I checked that all existing callers only used the function in a boolean
context.

Reviewed-by: Eric Blake <eblake@redhat.com>

Patch

diff --git a/block.c b/block.c
index 19c2d7b..0ed8190 100644
--- a/block.c
+++ b/block.c
@@ -3077,21 +3077,21 @@  bool bdrv_can_read_snapshot(BlockDriverState *bs)
 }
 
 /* return whether internal snapshot can be write on @bs */
-int bdrv_can_snapshot(BlockDriverState *bs)
+bool bdrv_can_snapshot(BlockDriverState *bs)
 {
     BlockDriver *drv = bs->drv;
     if (!drv || !bdrv_is_inserted(bs) || bdrv_is_read_only(bs)) {
-        return 0;
+        return false;
     }
 
     if (!drv->bdrv_snapshot_create) {
         if (bs->file != NULL) {
             return bdrv_can_snapshot(bs->file);
         }
-        return 0;
+        return false;
     }
 
-    return 1;
+    return true;
 }
 
 int bdrv_is_snapshot(BlockDriverState *bs)
diff --git a/include/block/block.h b/include/block/block.h
index 4c48052..2dabb87 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -322,7 +322,7 @@  void bdrv_get_full_backing_filename(BlockDriverState *bs,
 BlockInfo *bdrv_query_info(BlockDriverState *s);
 BlockStats *bdrv_query_stats(const BlockDriverState *bs);
 bool bdrv_can_read_snapshot(BlockDriverState *bs);
-int bdrv_can_snapshot(BlockDriverState *bs);
+bool bdrv_can_snapshot(BlockDriverState *bs);
 int bdrv_is_snapshot(BlockDriverState *bs);
 BlockDriverState *bdrv_snapshots(void);
 int bdrv_snapshot_create(BlockDriverState *bs,