From: Wei Liu Subject: Re: [PATCH v6 for-4.5 4/5] xl: add 'trim' and 'split_string_into_pair' functions Date: Fri, 26 Sep 2014 16:51:50 +0100 Message-ID: <20140926155150.GC28628@zion.uk.xensource.com> References: <1411591685-25308-1-git-send-email-dave.scott@citrix.com> <1411591685-25308-5-git-send-email-dave.scott@citrix.com> <20140926100917.GD12753@zion.uk.xensource.com> <21541.35354.847047.887012@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XXXoy-0002FS-H0 for xen-devel@lists.xenproject.org; Fri, 26 Sep 2014 15:52:36 +0000 Content-Disposition: inline In-Reply-To: <21541.35354.847047.887012@mariner.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 Jackson Cc: xen-devel@lists.xenproject.org, David Scott , Wei Liu , ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com List-Id: xen-devel@lists.xenproject.org On Fri, Sep 26, 2014 at 04:45:30PM +0100, Ian Jackson wrote: > Wei Liu writes ("Re: [PATCH v6 for-4.5 4/5] xl: add 'trim' and 'split_string_into_pair' functions"): > > On Wed, Sep 24, 2014 at 09:48:04PM +0100, David Scott wrote: > > > +/* NB: this follows the interface used by . See 'man 3 ctype' > > > + and look for CTYPE in libxl_internal.h */ > > > +typedef int (*char_predicate_t)(const int c); > > > + > > > +static void trim(char_predicate_t predicate, const char *input, char **output) __attribute__ ((unused)); > > > +static void trim(char_predicate_t predicate, const char *input, char **output) > > > +{ > > > + char *p, *q, *tmp; > > > > Ideally you should check input != NULL before dereferencing it. Or you > > need to document this function expects a valid pointer. > > (Thanks for looking at this, Wei, but:) > > I disagree. I think in general a function that takes any kind of > pointer should be assumed to require a non-NULL pointer. It should > not carry out any kind of nullness check; it should just dereference > the pointer (and consequently crash if it is NULL). > > If a function permits callers to pass NULL, that should be documented > in the function's doc comment (along, presumably, with the semantics, > if that isn't obvious). > Fair enough. I don't really have strong preference on this kind of issue. We just need to have an agreement on which route we take. Wei.