qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: Remove redundant assertion
@ 2013-08-27 15:56 Kevin Wolf
  2013-08-27 16:07 ` Stefan Weil
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Wolf @ 2013-08-27 15:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf

The failing condition is checked immediately before the assertion, so
keeping the assertion is kind of redundant.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/block.c b/block.c
index a387c1a..26639e8 100644
--- a/block.c
+++ b/block.c
@@ -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);
     }
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] block: Remove redundant assertion
  2013-08-27 15:56 [Qemu-devel] [PATCH] block: Remove redundant assertion Kevin Wolf
@ 2013-08-27 16:07 ` Stefan Weil
  2013-08-28  7:54   ` Kevin Wolf
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Weil @ 2013-08-27 16:07 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: qemu-devel

Am 27.08.2013 17:56, schrieb Kevin Wolf:
> 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

>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/block.c b/block.c
> index a387c1a..26639e8 100644
> --- a/block.c
> +++ b/block.c
> @@ -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);
>      }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] block: Remove redundant assertion
  2013-08-27 16:07 ` Stefan Weil
@ 2013-08-28  7:54   ` Kevin Wolf
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2013-08-28  7:54 UTC (permalink / raw)
  To: Stefan Weil; +Cc: qemu-devel

Am 27.08.2013 um 18:07 hat Stefan Weil geschrieben:
> Am 27.08.2013 17:56, schrieb Kevin Wolf:
> > 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

> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > ---
> >  block.c | 1 -
> >  1 file changed, 1 deletion(-)
> >
> > diff --git a/block.c b/block.c
> > index a387c1a..26639e8 100644
> > --- a/block.c
> > +++ b/block.c
> > @@ -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);
> >      }
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-08-28  7:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-27 15:56 [Qemu-devel] [PATCH] block: Remove redundant assertion Kevin Wolf
2013-08-27 16:07 ` Stefan Weil
2013-08-28  7:54   ` Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).