From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8Qp5-0005oa-Cp for qemu-devel@nongnu.org; Fri, 16 Mar 2012 02:39:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S8Qp3-0003xq-Fb for qemu-devel@nongnu.org; Fri, 16 Mar 2012 02:39:34 -0400 Received: from [222.73.24.84] (port=44159 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8Qp3-0003xe-4e for qemu-devel@nongnu.org; Fri, 16 Mar 2012 02:39:33 -0400 Message-ID: <4F62E08F.8050004@cn.fujitsu.com> Date: Fri, 16 Mar 2012 14:41:19 +0800 From: Wen Congyang MIME-Version: 1.0 References: <4F5FFC63.3060300@cn.fujitsu.com> <4F5FFE57.8010308@cn.fujitsu.com> <20120316.122315.59657118.d.hatayama@jp.fujitsu.com> In-Reply-To: <20120316.122315.59657118.d.hatayama@jp.fujitsu.com> Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Qemu-devel] [RFC][PATCH 11/14 v9] introduce a new monitor command 'dump' to dump guest's memory List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: HATAYAMA Daisuke Cc: jan.kiszka@siemens.com, anderson@redhat.com, qemu-devel@nongnu.org, eblake@redhat.com, lcapitulino@redhat.com At 03/16/2012 11:23 AM, HATAYAMA Daisuke Wrote: > From: Wen Congyang > Subject: [RFC][PATCH 11/14 v9] introduce a new monitor command 'dump' to dump guest's memory > Date: Wed, 14 Mar 2012 10:11:35 +0800 > >> +/* >> + * QEMU dump >> + * >> + * Copyright Fujitsu, Corp. 2011 >> + * > > Now 2012. On, I forgot to update it. > >> + /* >> + * calculate phdr_num >> + * >> + * the type of phdr->num is uint16_t, so we should avoid overflow > > e_phnum is correct. Yes > >> + */ >> + s->phdr_num = 1; /* PT_NOTE */ >> + if (s->list.num < (1 << 16) - 2) { > > s->list.num < UINT16_MAX is better. > >> + s->phdr_num += s->list.num; >> + s->have_section = false; >> + } else { >> + s->have_section = true; >> + s->phdr_num = PN_XNUM; >> + >> + /* the type of shdr->sh_info is uint32_t, so we should avoid overflow */ >> + if (s->list.num > (1ULL << 32) - 2) { > > s->list.num < UINT32_MAX is better. > >> + s->sh_info = 0xffffffff; > > UINT32_MAX is better. Is it rough around here? > >> + } else { >> + s->sh_info += s->list.num; >> + } >> + } > > Now orders of processings in positive and negative cases for e_phnum > and sh_info are different. It's better to make them sorted in the same > order. > > if (phdr_num not overflow?) { > not overflow case; > } else { > overflow case; > if (sh_info not overflow?) { > not overflow case; > } else { > overflow case; > } > } > > is better. OK Thanks Wen Congyang > > Thanks. > HATAYAMA, Daisuke > >