From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Jackson Subject: Re: [PATCH v2 16/27] tools/libxl: Infrastructure for reading a libxl migration v2 stream Date: Fri, 10 Jul 2015 12:16:04 +0100 Message-ID: <21919.43380.805697.706792@mariner.uk.xensource.com> References: <1436466413-25867-1-git-send-email-andrew.cooper3@citrix.com> <1436466413-25867-17-git-send-email-andrew.cooper3@citrix.com> <1436523793.23508.224.camel@citrix.com> <559FA2A5.9090105@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <559FA2A5.9090105@citrix.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: Andrew Cooper Cc: Ross Lagerwall , Wei Liu , Ian Campbell , Xen-devel List-Id: xen-devel@lists.xenproject.org Andrew Cooper writes ("Re: [PATCH v2 16/27] tools/libxl: Infrastructure for reading a libxl migration v2 stream"): > On 10/07/15 11:23, Ian Campbell wrote: > >> +void libxl__stream_read_start(libxl__egc *egc, > >> + libxl__stream_read_state *stream) > >> +{ > >> + libxl__datacopier_state *dc = &stream->dc; > >> + int ret = 0; > >> + > >> + /* State initialisation. */ > >> + assert(!stream->running); > > > > Since running is declared private and there is no _init function (I > > think _start is effectively filling that role) I'm not sure that the > > caller can necessarily be expected to have initialised anything other > > than the ao, fd and callback fields. > > It was a sanity check that _start() doesn't get called twice (guess what > I managed to do while developing). It can probably be dropped. I don't mind this at all but I think if you do this you should: * provide an _init method * document that _init must be called before start > > You might choose to handle this as a request for a doc comment ("must > > call LIBXL_FILLZERO on it to init"), or to add a separate init function > > containing the memset or to do away with this check. I've not gotten to > > the caller yet so I don't know which you will prefer. > > It is all zeroed because of the way dcs is constructed. I suppose I can > also drop the zeroing of the dc. Providing an init method would mean that if this thing needs to grow calls to sub-states' init methods, there is somewhere to put them. Ian.