From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH 16/27] tools/libxl: Infrastructure for reading a libxl migration v2 stream Date: Wed, 17 Jun 2015 10:50:29 +0100 Message-ID: <558142E5.1000609@citrix.com> References: <1434375880-30914-1-git-send-email-andrew.cooper3@citrix.com> <1434375880-30914-17-git-send-email-andrew.cooper3@citrix.com> <5581287F.9000305@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <5581287F.9000305@cn.fujitsu.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Wen Congyang , Xen-devel Cc: Ian Jackson , Yang Hongyang , Wei Liu , Ian Campbell , Ross Lagerwall List-Id: xen-devel@lists.xenproject.org On 17/06/15 08:57, Wen Congyang wrote: >> + /* Queue up reading the body. */ >> > + size_t bytes_to_read; >> > + >> > + switch (rec_hdr->type) { >> > + /* >> > + * Emulator records want to retain the blob in the pipe, for a further >> > + * datacopier call to move elsewhere. Just read the emulator header. >> > + */ > In this case, we should not call ROUNDUP(). > >> > + case REC_TYPE_EMULATOR_CONTEXT: >> > + bytes_to_read = sizeof(struct libxl_sr_emulator_hdr); >> > + break; >> > + >> > + default: >> > + bytes_to_read = rec_hdr->length; >> > + break; >> > + } >> > + >> > + bytes_to_read = ROUNDUP(bytes_to_read, REC_ALIGN_ORDER); > So, I think it is better to move ROUNDUP to default case. > > Thanks > Wen Congyang > sizeof(struct libxl_sr_emulator_hdr) is cunningly of the appropriate order already. I suppose it is probably better to move the roundup into the default case and assert() appropriate alignment after the switch() ~Andrew