Re: [PATCH spice-common 3/4] Check for messages with duplicate names inside a channel

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

 



> 
> On Wed, May 16, 2018 at 11:04:17AM -0400, Frediano Ziglio wrote:
> > > 
> > > On Mon, May 14, 2018 at 11:18:53PM +0100, Frediano Ziglio wrote:
> > > > Make sure there are not 2 messages with the same name in the
> > > > same channel.
> > > > 
> > > > Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> > > > ---
> > > >  python_modules/ptypes.py | 3 +++
> > > >  1 file changed, 3 insertions(+)
> > > > 
> > > > diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
> > > > index ef580aa..664dd1d 100644
> > > > --- a/python_modules/ptypes.py
> > > > +++ b/python_modules/ptypes.py
> > > > @@ -1055,6 +1055,9 @@ class ChannelType(Type):
> > > >                      m.value = info.count
> > > >                  info.count = m.value + 1
> > > >                  info.messages.append(m)
> > > > +                if m.name in info.messages_byname:
> > > > +                    raise Exception("Duplicated message name between
> > > > %s
> > > > and %s in channel %s" % (
> > > > +                        info.messages_byname[m.name].name, m.name,
> > > > self.name))
> > > 
> > > I believe this will repeat twice the same name "between xxx and xxx in
> > > channel ..". You can only mention the duplicate name once.
> > > Looks good otherwise.
> > > 
> > 
> > The exception will stop the program, so only the first is shown
> 
> It will show only one Exception message yes, but it will be something
> like
> "Duplicated message name between foo and foo in channel bar"
> No need for mentioning 'foo' twice in that message.
> 
> Christophe
> 

When you are right you are right, changing to

      raise Exception("Duplicated message name '%s' in channel '%s'" % (m.name, self.name))

Frediano
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]