From: Ian Campbell Subject: Re: [PATCH V4 15/24] libxl: introduce libxl_cpuid_policy_list_length Date: Tue, 6 May 2014 14:51:48 +0100 Message-ID: <1399384308.3014.141.camel@kazak.uk.xensource.com> References: <1398949101-23320-1-git-send-email-wei.liu2@citrix.com> <1398949101-23320-16-git-send-email-wei.liu2@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1398949101-23320-16-git-send-email-wei.liu2@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: Wei Liu Cc: ian.jackson@eu.citrix.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Thu, 2014-05-01 at 13:58 +0100, Wei Liu wrote: > Signed-off-by: Wei Liu > --- > tools/libxl/libxl.h | 1 + > tools/libxl/libxl_cpuid.c | 11 +++++++++++ > 2 files changed, 12 insertions(+) > > diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h > index 7d0351b..3755bad 100644 > --- a/tools/libxl/libxl.h > +++ b/tools/libxl/libxl.h > @@ -510,6 +510,7 @@ void libxl_bitmap_dispose(libxl_bitmap *map); > typedef struct libxl__cpuid_policy libxl_cpuid_policy; > typedef libxl_cpuid_policy * libxl_cpuid_policy_list; > void libxl_cpuid_dispose(libxl_cpuid_policy_list *cpuid_list); > +int libxl_cpuid_policy_list_length(libxl_cpuid_policy_list *l); > > #define LIBXL_PCI_FUNC_ALL (~0U) > > diff --git a/tools/libxl/libxl_cpuid.c b/tools/libxl/libxl_cpuid.c > index 45d2d9a..7f27c67 100644 > --- a/tools/libxl/libxl_cpuid.c > +++ b/tools/libxl/libxl_cpuid.c > @@ -451,6 +451,17 @@ int libxl_cpuid_policy_list_parse_json(libxl__gc *gc, > return 0; > } > > +int libxl_cpuid_policy_list_length(libxl_cpuid_policy_list *l) > +{ > + int i = 0; > + > + if (*l) > + while ((*l)[i].input[0] != XEN_CPUID_INPUT_UNUSED) Other functions of this type would assign *l to a temporary, I think this should do the same. The prevalent style would make the parameter *pl and then l = *pl. > + i++; > + > + return i; > +} > + > /* > * Local variables: > * mode: C