[Spice-devel] [PATCH spice-common 4/4] Check for messages with duplicate values inside a channel

Christophe Fergeau cfergeau at redhat.com
Wed May 16 14:59:47 UTC 2018


Acked-by: Christophe Fergeau <cfergeau at redhat.com>

On Mon, May 14, 2018 at 11:18:54PM +0100, Frediano Ziglio wrote:
> Make sure there are not 2 messages with the same value in the
> same channel.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  python_modules/ptypes.py | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
> index 664dd1d..1b05cc6 100644
> --- a/python_modules/ptypes.py
> +++ b/python_modules/ptypes.py
> @@ -1039,6 +1039,10 @@ class ChannelType(Type):
>                      self.messages_byname = {}
>                  self.count = 1
>  
> +                self.messages_byvalue = {}
> +                for m in self.messages:
> +                    self.messages_byvalue[m.value] = m
> +
>          server_info = MessagesInfo(self.base, True)
>          client_info = MessagesInfo(self.base, False)
>  
> @@ -1059,6 +1063,10 @@ class ChannelType(Type):
>                      raise Exception("Duplicated message name between %s and %s in channel %s" % (
>                          info.messages_byname[m.name].name, m.name, self.name))
>                  info.messages_byname[m.name] = m
> +                if m.value in info.messages_byvalue:
> +                    raise Exception("Duplicated message value %d between %s and %s in channel %s" % (
> +                        m.value, info.messages_byvalue[m.value].name, m.name, self.name))
> +                info.messages_byvalue[m.value] = m
>  
>          self.server_messages = server_info.messages
>          self.server_messages_byname = server_info.messages_byname
> -- 
> 2.17.0
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20180516/8fb9e4ba/attachment.sig>


More information about the Spice-devel mailing list