[PATCH libinput 1/3] Mark some internal log functions as printf-style function

Peter Hutterer peter.hutterer at who-t.net
Mon Oct 24 23:17:23 UTC 2016


On Mon, Oct 24, 2016 at 10:13:27AM +0100, Eric Engestrom wrote:
> On Monday, 2016-10-24 11:45:17 +1000, Peter Hutterer wrote:
> > Fixes the respective clang warnings
> > 
> > Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> > ---
> >  src/libinput.c    |  6 ++++++
> >  test/litest.c     | 16 ++++++++++++++++
> >  test/misc.c       |  7 +++++++
> >  tools/event-gui.c |  8 ++++++++
> >  tools/shared.c    |  7 +++++++
> >  5 files changed, 44 insertions(+)
> > 
> > diff --git a/src/libinput.c b/src/libinput.c
> > index 6958042..ec1c72a 100644
> > --- a/src/libinput.c
> > +++ b/src/libinput.c
> > @@ -163,6 +163,12 @@ static void
> >  libinput_default_log_func(struct libinput *libinput,
> >  			  enum libinput_log_priority priority,
> >  			  const char *format, va_list args)
> > +	LIBINPUT_ATTRIBUTE_PRINTF(3, 0);
> > +
> > +static void
> > +libinput_default_log_func(struct libinput *libinput,
> > +			  enum libinput_log_priority priority,
> > +			  const char *format, va_list args)
> >  {
> 
> I'm not sure why you're adding a prototype here; is there also a warning
> about this? (There shouldn't be, it's a static function.) If so, mention it
> in the commit log?
> 
> Anyway, I'm pretty sure just adding this one line would fix the printf
> warning too:
> 
> +LIBINPUT_ATTRIBUTE_PRINTF(3, 0)
>  static void
>  libinput_default_log_func(struct libinput *libinput,
>  			  enum libinput_log_priority priority,
>  			  const char *format, va_list args)
> +/* You can also add the attribute here if you prefer */
>  {
> 
> (Obviously, the same suggestion applies to all the functions in this patch.)

ha, right. now I finally know where to put this so it works for static
functions without adding a declaration... :)
thanks, fixed locally as you requested

Cheers,
   Peter

> 
> Patches 2 & 3 look good to me:
> Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>
> 
> >  	const char *prefix;
> >  
> > diff --git a/test/litest.c b/test/litest.c
> > index 4c301b5..940cf79 100644
> > --- a/test/litest.c
> > +++ b/test/litest.c
> > @@ -270,6 +270,15 @@ litest_fail_condition(const char *file,
> >  		      const char *condition,
> >  		      const char *message,
> >  		      ...)
> > +	LIBINPUT_ATTRIBUTE_PRINTF(5, 6);
> > +
> > +void
> > +litest_fail_condition(const char *file,
> > +		      int line,
> > +		      const char *func,
> > +		      const char *condition,
> > +		      const char *message,
> > +		      ...)
> >  {
> >  	litest_log("FAILED: %s\n", condition);
> >  
> > @@ -761,6 +770,13 @@ litest_log_handler(struct libinput *libinput,
> >  		   enum libinput_log_priority pri,
> >  		   const char *format,
> >  		   va_list args)
> > +		   LIBINPUT_ATTRIBUTE_PRINTF(3, 0);
> > +
> > +static void
> > +litest_log_handler(struct libinput *libinput,
> > +		   enum libinput_log_priority pri,
> > +		   const char *format,
> > +		   va_list args)
> >  {
> >  	const char *priority = NULL;
> >  
> > diff --git a/test/misc.c b/test/misc.c
> > index 791ebc3..44c4502 100644
> > --- a/test/misc.c
> > +++ b/test/misc.c
> > @@ -852,6 +852,13 @@ simple_log_handler(struct libinput *libinput,
> >  		   enum libinput_log_priority priority,
> >  		   const char *format,
> >  		   va_list args)
> > +		   LIBINPUT_ATTRIBUTE_PRINTF(3, 0);
> > +
> > +static void
> > +simple_log_handler(struct libinput *libinput,
> > +		   enum libinput_log_priority priority,
> > +		   const char *format,
> > +		   va_list args)
> >  {
> >  	vfprintf(stderr, format, args);
> >  }
> > diff --git a/tools/event-gui.c b/tools/event-gui.c
> > index b67ca45..e5fb26a 100644
> > --- a/tools/event-gui.c
> > +++ b/tools/event-gui.c
> > @@ -110,6 +110,10 @@ struct window {
> >  
> >  static int
> >  error(const char *fmt, ...)
> > +	LIBINPUT_ATTRIBUTE_PRINTF(1, 2);
> > +
> > +static int
> > +error(const char *fmt, ...)
> >  {
> >  	va_list args;
> >  	fprintf(stderr, "error: ");
> > @@ -123,6 +127,10 @@ error(const char *fmt, ...)
> >  
> >  static void
> >  msg(const char *fmt, ...)
> > +	LIBINPUT_ATTRIBUTE_PRINTF(1, 2);
> > +
> > +static void
> > +msg(const char *fmt, ...)
> >  {
> >  	va_list args;
> >  	printf("info: ");
> > diff --git a/tools/shared.c b/tools/shared.c
> > index 95655ba..f539957 100644
> > --- a/tools/shared.c
> > +++ b/tools/shared.c
> > @@ -70,6 +70,13 @@ log_handler(struct libinput *li,
> >  	    enum libinput_log_priority priority,
> >  	    const char *format,
> >  	    va_list args)
> > +	LIBINPUT_ATTRIBUTE_PRINTF(3, 0);
> > +
> > +static void
> > +log_handler(struct libinput *li,
> > +	    enum libinput_log_priority priority,
> > +	    const char *format,
> > +	    va_list args)
> >  {
> >  	vprintf(format, args);
> >  }
> > -- 
> > 2.9.3
> > 
> > _______________________________________________
> > wayland-devel mailing list
> > wayland-devel at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list