From: Wei Liu Subject: Re: [PATCH v3 11/15] libxl: refactor libxl_get_memory_target Date: Tue, 9 Sep 2014 14:39:35 +0100 Message-ID: <20140909133935.GF24977@zion.uk.xensource.com> References: <1409870601-7538-1-git-send-email-wei.liu2@citrix.com> <1409870601-7538-12-git-send-email-wei.liu2@citrix.com> <1410262606.8217.139.camel@kazak.uk.xensource.com> <1410262745.8217.141.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1410262745.8217.141.camel@kazak.uk.xensource.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: Ian Campbell Cc: ian.jackson@eu.citrix.com, Wei Liu , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Tue, Sep 09, 2014 at 12:39:05PM +0100, Ian Campbell wrote: > On Tue, 2014-09-09 at 12:36 +0100, Ian Campbell wrote: > > On Thu, 2014-09-04 at 23:43 +0100, Wei Liu wrote: > > > + > > > + if (!get_target) > > > + *out_mem = max_memkb; > > > + else > > > + *out_mem = target_memkb; > > > > Given that you are only going to return one or the other why do you go > > to all the effort of reading both and converting them from string to int > > etc? > > > > Can't you just set the path to read from based on out_target at the top > > (and maybe set a const char * what for logging purposes) and then the > > rest of the function just deals with that doing a single conversion etc? > > The caller in the next patch seems to want both values, so it calls this > function twice, meaning that currently it is reading and parsing both > values twice. > > Depends on what other callers there are perhaps what you really want is > a single helper to return both values at the same time, which accepts > NULL for either of the output pointers. > OK, I will rewrite it to return both values at the same time. Wei. > Ian.