[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH for-4.14] golang/xenlight: sort cases in switch statement


  • To: Ian Jackson <Ian.Jackson@xxxxxxxxxx>
  • From: George Dunlap <George.Dunlap@xxxxxxxxxx>
  • Date: Mon, 15 Jun 2020 16:02:05 +0000
  • Accept-language: en-GB, en-US
  • Authentication-results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Wei Liu <wl@xxxxxxx>, "paul@xxxxxxx" <paul@xxxxxxx>, Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>, Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>, Nick Rosbrook <rosbrookn@xxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 15 Jun 2020 16:02:19 +0000
  • Ironport-sdr: 5riCwz4p1wnpEEZqAejU2zm+FaabhOI3cpkXyHaxAdWOdmVDcbFxAw/8jModYlzuhOa0goVPd9 j0b44UAMwKSrdHNXKwarWWzkQCmdUeRKAcHyQvo6GilGI/p4KDpD3R+QpAf1KcAjNhFhFXqb4w SslpsunKoOuP77iBGP2senY14+v8GRx7tqNnZrw5rjlr5PvPD/ii0uVmULycuMXIuj6RtWfgVg /esenJNIKNxAMp6R3KG3vdNW63qo57ZlVzJq39os9hN+nbIhUVO2jYztUAjFhQKb1mVtbxIyzY gsM=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHWQys0M2jXFQanD0CJHiScvqapGKjZr4CAgAAFQ4A=
  • Thread-topic: [PATCH for-4.14] golang/xenlight: sort cases in switch statement


> On Jun 15, 2020, at 4:43 PM, Ian Jackson <ian.jackson@xxxxxxxxxx> wrote:
> 
> 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 ?

I can confirm that 1) rerunning this doesn’t cause any changes 2) the resulting 
code compiles.

Acked-by: George Dunlap <george.dunlap@xxxxxxxxxx>

Since I’ve got it in my tree I’ll push it.

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.