qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [Qemu-trivial] [PATCH] block: Remove unused assignment


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH] block: Remove unused assignment (fixes warning from clang)
Date: Mon, 30 Sep 2013 11:16:33 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Sun, Sep 29, 2013 at 10:15:10PM +0200, Stefan Weil wrote:
> Am 29.09.2013 21:44, schrieb Michael Tokarev:
> > 28.09.2013 13:55, Stefan Weil wrote:
> [...]
> >> diff --git a/blockdev.c b/blockdev.c
> >> index 8aa66a9..8c83f6f 100644
> >> --- a/blockdev.c
> >> +++ b/blockdev.c
> >> @@ -1926,7 +1926,6 @@ void qmp_drive_mirror(const char *device, const
> >> char *target,
> >>       } else {
> >>           switch (mode) {
> >>           case NEW_IMAGE_MODE_EXISTING:
> >> -            ret = 0;
> >>               break;
> >
> > While this one is obviously unused assignment,
> > there's on more usage of `ret' variable in this
> > function, -- it is to store the return value
> > from bdrv_open():
> >
> >     ret = bdrv_open(target_bs, target, NULL, flags |
> > BDRV_O_NO_BACKING, drv,
> >                     &local_err);
> >     if (ret < 0) {...
> >
> > What's the rule about converting that into if() ?
> >
> > Thanks,
> >
> > /mjt
> 
> Is there a rule for cases like that? This pattern is very common in QEMU
> code
> (several occurrences in blockdev.c). Should we eliminate the 'ret' variable?
> I don't think it's worth the effort.

Me neither.  There is a minor style difference between putting
everything into the if statement and using a variable to split up a
potentially complicated if statement.

Both approaches are usually okay.

Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]