qemu-block
[Top][All Lists]
Advanced

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

Re: [Qemu-block] [PULL 21/31] block: Avoid bs->blk in bdrv_next()


From: Kevin Wolf
Subject: Re: [Qemu-block] [PULL 21/31] block: Avoid bs->blk in bdrv_next()
Date: Fri, 20 May 2016 12:26:22 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

Am 20.05.2016 um 11:39 hat Paolo Bonzini geschrieben:
> 
> 
> On 20/05/2016 10:10, Kevin Wolf wrote:
> >> > Already posted a fix. I chose to keep the interface and free the
> >> > BdrvNextIterator inside bdrv_next(), when we return NULL after the last
> >> > element.
> > Oops, should have actually read your email... You're right about callers
> > that prematurely exit the loop, of course.
> > 
> > I still don't really like first/next interfaces, though. Perhaps start
> > the iteration with bs == NULL instead of it == NULL?
> 
> Yet another alternative is to add a BDRV_NEXT_ITERATOR_INITIALIZER
> macro.  I like it because it's less magic than "x is NULL" and because I
> would prefer an interface with just the BdrvNextIterator* as the
> argument to bdrv_next.

Hm, we have a few instances where an iterator variable is used for
multiple loops, so we need to be able to use it in an assignment, i.e.
it should be a compound literal. On the other hand, I seem to remember
that compound literals can't be used as initialisers.

Maybe a bdrv_next_iterator_reset() function then? Which would be like
first/next, except that it doesn't return the first value yet.

Kevin



reply via email to

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