On 09/02/2015 02:51 AM, Wen Congyang wrote: > Signed-off-by: Wen Congyang <we...@cn.fujitsu.com> > --- > block.c | 4 ++-- > block/block-backend.c | 9 +++++++++ > include/sysemu/block-backend.h | 1 + > 3 files changed, 12 insertions(+), 2 deletions(-) >
> /* > + * Return true if a device model is attached to @blk already, > + * otherwise, return false. > + */ > +bool blk_is_attached(BlockBackend *blk) > +{ > + return blk != NULL && blk->dev != NULL && blk->dev != (void *)-1; Again, I don't like the raw magic constant, even if we go with this patch. And it is shorter to write: return blk && blk->dev && blk->dev != MAGIC; But I think it is better to just allow for a NULL BDS to represent an unattached media (in which case Max's patches may already cover what you are trying to do here), rather than trying to overload a special value different from NULL. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature