On 01/04/2017 12:58 AM, Dou Liyang wrote: > the bdrv_query_stats and bdrv_query_bds_stats functions need to call > each other, that increases the coupling. it also makes the program > complicated and makes some unnecessary judgements. s/judgements/judgments/ - although I wonder if 'tests' would be a simpler word. > > remove the call from bdrv_query_bds_stats to bdrv_query_stats, just > take some recursion to make it clearly. > > avoid judging whether the blk is NULL during querying the bds stats. Again, 'testing' might read nicer than 'judging'. > it is unnecessary. > > Signed-off-by: Dou Liyang > --- > block/qapi.c | 26 ++++++++++++++------------ > 1 file changed, 14 insertions(+), 12 deletions(-) > > -static void bdrv_query_bds_stats(BlockStats *s, const BlockDriverState *bs, > +static BlockStats *bdrv_query_bds_stats(const BlockDriverState *bs, > bool query_backing) > { > + BlockStats *s = NULL; > + > + s = g_malloc0(sizeof(*s)); Dead initialization to NULL since the very next statement overwrites it. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org