From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2JpF-000240-Pd for qemu-devel@nongnu.org; Thu, 25 Jul 2013 07:35:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V2JpE-0006aB-F1 for qemu-devel@nongnu.org; Thu, 25 Jul 2013 07:35:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26500) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2JpE-0006a3-68 for qemu-devel@nongnu.org; Thu, 25 Jul 2013 07:35:16 -0400 Date: Thu, 25 Jul 2013 13:35:07 +0200 From: Igor Mammedov Message-ID: <20130725133507.51714c4c@nial.usersys.redhat.com> In-Reply-To: <20130725064136.GC2651@G08FNSTD100614.fnst.cn.fujitsu.com> References: <1374596592-7027-1-git-send-email-imammedo@redhat.com> <1374596592-7027-5-git-send-email-imammedo@redhat.com> <20130725064136.GC2651@G08FNSTD100614.fnst.cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 04/16] qapi: make visit_type_size fallback to type_int List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Hu Tao Cc: vasilis.liaskovitis@profitbricks.com, pbonzini@redhat.com, qemu-devel@nongnu.org On Thu, 25 Jul 2013 14:41:36 +0800 Hu Tao wrote: > On Tue, Jul 23, 2013 at 06:23:00PM +0200, Igor Mammedov wrote: > > From: Vasilis Liaskovitis > > > > Currently visit_type_size checks if the visitor's type_size function pointer is > > NULL. If not, it calls it, otherwise it calls v->type_uint64(). But neither of > > these pointers are ever set. Fallback to calling v->type_int() in this third > > (default) case. > > > > Signed-off-by: Vasilis Liaskovitis > > Signed-off-by: Hu Tao > > Signed-off-by: Igor Mammedov > > --- > > qapi/qapi-visit-core.c | 11 ++++++++++- > > 1 files changed, 10 insertions(+), 1 deletions(-) > > > > diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c > > index 401ee6e..fcacaff 100644 > > --- a/qapi/qapi-visit-core.c > > +++ b/qapi/qapi-visit-core.c > > @@ -238,8 +238,17 @@ void visit_type_int64(Visitor *v, int64_t *obj, const char *name, Error **errp) > > > > void visit_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp) > > { > > + int64_t value; > > if (!error_is_set(errp)) { > > - (v->type_size ? v->type_size : v->type_uint64)(v, obj, name, errp); > > + if (v->type_size) { > > + v->type_size(v, obj, name, errp); > > + } else if (v->type_uint64) { > > + v->type_uint64(v, obj, name, errp); > > + } else { > > + value = *obj; > > + v->type_int(v, &value, name, errp); > > + *obj = value; > > + } > > } > > } > > This doesn't address comment from Michael Roth, quoted below: > > --- > I'd recommend just doing: > > if (v->type_size) { > v->type_size(v, obj, name, errp); > } else { > visit_type_uint64(v, obj, name, errp); > } > > visit_type_uint64() already handles the fallback to visit_type_int() so no > need to duplicate. > --- > I guess we can just drop this patch.