From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:42518) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rxauz-00063P-BE for qemu-devel@nongnu.org; Wed, 15 Feb 2012 04:12:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rxauv-0003CM-Em for qemu-devel@nongnu.org; Wed, 15 Feb 2012 04:12:53 -0500 Received: from mail-qw0-f45.google.com ([209.85.216.45]:65020) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rxauv-0003CG-9h for qemu-devel@nongnu.org; Wed, 15 Feb 2012 04:12:49 -0500 Received: by qabg40 with SMTP id g40so2727289qab.4 for ; Wed, 15 Feb 2012 01:12:48 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <4F333CEC.7080007@cn.fujitsu.com> References: <4F333AAA.1070601@cn.fujitsu.com> <4F333CEC.7080007@cn.fujitsu.com> Date: Wed, 15 Feb 2012 09:12:48 +0000 Message-ID: From: Peter Maydell Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC][PATCH 08/16 v6] target-i386: add API to get dump info List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wen Congyang Cc: Jan Kiszka , qemu-devel , Luiz Capitulino , HATAYAMA Daisuke , Dave Anderson , Eric Blake On 9 February 2012 03:26, Wen Congyang wrote: > +int cpu_get_dump_info(ArchDumpInfo *info) > +{ > + =C2=A0 =C2=A0bool lma =3D false; > + =C2=A0 =C2=A0RAMBlock *block; > + > +#ifdef TARGET_X86_64 > + =C2=A0 =C2=A0lma =3D !!(first_cpu->hflags & HF_LMA_MASK); > +#endif > + > + =C2=A0 =C2=A0if (lma) { > + =C2=A0 =C2=A0 =C2=A0 =C2=A0info->d_machine =3D EM_X86_64; > + =C2=A0 =C2=A0} else { > + =C2=A0 =C2=A0 =C2=A0 =C2=A0info->d_machine =3D EM_386; > + =C2=A0 =C2=A0} > + =C2=A0 =C2=A0info->d_endian =3D ELFDATA2LSB; > + > + =C2=A0 =C2=A0if (lma) { > + =C2=A0 =C2=A0 =C2=A0 =C2=A0info->d_class =3D ELFCLASS64; > + =C2=A0 =C2=A0} else { > + =C2=A0 =C2=A0 =C2=A0 =C2=A0info->d_class =3D ELFCLASS32; > + =C2=A0 =C2=A0} > + > + =C2=A0 =C2=A0QLIST_FOREACH(block, &ram_list.blocks, next) { > + =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!lma && (block->offset + block->length >= UINT_MAX)) { > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* The memory size is greater = than 4G */ > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0info->d_class =3D ELFCLASS32; > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0break; > + =C2=A0 =C2=A0 =C2=A0 =C2=A0} > + =C2=A0 =C2=A0} I think it would be cleaner to have a single if (lma) { stuff; } else { stuff; } rather than checking it three times, especially for the loop, where if lma is true we'll walk the ram_list without ever doing anything. -- PMM