mirror of
https://github.com/flatpak/flatpak.git
synced 2026-04-03 23:04:49 -04:00
Add missing G_GNUC_PRINTF attributes
This allows callers to be checked for mismatches between format string and arguments, and also means gcc can assume that the format string and the arguments match up correctly when forwarding them to functions like g_strdup_vprintf, removing the need to suppress -Wformat-nonliteral warnings. Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
committed by
Alexander Larsson
parent
0592caca8a
commit
17b6c31c7c
@@ -36,10 +36,7 @@ flatpak_completion_debug (const gchar *format, ...)
|
||||
static FILE *f = NULL;
|
||||
|
||||
va_start (var_args, format);
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
s = g_strdup_vprintf (format, var_args);
|
||||
#pragma GCC diagnostic pop
|
||||
if (f == NULL)
|
||||
f = fopen ("/tmp/flatpak-completion-debug.txt", "a+");
|
||||
fprintf (f, "%s\n", s);
|
||||
|
||||
@@ -41,7 +41,7 @@ struct FlatpakCompletion
|
||||
};
|
||||
|
||||
void flatpak_completion_debug (const gchar *format,
|
||||
...);
|
||||
...) G_GNUC_PRINTF (1, 2);
|
||||
|
||||
FlatpakCompletion *flatpak_completion_new (const char *arg_line,
|
||||
const char *arg_point,
|
||||
|
||||
@@ -274,12 +274,9 @@ flatpak_table_printer_append_with_comma_printf (FlatpakTablePrinter *printer,
|
||||
va_list var_args;
|
||||
g_autofree char *s = NULL;
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
va_start (var_args, format);
|
||||
s = g_strdup_vprintf (format, var_args);
|
||||
va_end (var_args);
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
flatpak_table_printer_append_with_comma (printer, s);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ void flatpak_table_printer_append_with_comma (FlatpakTablePrinter
|
||||
const char *text);
|
||||
void flatpak_table_printer_append_with_comma_printf (FlatpakTablePrinter *printer,
|
||||
const char *format,
|
||||
...);
|
||||
...) G_GNUC_PRINTF (2, 3);
|
||||
void flatpak_table_printer_set_key (FlatpakTablePrinter *printer,
|
||||
const char *key);
|
||||
void flatpak_table_printer_finish_row (FlatpakTablePrinter *printer);
|
||||
|
||||
@@ -179,7 +179,7 @@ static void flatpak_dir_log (FlatpakDir *self,
|
||||
const char *old_commit,
|
||||
const char *url,
|
||||
const char *format,
|
||||
...);
|
||||
...) G_GNUC_PRINTF (12, 13);
|
||||
|
||||
#define flatpak_dir_log(self, change, remote, ref, commit, old_commit, url, format, ...) \
|
||||
(flatpak_dir_log) (self, __FILE__, __LINE__, __FUNCTION__, \
|
||||
@@ -15689,11 +15689,7 @@ static void
|
||||
len = g_snprintf (message, sizeof (message), "%s: ", installation);
|
||||
|
||||
va_start (args, format);
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
g_vsnprintf (message + len, sizeof (message) - len, format, args);
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
va_end (args);
|
||||
|
||||
/* See systemd.journal-fields(7) for the meaning of the
|
||||
|
||||
Reference in New Issue
Block a user