Received: from eggs.gnu.org ([208.118.235.92]:33075) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdiFT-0002CY-Dd for qemu-devel@nongnu.org; Wed, 28 Nov 2012 09:04:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TdiFR-0003Cs-8f for qemu-devel@nongnu.org; Wed, 28 Nov 2012 09:04:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:29732) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdiFR-00039G-0w for qemu-devel@nongnu.org; Wed, 28 Nov 2012 09:04:21 -0500 Date: Wed, 28 Nov 2012 11:21:48 -0200 From: Eduardo Habkost Message-ID: <20121128132148.GA12995@otherpad.lan.raisama.net> References: <1352756342-13716-1-git-send-email-ehabkost@redhat.com> <1352756342-13716-6-git-send-email-ehabkost@redhat.com> <1354082881.655.5.camel@liguang.fnst.cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1354082881.655.5.camel@liguang.fnst.cn.fujitsu.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 05/17] target-i386: cpu_x86_init(): move error handling to end of function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: li guang Cc: Igor Mammedov , Don Slutz , qemu-devel@nongnu.org, Andreas =?iso-8859-1?Q?F=E4rber?= On Wed, Nov 28, 2012 at 02:08:01PM +0800, li guang wrote: > =E5=9C=A8 2012-11-12=E4=B8=80=E7=9A=84 19:38 -0200=EF=BC=8CEduardo Habk= ost=E5=86=99=E9=81=93=EF=BC=9A > > Doing error handling on a single place will make it easier to make su= re > > memory is freed, and that error information is properly printed or > > returned to the caller. > >=20 > > Signed-off-by: Eduardo Habkost > > --- > > target-i386/cpu.c | 13 ++++++++----- > > 1 file changed, 8 insertions(+), 5 deletions(-) > >=20 > > diff --git a/target-i386/cpu.c b/target-i386/cpu.c > > index 73b0fa1..69f1204 100644 > > --- a/target-i386/cpu.c > > +++ b/target-i386/cpu.c > > @@ -1506,17 +1506,20 @@ X86CPU *cpu_x86_init(const char *cpu_model) > > env->cpu_model_str =3D cpu_model; > > =20 > > if (cpu_x86_register(cpu, cpu_model) < 0) { > > - object_delete(OBJECT(cpu)); > > - return NULL; > > + goto error; > > } > > =20 > > x86_cpu_realize(OBJECT(cpu), &error); > > if (error) { > > - error_free(error); > > - object_delete(OBJECT(cpu)); > > - return NULL; > > + goto error; > > } > > return cpu; > > +error: >=20 > seems we should not use lable 'error' as it's=20 > the same name with variable 'error' Do you know any compiler that complains about that? I don't find this to be a problem at all. >=20 > hmm, maybe I should send a patch to clarify. > =20 >=20 > > + object_delete(OBJECT(cpu)); > > + if (error) { > > + error_free(error); > > + } > > + return NULL; > > } > > =20 > > #if !defined(CONFIG_USER_ONLY) >=20 > --=20 > regards! > li guang =20 > linux kernel team at FNST, china >=20 > thinking with brain but heart > living with heart but brain >=20 --=20 Eduardo