From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH] rangeset: "has" and "is" functions return boolean Date: Tue, 9 Jun 2015 10:00:46 +0100 Message-ID: <1433840446.7108.529.camel@citrix.com> References: <5576C4570200007800082740@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Z2FOv-0003ol-C7 for xen-devel@lists.xenproject.org; Tue, 09 Jun 2015 09:00:53 +0000 In-Reply-To: <5576C4570200007800082740@mail.emea.novell.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: Jan Beulich Cc: xen-devel , Keir Fraser , Ian Jackson , Tim Deegan List-Id: xen-devel@lists.xenproject.org On Tue, 2015-06-09 at 09:47 +0100, Jan Beulich wrote: > Additionally rangeset_is_empty()'s sole parameter can be const. Isn't that true of all/most of the others touched here too? (Once the underlying range_* list manipulations are made const correct). If you do decide to go further then there is a "implemnetation" typo in there too. > Signed-off-by: Jan Beulich So far as it goes: Acked-by: Ian Campbell > --- a/xen/common/rangeset.c > +++ b/xen/common/rangeset.c > @@ -248,11 +248,11 @@ int rangeset_remove_range( > return rc; > } > > -int rangeset_contains_range( > +bool_t rangeset_contains_range( > struct rangeset *r, unsigned long s, unsigned long e) > { > struct range *x; > - int contains; > + bool_t contains; > > ASSERT(s <= e); > > @@ -264,11 +264,11 @@ int rangeset_contains_range( > return contains; > } > > -int rangeset_overlaps_range( > +bool_t rangeset_overlaps_range( > struct rangeset *r, unsigned long s, unsigned long e) > { > struct range *x; > - int overlaps; > + bool_t overlaps; > > ASSERT(s <= e); > > @@ -310,14 +310,14 @@ int rangeset_remove_singleton( > return rangeset_remove_range(r, s, s); > } > > -int rangeset_contains_singleton( > +bool_t rangeset_contains_singleton( > struct rangeset *r, unsigned long s) > { > return rangeset_contains_range(r, s, s); > } > > -int rangeset_is_empty( > - struct rangeset *r) > +bool_t rangeset_is_empty( > + const struct rangeset *r) > { > return ((r == NULL) || list_empty(&r->range_list)); > } > --- a/xen/include/xen/rangeset.h > +++ b/xen/include/xen/rangeset.h > @@ -10,6 +10,8 @@ > #ifndef __XEN_RANGESET_H__ > #define __XEN_RANGESET_H__ > > +#include > + > struct domain; > struct rangeset; > > @@ -50,17 +52,17 @@ void rangeset_limit( > #define _RANGESETF_prettyprint_hex 0 > #define RANGESETF_prettyprint_hex (1U << _RANGESETF_prettyprint_hex) > > -int __must_check rangeset_is_empty( > - struct rangeset *r); > +bool_t __must_check rangeset_is_empty( > + const struct rangeset *r); > > /* Add/remove/query a numeric range. */ > int __must_check rangeset_add_range( > struct rangeset *r, unsigned long s, unsigned long e); > int __must_check rangeset_remove_range( > struct rangeset *r, unsigned long s, unsigned long e); > -int __must_check rangeset_contains_range( > +bool_t __must_check rangeset_contains_range( > struct rangeset *r, unsigned long s, unsigned long e); > -int __must_check rangeset_overlaps_range( > +bool_t __must_check rangeset_overlaps_range( > struct rangeset *r, unsigned long s, unsigned long e); > int rangeset_report_ranges( > struct rangeset *r, unsigned long s, unsigned long e, > @@ -71,7 +73,7 @@ int __must_check rangeset_add_singleton( > struct rangeset *r, unsigned long s); > int __must_check rangeset_remove_singleton( > struct rangeset *r, unsigned long s); > -int __must_check rangeset_contains_singleton( > +bool_t __must_check rangeset_contains_singleton( > struct rangeset *r, unsigned long s); > > /* swap contents */ > > >