[PATCH libinput] tools: prefix debug output with '.' on device changes

Peter Hutterer peter.hutterer at who-t.net
Wed Sep 14 21:55:54 UTC 2016


On Wed, Sep 14, 2016 at 05:48:26PM +0100, Eric Engestrom wrote:
> On Thu, Sep 08, 2016 at 03:55:47PM +1000, Peter Hutterer wrote:
> > We print the sysname, but it's not always obvious when there's an event from
> > another device within the stream from another device. Prefix it so it's easier
> > to spot and search for.
> > 
> > See https://bugzilla.redhat.com/show_bug.cgi?id=1364850#c3 for an example of
> > how such an event can hide.
> > 
> > We only use last_device for comparing pointer values so we don't need a
> > reference to the device, it doesn't matter if the device itself goes out of
> > scope.
> > 
> > Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> > ---
> >  tools/event-debug.c | 12 +++++++++++-
> >  1 file changed, 11 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/event-debug.c b/tools/event-debug.c
> > index 67432b7..0e95611 100644
> > --- a/tools/event-debug.c
> > +++ b/tools/event-debug.c
> > @@ -49,8 +49,11 @@ static unsigned int stop = 0;
> >  static void
> >  print_event_header(struct libinput_event *ev)
> >  {
> > +	/* use for pointer value only, do not dereference */
> > +	static struct libinput_device *last_device = NULL;
> 
> I would make that a void* to make it clear that it's not meant to be
> dereferenced.

I've already pushed this patch for 1.5 but I've changed this in a follow-up
patch now. Thanks.

Cheers,
   Peter

> >  	struct libinput_device *dev = libinput_event_get_device(ev);
> >  	const char *type = NULL;
> > +	char prefix;
> >  
> >  	switch(libinput_event_get_type(ev)) {
> >  	case LIBINPUT_EVENT_NONE:
> > @@ -132,7 +135,14 @@ print_event_header(struct libinput_event *ev)
> >  		break;
> >  	}
> >  
> > -	printf("%-7s	%-16s ", libinput_device_get_sysname(dev), type);
> > +	prefix = (last_device != dev) ? '-' : ' ';
> 
> Nit: that line would be even shorter within the printf than here on
> its own :)
> 
> Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>
> 
> > +
> > +	printf("%c%-7s	%-16s ",
> > +	       prefix,
> > +	       libinput_device_get_sysname(dev),
> > +	       type);
> > +
> > +	last_device = dev;
> >  }
> >  
> >  static void
> > -- 
> > 2.7.4


More information about the wayland-devel mailing list