Skip to contentSkip to conversation

qcow2: insert assert into qcow2_get_specific_info()

PATCH Applied Denis V. Lunev 3 participants 3 messages Dec 10, 2015 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qcow2: insert assert into qcow2_get_specific_info()

s->qcow_version is always set to 2 or 3. Let's assert if this is wrong.

CC Roman Kagan <[email protected]>
CC Max Reitz <[email protected]>
CC Kevin Wolf <[email protected]>
---
 block/qcow2.c | 4 ++++
 1 file changed, 4 insertions(+)
block/qcow2.c +4 -0
index 88f56c8..b285014 100644
@@ -2757,6 +2757,10 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs)
             .has_corrupt        = true,
             .refcount_bits      = s->refcount_bits,
         };
+    } else {
+        /* if this assertion fails, this probably means a new version was
+         * added without having it covered here */
+        assert(false);
     }
 
     return spec_info;
Signature · 1 line
2.1.4
Reviewed-by on v1 1/1
#1 lore raw

[adding qemu-block in cc, per MAINTAINERS]

Quoted 15 lines · Denis V. Lunev

s->qcow_version is always set to 2 or 3. Let's assert if this is wrong.

CC Roman Kagan <[email protected]>
CC Max Reitz <[email protected]>
CC Kevin Wolf <[email protected]>
---
 block/qcow2.c | 4 ++++
 1 file changed, 4 insertions(+)
block/qcow2.c +0 -0
index 88f56c8..b285014 100644

block/qcow2.c static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs) · line 2763

Quoted 7 lines
block/qcow2.c +4 -0
@@ -2757,6 +2757,10 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs)
             .has_corrupt        = true,
             .refcount_bits      = s->refcount_bits,
         };
+    } else {
+        /* if this assertion fails, this probably means a new version was
+         * added without having it covered here */
+        assert(false);

Only covers us if we don't turn on NDEBUG during compile; but then again, lots of spots in the code base assume assert() will never be crippled.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org