block: Remove redundant assertion
PATCH 1/1 block: Remove redundant assertion
The failing condition is checked immediately before the assertion, so keeping the assertion is kind of redundant.
--- block.c | 1 - 1 file changed, 1 deletion(-)
block.c +0 -1
@@ -743,7 +743,6 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file, ret = -EINVAL ; goto free_and_fail; } -assert (file !=NULL ); bs->file = file; ret = drv->bdrv_open (bs, options, open_flags); }
Signature · 1 line
1.8.1.4
Am 27.08.2013 17:56, schrieb Kevin Wolf:
Quoted 2 lines
The failing condition is checked immediately before the assertion, so keeping the assertion is kind of redundant.
Are you sure that it is not the check which is redundant? Is file == NULL allowed in this 'else' branch?
Regards,
Stefan
Quoted 18 lines
Signed-off-by Kevin Wolf <[email protected]>--- block.c | 1 - 1 file changed, 1 deletion(-)block.c +0
-1@@ -743,7 +743,6 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file, ret = -EINVAL ; goto free_and_fail; } -assert (file !=NULL ); bs->file = file; ret = drv->bdrv_open (bs, options, open_flags); }
Am 27.08.2013 um 18:07 hat Stefan Weil geschrieben:
Quoted 6 lines
Am 27.08.2013 17:56, schrieb Kevin Wolf:
Quoted 2 lines
The failing condition is checked immediately before the assertion, so keeping the assertion is kind of redundant.
Are you sure that it is not the check which is redundant? Is file == NULL allowed in this 'else' branch?
Allowed in the sense of it's possible to get there, yes. The check that errors out on the condition isn't dead code after reverting 8afaefb8 (which enables the recent work towards blockdev-add):
$ x86_64-softmmu/qemu-system-x86_64 -drive file.driver=qcow2,file=/tmp/test.qcow2 qemu-system-x86_64: -drive file.driver=qcow2,file=/tmp/test.qcow2: Can't use 'qcow2' as a block driver for the protocol level qemu-system-x86_64: -drive file.driver=qcow2,file=/tmp/test.qcow2: could not open disk image /tmp/test.qcow2: Invalid argument
Kevin
Quoted 18 lines
Quoted 17 lines
Signed-off-by Kevin Wolf <[email protected]>--- block.c | 1 - 1 file changed, 1 deletion(-)block.c +0
-1@@ -743,7 +743,6 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file, ret = -EINVAL ; goto free_and_fail; } -assert (file !=NULL ); bs->file = file; ret = drv->bdrv_open (bs, options, open_flags); }