[PATCH libevdev 2/3] Mark the log functions with the printf format attribute
Peter Hutterer
peter.hutterer at who-t.net
Mon May 26 17:06:58 PDT 2014
On Sun, May 25, 2014 at 02:29:50PM +0200, David Herrmann wrote:
> Hi
>
> On Mon, May 19, 2014 at 6:01 AM, Peter Hutterer
> <peter.hutterer at who-t.net> wrote:
> > Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> > ---
> > configure.ac | 1 +
> > libevdev/libevdev-int.h | 3 +--
> > libevdev/libevdev.h | 10 +++++++++-
> > 3 files changed, 11 insertions(+), 3 deletions(-)
> >
> > diff --git a/configure.ac b/configure.ac
> > index 0f2755e..9c0aae3 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -50,6 +50,7 @@ AM_SILENT_RULES([yes])
> >
> > # Check for programs
> > AC_PROG_CC_C99
> > +CC_ATTRIBUTE_FORMAT
>
> Who cares for that? LLVM and GCC implement
> __attribute__((__format__)). I'm no big fan of supporting compilers we
> don't know. And stuff like that should be forced into the C standard,
> instead of working around it all the time.
I just found there is a badly broken issue with this patch anyway - because
of the ifdef's in the config file the installed header would never enable
it, causing warnings in the callers. I'll send out another revision with a
straightforward ifdef, and let those without support worry about undefining
it.
Cheers,
Peter
> Anyhow, patch still looks fine, so if you really want that:
>
> Reviewed-by: David Herrmann <dh.herrmann at gmail.com>
>
> Thanks
> David
>
> >
> > # Initialize libtool
> > LT_PREREQ([2.2])
> > diff --git a/libevdev/libevdev-int.h b/libevdev/libevdev-int.h
> > index 98c75ce..f587e76 100644
> > --- a/libevdev/libevdev-int.h
> > +++ b/libevdev/libevdev-int.h
> > @@ -36,7 +36,6 @@
> > #define ABS_MT_MAX ABS_MT_TOOL_Y
> > #define ABS_MT_CNT (ABS_MT_MAX - ABS_MT_MIN + 1)
> > #define LIBEVDEV_EXPORT __attribute__((visibility("default")))
> > -#define LIBEVDEV_PRINTF(_format, _args) __attribute__ ((format (printf, _format, _args)))
> > #define ALIAS(_to) __attribute__((alias(#_to)))
> >
> > /**
> > @@ -131,7 +130,7 @@ extern void
> > log_msg(enum libevdev_log_priority priority,
> > void *data,
> > const char *file, int line, const char *func,
> > - const char *format, ...) LIBEVDEV_PRINTF(6, 7);
> > + const char *format, ...) LIBEVDEV_ATTRIBUTE_PRINTF(6, 7);
> >
> > /**
> > * @return a pointer to the next element in the queue, or NULL if the queue
> > diff --git a/libevdev/libevdev.h b/libevdev/libevdev.h
> > index ef142ea..2c46102 100644
> > --- a/libevdev/libevdev.h
> > +++ b/libevdev/libevdev.h
> > @@ -30,6 +30,13 @@ extern "C" {
> > #include <linux/input.h>
> > #include <stdarg.h>
> >
> > +#undef LIBEVDEV_ATTRIBUTE_PRINTF
> > +#ifdef SUPPORT_ATTRIBUTE_FORMAT
> > +#define LIBEVDEV_ATTRIBUTE_PRINTF(_format, _args) __attribute__ ((format (printf, _format, _args)))
> > +#else
> > +#define LIBEVDEV_ATTRIBUTE_PRINTF(_format, _args) /**/
> > +#endif
> > +
> > /**
> > * @mainpage
> > *
> > @@ -789,7 +796,8 @@ typedef void (*libevdev_log_func_t)(enum libevdev_log_priority priority,
> > void *data,
> > const char *file, int line,
> > const char *func,
> > - const char *format, va_list args);
> > + const char *format, va_list args)
> > + LIBEVDEV_ATTRIBUTE_PRINTF(6, 0);
> >
> > /**
> > * @ingroup init
> > --
> > 1.9.0
> >
> > _______________________________________________
> > Input-tools mailing list
> > Input-tools at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/input-tools
More information about the Input-tools
mailing list