xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@citrix.com>
To: Nick Rosbrook <rosbrookn@gmail.com>
Cc: Wei Liu <wl@xen.org>, "paul@xen.org" <paul@xen.org>,
	Andrew Cooper <Andrew.Cooper3@citrix.com>,
	George Dunlap <George.Dunlap@citrix.com>,
	Nick Rosbrook <rosbrookn@ainfosec.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH for-4.14] golang/xenlight: sort cases in switch statement
Date: Mon, 15 Jun 2020 16:43:15 +0100	[thread overview]
Message-ID: <24295.38675.682397.522303@mariner.uk.xensource.com> (raw)
In-Reply-To: <42ba06bc716cf91d25c8bb1d988cb1310219b8fe.1592234663.git.rosbrookn@ainfosec.com>

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@ainfosec.com>
> ---
> 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@eu.citrix.com>

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.

Ian.


  reply	other threads:[~2020-06-15 15:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-15 15:39 [PATCH for-4.14] golang/xenlight: sort cases in switch statement Nick Rosbrook
2020-06-15 15:43 ` Ian Jackson [this message]
2020-06-15 16:00   ` Paul Durrant
2020-06-15 16:02   ` George Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=24295.38675.682397.522303@mariner.uk.xensource.com \
    --to=ian.jackson@citrix.com \
    --cc=Andrew.Cooper3@citrix.com \
    --cc=George.Dunlap@citrix.com \
    --cc=paul@xen.org \
    --cc=rosbrookn@ainfosec.com \
    --cc=rosbrookn@gmail.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).