Add G_GNUC_PRINTF on all functions with format strings This allows compilation with clang wihtout errors, even when -Wformat-nonliteral is active (as long as there are no real cases of non literal formatting). https://bugzilla.gnome.org/show_bug.cgi?id=691608
diff --git a/gio/gdbusauth.c b/gio/gdbusauth.c index 962a218..dd4cc2c 100644 --- a/gio/gdbusauth.c +++ b/gio/gdbusauth.c
@@ -46,6 +46,7 @@ #include "glibintl.h" +G_GNUC_PRINTF(1, 2) static void debug_print (const gchar *message, ...) {
diff --git a/gio/gdbusauthmechanismsha1.c b/gio/gdbusauthmechanismsha1.c index 4729208..5e8b6c0 100644 --- a/gio/gdbusauthmechanismsha1.c +++ b/gio/gdbusauthmechanismsha1.c
@@ -469,6 +469,7 @@ } /* function for logging important events that the system administrator should take notice of */ +G_GNUC_PRINTF(1, 2) static void _log (const gchar *message, ...)
diff --git a/gio/gdbusdaemon.c b/gio/gdbusdaemon.c index 35a724c..2393771 100644 --- a/gio/gdbusdaemon.c +++ b/gio/gdbusdaemon.c
@@ -1346,6 +1346,7 @@ return TRUE; } +G_GNUC_PRINTF(5, 6) static void return_error (Client *client, GDBusMessage *message, GQuark domain,
diff --git a/gio/gdbuserror.h b/gio/gdbuserror.h index d32b928..c1d3e9c 100644 --- a/gio/gdbuserror.h +++ b/gio/gdbuserror.h
@@ -87,12 +87,12 @@ const gchar *dbus_error_name, const gchar *dbus_error_message, const gchar *format, - ...); + ...) G_GNUC_PRINTF(4, 5); void g_dbus_error_set_dbus_error_valist (GError **error, const gchar *dbus_error_name, const gchar *dbus_error_message, const gchar *format, - va_list var_args); + va_list var_args) G_GNUC_PRINTF(4, 0); gchar *g_dbus_error_encode_gerror (const GError *error); G_END_DECLS
diff --git a/gio/gdbusmessage.c b/gio/gdbusmessage.c index ecbc033..9181029 100644 --- a/gio/gdbusmessage.c +++ b/gio/gdbusmessage.c
@@ -827,6 +827,7 @@ * * Since: 2.26 */ +G_GNUC_PRINTF(3, 0) GDBusMessage * g_dbus_message_new_method_error_valist (GDBusMessage *method_call_message, const gchar *error_name,
diff --git a/gio/gdbusmethodinvocation.h b/gio/gdbusmethodinvocation.h index 9146b21..29cfe63 100644 --- a/gio/gdbusmethodinvocation.h +++ b/gio/gdbusmethodinvocation.h
@@ -55,12 +55,13 @@ GQuark domain, gint code, const gchar *format, - ...); + ...) G_GNUC_PRINTF(4, 5); void g_dbus_method_invocation_return_error_valist (GDBusMethodInvocation *invocation, GQuark domain, gint code, const gchar *format, - va_list var_args); + va_list var_args) + G_GNUC_PRINTF(4, 0); void g_dbus_method_invocation_return_error_literal (GDBusMethodInvocation *invocation, GQuark domain, gint code,
diff --git a/gio/gsimpleasyncresult.h b/gio/gsimpleasyncresult.h index 6233369..1ea98f4 100644 --- a/gio/gsimpleasyncresult.h +++ b/gio/gsimpleasyncresult.h
@@ -110,7 +110,8 @@ GQuark domain, gint code, const char *format, - va_list args); + va_list args) + G_GNUC_PRINTF(4, 0); gboolean g_simple_async_result_is_valid (GAsyncResult *result, GObject *source, gpointer source_tag); @@ -121,7 +122,7 @@ GQuark domain, gint code, const char *format, - ...); + ...) G_GNUC_PRINTF(6, 7); void g_simple_async_report_gerror_in_idle (GObject *object, GAsyncReadyCallback callback, gpointer user_data,
diff --git a/gio/gtask.h b/gio/gtask.h index bb03226..d5a2d77 100644 --- a/gio/gtask.h +++ b/gio/gtask.h
@@ -61,7 +61,7 @@ GQuark domain, gint code, const char *format, - ...); + ...) G_GNUC_PRINTF(7, 8); GLIB_AVAILABLE_IN_2_36 void g_task_set_task_data (GTask *task,
diff --git a/glib/gerror.c b/glib/gerror.c index e6ce3c0..2adbdf8 100644 --- a/glib/gerror.c +++ b/glib/gerror.c
@@ -645,6 +645,7 @@ } } +G_GNUC_PRINTF(2, 0) static void g_error_add_prefix (gchar **string, const gchar *format,
diff --git a/glib/gerror.h b/glib/gerror.h index f9020d6..8b5de28 100644 --- a/glib/gerror.h +++ b/glib/gerror.h
@@ -60,7 +60,7 @@ GError* g_error_new_valist (GQuark domain, gint code, const gchar *format, - va_list args); + va_list args) G_GNUC_PRINTF(3, 0); void g_error_free (GError *error); GError* g_error_copy (const GError *error);
diff --git a/glib/gmarkup.c b/glib/gmarkup.c index 11f68de..bf7c008 100644 --- a/glib/gmarkup.c +++ b/glib/gmarkup.c
@@ -403,6 +403,7 @@ g_propagate_error (error, tmp_error); } +G_GNUC_PRINTF(4, 5) static void set_error (GMarkupParseContext *context, GError **error, @@ -564,6 +565,7 @@ return buf; } +G_GNUC_PRINTF(5, 6) static void set_unescape_error (GMarkupParseContext *context, GError **error,
diff --git a/glib/gmarkup.h b/glib/gmarkup.h index d26c2ad..d0eda4f 100644 --- a/glib/gmarkup.h +++ b/glib/gmarkup.h
@@ -214,7 +214,7 @@ gchar *g_markup_printf_escaped (const char *format, ...) G_GNUC_PRINTF (1, 2); gchar *g_markup_vprintf_escaped (const char *format, - va_list args); + va_list args) G_GNUC_PRINTF(1, 0); typedef enum {
diff --git a/glib/gmessages.h b/glib/gmessages.h index 777cda2..d0c1930 100644 --- a/glib/gmessages.h +++ b/glib/gmessages.h
@@ -46,7 +46,7 @@ /* calculate a string size, guaranteed to fit format + args. */ gsize g_printf_string_upper_bound (const gchar* format, - va_list args); + va_list args) G_GNUC_PRINTF(1, 0); /* Log level shift offset for user defined * log levels (0-7 are used by GLib). @@ -101,7 +101,7 @@ void g_logv (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, - va_list args); + va_list args) G_GNUC_PRINTF(3, 0); GLogLevelFlags g_log_set_fatal_mask (const gchar *log_domain, GLogLevelFlags fatal_mask); GLogLevelFlags g_log_set_always_fatal (GLogLevelFlags fatal_mask);
diff --git a/glib/gprintf.h b/glib/gprintf.h index d96870f..2ed5ecc 100644 --- a/glib/gprintf.h +++ b/glib/gprintf.h
@@ -36,16 +36,16 @@ ...) G_GNUC_PRINTF (2, 3); gint g_vprintf (gchar const *format, - va_list args); + va_list args) G_GNUC_PRINTF(1, 0); gint g_vfprintf (FILE *file, gchar const *format, - va_list args); + va_list args) G_GNUC_PRINTF(2, 0); gint g_vsprintf (gchar *string, gchar const *format, - va_list args); + va_list args) G_GNUC_PRINTF(2, 0); gint g_vasprintf (gchar **string, gchar const *format, - va_list args); + va_list args) G_GNUC_PRINTF(2, 0); G_END_DECLS
diff --git a/glib/gstrfuncs.h b/glib/gstrfuncs.h index 3142485..e0752d3 100644 --- a/glib/gstrfuncs.h +++ b/glib/gstrfuncs.h
@@ -188,7 +188,8 @@ gchar* g_strdup_printf (const gchar *format, ...) G_GNUC_PRINTF (1, 2) G_GNUC_MALLOC; gchar* g_strdup_vprintf (const gchar *format, - va_list args) G_GNUC_MALLOC; + va_list args) G_GNUC_PRINTF(1, 0) + G_GNUC_MALLOC; gchar* g_strndup (const gchar *str, gsize n) G_GNUC_MALLOC; gchar* g_strnfill (gsize length,
diff --git a/glib/gstring.h b/glib/gstring.h index a97aa4e..c6a11ae 100644 --- a/glib/gstring.h +++ b/glib/gstring.h
@@ -109,13 +109,15 @@ GString* g_string_ascii_up (GString *string); void g_string_vprintf (GString *string, const gchar *format, - va_list args); + va_list args) + G_GNUC_PRINTF(2, 0); void g_string_printf (GString *string, const gchar *format, ...) G_GNUC_PRINTF (2, 3); void g_string_append_vprintf (GString *string, const gchar *format, - va_list args); + va_list args) + G_GNUC_PRINTF(2, 0); void g_string_append_printf (GString *string, const gchar *format, ...) G_GNUC_PRINTF (2, 3);
diff --git a/glib/gutils.h b/glib/gutils.h index 8102f53..6c21bf7 100644 --- a/glib/gutils.h +++ b/glib/gutils.h
@@ -187,7 +187,8 @@ gint g_vsnprintf (gchar *string, gulong n, gchar const *format, - va_list args); + va_list args) + G_GNUC_PRINTF(3, 0); void g_nullify_pointer (gpointer *nullify_location);
diff --git a/glib/gvariant-parser.c b/glib/gvariant-parser.c index e2e85ab..d5c036a 100644 --- a/glib/gvariant-parser.c +++ b/glib/gvariant-parser.c
@@ -78,6 +78,7 @@ gint start, end; } SourceRef; +G_GNUC_PRINTF(5, 0) static void parser_set_error_va (GError **error, SourceRef *location, @@ -105,6 +106,7 @@ g_string_free (msg, TRUE); } +G_GNUC_PRINTF(5, 6) static void parser_set_error (GError **error, SourceRef *location, @@ -130,6 +132,7 @@ } TokenStream; +G_GNUC_PRINTF(5, 6) static void token_stream_set_error (TokenStream *stream, GError **error, @@ -525,6 +528,7 @@ ast->class->free (ast); } +G_GNUC_PRINTF(5, 6) static void ast_set_error (AST *ast, GError **error,
diff --git a/glib/tests/markup-escape.c b/glib/tests/markup-escape.c index 0cd90ef..b2de289 100644 --- a/glib/tests/markup-escape.c +++ b/glib/tests/markup-escape.c
@@ -96,6 +96,7 @@ escape_test (&t); } +G_GNUC_PRINTF(1, 3) static void test_format (const gchar *format, const gchar *expected,
diff --git a/glib/tests/string.c b/glib/tests/string.c index 454574b..ba55d3d 100644 --- a/glib/tests/string.c +++ b/glib/tests/string.c
@@ -106,6 +106,7 @@ g_string_free (string2, TRUE); } +G_GNUC_PRINTF(2, 3) static void my_string_printf (GString *string, const gchar *format,
diff --git a/glib/tests/test-printf.c b/glib/tests/test-printf.c index 10d0a1d..dbfc8fc 100644 --- a/glib/tests/test-printf.c +++ b/glib/tests/test-printf.c
@@ -942,6 +942,7 @@ #endif } +G_GNUC_PRINTF(1, 2) static gsize upper_bound (const gchar *format, ...) {