On 9 February 2012 03:26, Wen Congyang <we...@cn.fujitsu.com> 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. -- PMM