mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 15:36:17 +01:00
Add G_GNUC_PRINTF on all functions with format strings
This allows compilation with clang without 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
This commit is contained in:
parent
120834db5b
commit
c219181cb2
@ -46,6 +46,7 @@
|
||||
|
||||
#include "glibintl.h"
|
||||
|
||||
G_GNUC_PRINTF(1, 2)
|
||||
static void
|
||||
debug_print (const gchar *message, ...)
|
||||
{
|
||||
|
@ -469,6 +469,7 @@ keyring_lookup_entry (const gchar *cookie_context,
|
||||
}
|
||||
|
||||
/* function for logging important events that the system administrator should take notice of */
|
||||
G_GNUC_PRINTF(1, 2)
|
||||
static void
|
||||
_log (const gchar *message,
|
||||
...)
|
||||
|
@ -1346,6 +1346,7 @@ handle_start_service_by_name (_GFreedesktopDBus *object,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
G_GNUC_PRINTF(5, 6)
|
||||
static void
|
||||
return_error (Client *client, GDBusMessage *message,
|
||||
GQuark domain,
|
||||
|
@ -87,12 +87,12 @@ void g_dbus_error_set_dbus_error (GError **error,
|
||||
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
|
||||
|
@ -827,6 +827,7 @@ g_dbus_message_new_method_error_literal (GDBusMessage *method_call_message,
|
||||
*
|
||||
* Since: 2.26
|
||||
*/
|
||||
G_GNUC_PRINTF(3, 0)
|
||||
GDBusMessage *
|
||||
g_dbus_message_new_method_error_valist (GDBusMessage *method_call_message,
|
||||
const gchar *error_name,
|
||||
|
@ -55,12 +55,13 @@ void g_dbus_method_invocation_return_error (GDBusMetho
|
||||
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,
|
||||
|
@ -110,7 +110,8 @@ void g_simple_async_result_set_error_va (GSimpleAsyncResult
|
||||
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 @@ void g_simple_async_report_error_in_idle (GObject *object,
|
||||
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,
|
||||
|
@ -61,7 +61,7 @@ void g_task_report_new_error (gpointer source_object,
|
||||
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,
|
||||
|
@ -645,6 +645,7 @@ g_clear_error (GError **err)
|
||||
}
|
||||
}
|
||||
|
||||
G_GNUC_PRINTF(2, 0)
|
||||
static void
|
||||
g_error_add_prefix (gchar **string,
|
||||
const gchar *format,
|
||||
|
@ -60,7 +60,7 @@ GError* g_error_new_literal (GQuark domain,
|
||||
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);
|
||||
|
@ -403,6 +403,7 @@ set_error_literal (GMarkupParseContext *context,
|
||||
g_propagate_error (error, tmp_error);
|
||||
}
|
||||
|
||||
G_GNUC_PRINTF(4, 5)
|
||||
static void
|
||||
set_error (GMarkupParseContext *context,
|
||||
GError **error,
|
||||
@ -564,6 +565,7 @@ utf8_str (const gchar *utf8,
|
||||
return buf;
|
||||
}
|
||||
|
||||
G_GNUC_PRINTF(5, 6)
|
||||
static void
|
||||
set_unescape_error (GMarkupParseContext *context,
|
||||
GError **error,
|
||||
|
@ -214,7 +214,7 @@ gchar* g_markup_escape_text (const gchar *text,
|
||||
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
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ G_BEGIN_DECLS
|
||||
/* 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_log (const gchar *log_domain,
|
||||
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);
|
||||
|
@ -36,16 +36,16 @@ gint g_sprintf (gchar *string,
|
||||
...) 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
|
||||
|
||||
|
@ -188,7 +188,8 @@ gchar* g_strdup (const gchar *str) G_GNUC_MALLOC;
|
||||
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,
|
||||
|
@ -109,13 +109,15 @@ GString* g_string_ascii_down (GString *string);
|
||||
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);
|
||||
|
@ -187,7 +187,8 @@ gint g_snprintf (gchar *string,
|
||||
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);
|
||||
|
||||
|
@ -78,6 +78,7 @@ typedef struct
|
||||
gint start, end;
|
||||
} SourceRef;
|
||||
|
||||
G_GNUC_PRINTF(5, 0)
|
||||
static void
|
||||
parser_set_error_va (GError **error,
|
||||
SourceRef *location,
|
||||
@ -105,6 +106,7 @@ parser_set_error_va (GError **error,
|
||||
g_string_free (msg, TRUE);
|
||||
}
|
||||
|
||||
G_GNUC_PRINTF(5, 6)
|
||||
static void
|
||||
parser_set_error (GError **error,
|
||||
SourceRef *location,
|
||||
@ -130,6 +132,7 @@ typedef struct
|
||||
} TokenStream;
|
||||
|
||||
|
||||
G_GNUC_PRINTF(5, 6)
|
||||
static void
|
||||
token_stream_set_error (TokenStream *stream,
|
||||
GError **error,
|
||||
@ -525,6 +528,7 @@ ast_free (AST *ast)
|
||||
ast->class->free (ast);
|
||||
}
|
||||
|
||||
G_GNUC_PRINTF(5, 6)
|
||||
static void
|
||||
ast_set_error (AST *ast,
|
||||
GError **error,
|
||||
|
@ -96,6 +96,7 @@ unichar_test (gconstpointer d)
|
||||
escape_test (&t);
|
||||
}
|
||||
|
||||
G_GNUC_PRINTF(1, 3)
|
||||
static void
|
||||
test_format (const gchar *format,
|
||||
const gchar *expected,
|
||||
|
@ -106,6 +106,7 @@ test_string_new (void)
|
||||
g_string_free (string2, TRUE);
|
||||
}
|
||||
|
||||
G_GNUC_PRINTF(2, 3)
|
||||
static void
|
||||
my_string_printf (GString *string,
|
||||
const gchar *format,
|
||||
|
@ -942,6 +942,7 @@ _Pragma ("GCC diagnostic pop")
|
||||
#endif
|
||||
}
|
||||
|
||||
G_GNUC_PRINTF(1, 2)
|
||||
static gsize
|
||||
upper_bound (const gchar *format, ...)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user