gmessages: Fix G_GNUC_PRINTF mark for g_log_structured

GCC fails to build because of the trailing arguments, not part of the
format:

../../glib/gmessages.c: In function 'g_log_default_handler':
../../glib/gmessages.c:2385:21: error: too many arguments for format
[-Werror=format-extra-args]
                     NULL);
                     ^

The documentation for `__attribute__((format(...)))` in GCC

https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes

States that the second index must be 0 for functions that are not
available to be checked, like for vprintf-style functions. In this case
it's also appropriate because of the trailing arguments.

The sd-journal API in systemd, upon which the structured logging API is
modelled, also uses 0 as the second argument for the format attribute.

https://bugzilla.gnome.org/show_bug.cgi?id=744456
This commit is contained in:
Rico Tzschichholz 2016-07-19 11:34:54 +02:00 committed by Emmanuele Bassi
parent 07932996fa
commit c67bd6cc54

View File

@ -191,7 +191,7 @@ GLIB_AVAILABLE_IN_2_50
void g_log_structured (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *format,
...) G_GNUC_PRINTF (3, 4)
...) G_GNUC_PRINTF (3, 0)
G_GNUC_NULL_TERMINATED;
GLIB_AVAILABLE_IN_2_50