diff mbox

[v2,2/2] libxendevicemodel: initialise extent to zero

Message ID 20170928104624.eirld27ric2umhjb@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Liu Sept. 28, 2017, 10:46 a.m. UTC
On Thu, Sep 28, 2017 at 11:40:45AM +0100, Paul Durrant wrote:
> > -----Original Message-----
> > From: Wei Liu [mailto:wei.liu2@citrix.com]
> > Sent: 28 September 2017 11:36
> > To: Xen-devel <xen-devel@lists.xenproject.org>
> > Cc: Anthony Perard <anthony.perard@citrix.com>; Wei Liu
> > <wei.liu2@citrix.com>; Ian Jackson <Ian.Jackson@citrix.com>; Paul Durrant
> > <Paul.Durrant@citrix.com>
> > Subject: [PATCH v2 2/2] libxendevicemodel: initialise extent to zero
> > 
> > The pad field needs to be zero as required by the hypervisor.
> > 
> > Instead of setting the pad separately, use C99 initialiser to clear
> > extent.
> > 
> > Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> > ---
> > Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> > Cc: Paul Durrant <paul.durrant@citrix.com>
> > 
> > Backport to 4.9
> > ---
> >  tools/libs/devicemodel/core.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c
> > index fcb260d29b..986f147658 100644
> > --- a/tools/libs/devicemodel/core.c
> > +++ b/tools/libs/devicemodel/core.c
> > @@ -483,7 +483,7 @@ int xendevicemodel_modified_memory(
> >      xendevicemodel_handle *dmod, domid_t domid, uint64_t first_pfn,
> >      uint32_t nr)
> >  {
> > -    struct xen_dm_op_modified_memory_extent extent;
> > +    struct xen_dm_op_modified_memory_extent extent = { };
> 
> Not quite. I meant:
> 
> struct xen_dm_op_modified_memory_extent extent = { 
>     .first_pfn = first_pfn,
>     .nr = nr,
> };
> 
> then you can drop the lines below.

Here you go.

---8<---
From 75c955c2d2c7077fe59b5e3b14e3deff613025e8 Mon Sep 17 00:00:00 2001
From: Wei Liu <wei.liu2@citrix.com>
Date: Thu, 28 Sep 2017 11:00:00 +0100
Subject: [PATCH] libxendevicemodel: initialise extent.pad to zero

The pad field needs to be zero as required by the hypervisor.

Instead of setting the pad separately, use C99 initialiser.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Paul Durrant <paul.durrant@citrix.com>

Backport to 4.9
---
 tools/libs/devicemodel/core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Paul Durrant Sept. 28, 2017, 10:48 a.m. UTC | #1
> -----Original Message-----
> From: Wei Liu [mailto:wei.liu2@citrix.com]
> Sent: 28 September 2017 11:46
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: Wei Liu <wei.liu2@citrix.com>; Xen-devel <xen-
> devel@lists.xenproject.org>; Anthony Perard <anthony.perard@citrix.com>;
> Ian Jackson <Ian.Jackson@citrix.com>
> Subject: Re: [PATCH v2 2/2] libxendevicemodel: initialise extent to zero
> 
> On Thu, Sep 28, 2017 at 11:40:45AM +0100, Paul Durrant wrote:
> > > -----Original Message-----
> > > From: Wei Liu [mailto:wei.liu2@citrix.com]
> > > Sent: 28 September 2017 11:36
> > > To: Xen-devel <xen-devel@lists.xenproject.org>
> > > Cc: Anthony Perard <anthony.perard@citrix.com>; Wei Liu
> > > <wei.liu2@citrix.com>; Ian Jackson <Ian.Jackson@citrix.com>; Paul
> Durrant
> > > <Paul.Durrant@citrix.com>
> > > Subject: [PATCH v2 2/2] libxendevicemodel: initialise extent to zero
> > >
> > > The pad field needs to be zero as required by the hypervisor.
> > >
> > > Instead of setting the pad separately, use C99 initialiser to clear
> > > extent.
> > >
> > > Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> > > ---
> > > Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> > > Cc: Paul Durrant <paul.durrant@citrix.com>
> > >
> > > Backport to 4.9
> > > ---
> > >  tools/libs/devicemodel/core.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/tools/libs/devicemodel/core.c
> b/tools/libs/devicemodel/core.c
> > > index fcb260d29b..986f147658 100644
> > > --- a/tools/libs/devicemodel/core.c
> > > +++ b/tools/libs/devicemodel/core.c
> > > @@ -483,7 +483,7 @@ int xendevicemodel_modified_memory(
> > >      xendevicemodel_handle *dmod, domid_t domid, uint64_t first_pfn,
> > >      uint32_t nr)
> > >  {
> > > -    struct xen_dm_op_modified_memory_extent extent;
> > > +    struct xen_dm_op_modified_memory_extent extent = { };
> >
> > Not quite. I meant:
> >
> > struct xen_dm_op_modified_memory_extent extent = {
> >     .first_pfn = first_pfn,
> >     .nr = nr,
> > };
> >
> > then you can drop the lines below.
> 
> Here you go.
> 
> ---8<---
> From 75c955c2d2c7077fe59b5e3b14e3deff613025e8 Mon Sep 17 00:00:00
> 2001
> From: Wei Liu <wei.liu2@citrix.com>
> Date: Thu, 28 Sep 2017 11:00:00 +0100
> Subject: [PATCH] libxendevicemodel: initialise extent.pad to zero
> 
> The pad field needs to be zero as required by the hypervisor.
> 
> Instead of setting the pad separately, use C99 initialiser.
> 
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> ---
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Paul Durrant <paul.durrant@citrix.com>
> 
> Backport to 4.9
> ---
>  tools/libs/devicemodel/core.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c
> index fcb260d29b..0f2c1a791f 100644
> --- a/tools/libs/devicemodel/core.c
> +++ b/tools/libs/devicemodel/core.c
> @@ -483,10 +483,10 @@ int xendevicemodel_modified_memory(
>      xendevicemodel_handle *dmod, domid_t domid, uint64_t first_pfn,
>      uint32_t nr)
>  {
> -    struct xen_dm_op_modified_memory_extent extent;
> -
> -    extent.first_pfn = first_pfn;
> -    extent.nr = nr;
> +    struct xen_dm_op_modified_memory_extent extent = {
> +        .first_pfn = first_pfn,
> +        .nr = nr,
> +    };

Yep, LGTM.

Reviewed-by: Paul Durrant <paul.durrant@citrix.com>

> 
>      return xendevicemodel_modified_memory_bulk(dmod, domid, &extent,
> 1);
>  }
> --
> 2.11.0
diff mbox

Patch

diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c
index fcb260d29b..0f2c1a791f 100644
--- a/tools/libs/devicemodel/core.c
+++ b/tools/libs/devicemodel/core.c
@@ -483,10 +483,10 @@  int xendevicemodel_modified_memory(
     xendevicemodel_handle *dmod, domid_t domid, uint64_t first_pfn,
     uint32_t nr)
 {
-    struct xen_dm_op_modified_memory_extent extent;
-
-    extent.first_pfn = first_pfn;
-    extent.nr = nr;
+    struct xen_dm_op_modified_memory_extent extent = {
+        .first_pfn = first_pfn,
+        .nr = nr,
+    };
 
     return xendevicemodel_modified_memory_bulk(dmod, domid, &extent, 1);
 }