Benoît Canet <benoit.ca...@nodalink.com> writes: >> +DriveInfo *blk_legacy_dinfo(BlockBackend *blk) >> +{ >> + return blk->legacy_dinfo; >> +} >> + >> +/* >> + * Set @blk's DriveInfo to @dinfo, and return it. >> + * @blk must not have a DriveInfo set already. > >> + * No other BlockBackend may have the same DriveInfo set. > Must we try to assert this ? > This would require an extra linked list traversal but I don't think it's a > performance path anyway.
Must, no. We could. However, the obvious assert(!blk_by_legacy_dinfo(dinfo); doesn't work, because blk_by_legacy_dinfo() asserts it returns a non-null value. Either we sacrifice that assertion, or we duplicate the search loop here (yuck), or we factor it out into a helper function. I don't particularly like either of the three. But if you guys really want the precondition checked, I'll check it. > Reviewed-by: Benoît Canet <benoit.ca...@nodalink.com> Thanks!