Skip to contentSkip to conversation

block: Assert BlockDriver::format_name is not NULL

PATCH-for-5.0 Applied Philippe Mathieu-Daudé 3 participants 3 messages Mar 18, 2020 – Mar 23, 2020

lore
Share & tools
lore
#0 lore raw

bdrv_do_find_format() calls strcmp() using BlockDriver::format_name as argument, which must not be NULL. Assert this field is not null when we register a block driver in bdrv_register().

---
 block.c | 1 +
 1 file changed, 1 insertion(+)
block.c +1 -0
index a2542c977b..6b984dc883 100644
@@ -363,6 +363,7 @@ char *bdrv_get_full_backing_filename(BlockDriverState *bs, Error **errp)
 
 void bdrv_register(BlockDriver *bdrv)
 {
+    assert(bdrv->format_name);
     QLIST_INSERT_HEAD(&bdrv_drivers, bdrv, list);
 }
 
Signature · 1 line
2.21.1
Applied
#2 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 9 lines · Philippe Mathieu-Daudé

bdrv_do_find_format() calls strcmp() using BlockDriver::format_name as argument, which must not be NULL. Assert this field is not null when we register a block driver in bdrv_register().

---
 block.c | 1 +
 1 file changed, 1 insertion(+)

Thanks, applied to my block branch:

https://git.xanclic.moe/XanClic/qemu/commits/branch/block

Max