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. Thanks, Paolo