From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44324) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VljUQ-0008JH-RS for qemu-devel@nongnu.org; Wed, 27 Nov 2013 13:05:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VljUK-0003JQ-Kv for qemu-devel@nongnu.org; Wed, 27 Nov 2013 13:05:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37750) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VljUK-0003J5-B9 for qemu-devel@nongnu.org; Wed, 27 Nov 2013 13:05:24 -0500 Message-ID: <5296345E.1020202@redhat.com> Date: Wed, 27 Nov 2013 19:05:18 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1373927181-24247-1-git-send-email-imammedo@redhat.com> <1373927181-24247-3-git-send-email-imammedo@redhat.com> <5296322D.1030800@suse.de> In-Reply-To: <5296322D.1030800@suse.de> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 02/20] target-i386: convert 'hv_spinlocks' to static property List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?ISO-8859-15?Q?Andreas_F=E4rber?= Cc: Igor Mammedov , Anthony Liguori , Vadim Rozenfeld , qemu-devel@nongnu.org, Eduardo Habkost Il 27/11/2013 18:55, Andreas F=E4rber ha scritto: > Am 16.07.2013 00:25, schrieb Igor Mammedov: >> Signed-off-by: Igor Mammedov >> --- >> v2: >> - rebase on top of hyperv_spinlock_attempts in X86CPU >> --- >> target-i386/cpu.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++= +- >> 1 file changed, 47 insertions(+), 1 deletion(-) >> >> diff --git a/target-i386/cpu.c b/target-i386/cpu.c >> index 14e9c7e..00c2882 100644 >> --- a/target-i386/cpu.c >> +++ b/target-i386/cpu.c >> @@ -1473,6 +1473,49 @@ static void x86_cpu_get_feature_words(Object *o= bj, Visitor *v, void *opaque, >> error_propagate(errp, err); >> } >> =20 >> +static void x86_get_hv_spinlocks(Object *obj, Visitor *v, void *opaqu= e, >> + const char *name, Error **errp) >> +{ >> + X86CPU *cpu =3D X86_CPU(obj); >> + int64_t value =3D cpu->hyperv_spinlock_attempts; >> + >> + visit_type_int(v, &value, name, errp); >> +} >> + >> +static void x86_set_hv_spinlocks(Object *obj, Visitor *v, void *opaqu= e, >> + const char *name, Error **errp) >> +{ >> + const int64_t min =3D 0xFFF; >> + const int64_t max =3D UINT_MAX; >> + X86CPU *cpu =3D X86_CPU(obj); >> + int64_t value; >> + >> + visit_type_int(v, &value, name, errp); >> + if (error_is_set(errp)) { >> + return; >> + } >=20 > errp may be NULL. And if an Error gets raised here but not set to *errp > for lack of pointer, value might be uninitialized: > object_property_parse(obj, "not-a-number", "hv-spinlocks", NULL); > So we cannot rely on error_is_set(errp) but must use a local variable t= o > enforce any return. Fixed on qom-cpu-next as follows: >=20 > diff --git a/target-i386/cpu.c b/target-i386/cpu.c > index 435b3b9..0a5a4f0 100644 > --- a/target-i386/cpu.c > +++ b/target-i386/cpu.c > @@ -1611,10 +1611,12 @@ static void x86_set_hv_spinlocks(Object *obj, > Visitor *v, void *opaque, > const int64_t min =3D 0xFFF; > const int64_t max =3D UINT_MAX; > X86CPU *cpu =3D X86_CPU(obj); > + Error *err =3D NULL; > int64_t value; >=20 > - visit_type_int(v, &value, name, errp); > - if (error_is_set(errp)) { > + visit_type_int(v, &value, name, &err); > + if (err) { > + error_propagate(errp, err); > return; > } Reviewed-by: Paolo Bonzini