|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] RE: [PATCH for-4.14] golang/xenlight: sort cases in switch statement
> -----Original Message-----
> From: Ian Jackson <ian.jackson@xxxxxxxxxx>
> Sent: 15 June 2020 16:43
> To: Nick Rosbrook <rosbrookn@xxxxxxxxx>
> Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx; paul@xxxxxxx; Andrew Cooper
> <Andrew.Cooper3@xxxxxxxxxx>; Nick
> Rosbrook <rosbrookn@xxxxxxxxxxxx>; George Dunlap <George.Dunlap@xxxxxxxxxx>;
> Wei Liu <wl@xxxxxxx>
> Subject: Re: [PATCH for-4.14] golang/xenlight: sort cases in switch statement
>
> Nick Rosbrook writes ("[PATCH for-4.14] golang/xenlight: sort cases in switch
> statement"):
> > The xenlight_golang_union_from_C function iterates over a dict to
> > construct a switch statement that marshals a C keyed union into a Go
> > type. Because python does not guarantee dict ordering across all
> > versions, this can result in the switch statement being generated in a
> > different order depending on the version of python used. For example,
> > running gengotypes.py with python2.7 and python3.6 will yield different
> > orderings.
> >
> > Iterate over sorted(cases.items()) rather than cases.items() to fix
> > this.
> >
> > This patch changes the ordering from what was previously checked-in, but
> > running gengotypes.py with different versions of python will now yield
> > the same result.
> >
> > Signed-off-by: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>
> > ---
> > Andrew reported this in [1], so I intend this as a build fix for 4.14.
> >
> > [1]
> > https://lists.xenproject.org/archives/html/xen-devel/2020-06/msg00881.html
> > ---
> > tools/golang/xenlight/gengotypes.py | 2 +-
> > tools/golang/xenlight/helpers.gen.go | 32 ++++++++++++++--------------
> > 2 files changed, 17 insertions(+), 17 deletions(-)
> >
> > diff --git a/tools/golang/xenlight/gengotypes.py
> > b/tools/golang/xenlight/gengotypes.py
> > index ecca59745f..557fecd07b 100644
> > --- a/tools/golang/xenlight/gengotypes.py
> > +++ b/tools/golang/xenlight/gengotypes.py
> > @@ -379,7 +379,7 @@ def xenlight_golang_union_from_C(ty = None, union_name
> > = '', struct_name = ''):
> >
> > # Create switch statement to determine which 'union element'
> > # to populate in the Go struct.
> > - for case_name, case_tuple in cases.items():
> > + for case_name, case_tuple in sorted(cases.items()):
> > (case_val, case_type) = case_tuple
>
> This part
>
> Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
>
> But I don't think I have the right golang tools to verify the
> autogenerated code. George, can you check that this patch is right,
> and/or do the commit and rerun the generation ?
>
> Obviously that needs to wait for a release ack.
>
Assuming George is happy...
Release-acked-by: Paul Durrant <paul@xxxxxxx>
> Ian.
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |