From: Ian Jackson Subject: Re: [PATCH v1 08/10] libxl: introduce libxl_get_memory_static_max Date: Tue, 29 Jul 2014 14:39:08 +0100 Message-ID: <21463.41980.66655.169690@mariner.uk.xensource.com> References: <1405002745-5034-1-git-send-email-wei.liu2@citrix.com> <1405002745-5034-9-git-send-email-wei.liu2@citrix.com> <1405594028.12538.9.camel@kazak.uk.xensource.com> <20140717120232.GJ4913@zion.uk.xensource.com> <1405605559.31127.22.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1405605559.31127.22.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: Wei Liu , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org Ian Campbell writes ("Re: [PATCH v1 08/10] libxl: introduce libxl_get_memory_static_max"): > On Thu, 2014-07-17 at 13:02 +0100, Wei Liu wrote: > > On Thu, Jul 17, 2014 at 11:47:08AM +0100, Ian Campbell wrote: > > > It looks to me like this could instead be a common helper function, with > > > a simple boolean parameter. > > > > Ian J likes macro while you likes functions. I'm fine with anything that > > works. :-) > > I think Ian prefers macros over repetition, but not at the expense of a > helper function. IOW macros only when the function is impossible. At > least I hope that's the case! Yes. I am indeed allergic to repetition. Repetition should be avoided by the use of helper functions if possible; or helper functions with helper macros; or failing that just macros; or failing that with code autogeneration run from the build system. So I agree with Ian C that if you can shrink the proportion of the code in the macros that's probably a good thing, unless it seems to break things up so much it makes them more confusing. Note also that there are complicated rules about pointer casting - particularly about calling a function through a pointer which has been cast from one function pointer type to another. Thanks, Ian.