From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:52580) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rxayz-0007Bn-7a for qemu-devel@nongnu.org; Wed, 15 Feb 2012 04:17:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rxayv-0004AC-6M for qemu-devel@nongnu.org; Wed, 15 Feb 2012 04:17:01 -0500 Received: from [222.73.24.84] (port=61302 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rxayu-0004A1-Na for qemu-devel@nongnu.org; Wed, 15 Feb 2012 04:16:57 -0500 Message-ID: <4F3B789B.5050504@cn.fujitsu.com> Date: Wed, 15 Feb 2012 17:19:23 +0800 From: Wen Congyang MIME-Version: 1.0 References: <4F333AAA.1070601@cn.fujitsu.com> <4F333CEC.7080007@cn.fujitsu.com> In-Reply-To: Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=UTF-8 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: Peter Maydell Cc: Jan Kiszka , qemu-devel , Luiz Capitulino , HATAYAMA Daisuke , Dave Anderson , Eric Blake At 02/15/2012 05:12 PM, Peter Maydell Wrote: > On 9 February 2012 03:26, Wen Congyang wrote: >> +int cpu_get_dump_info(ArchDumpInfo *info) >> +{ >> + bool lma = false; >> + RAMBlock *block; >> + >> +#ifdef TARGET_X86_64 >> + lma = !!(first_cpu->hflags & HF_LMA_MASK); >> +#endif >> + >> + if (lma) { >> + info->d_machine = EM_X86_64; >> + } else { >> + info->d_machine = EM_386; >> + } >> + info->d_endian = ELFDATA2LSB; >> + >> + if (lma) { >> + info->d_class = ELFCLASS64; >> + } else { >> + info->d_class = ELFCLASS32; >> + } >> + >> + QLIST_FOREACH(block, &ram_list.blocks, next) { >> + if (!lma && (block->offset + block->length > UINT_MAX)) { >> + /* The memory size is greater than 4G */ >> + info->d_class = ELFCLASS32; >> + break; >> + } >> + } > > 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. Nice. I will change it. Thanks Wen Congyang > > -- PMM >