GNOME Bugzilla – Bug 781125
gio-tool: Fix errors format string
Last modified: 2017-04-10 13:44:36 UTC
Compiling with clang 3.8.1-18 (debian, x86_64) I ran across this error: gio-tool.c:40:31: error: format string is not a string literal [-Werror,-Wformat-nonliteral] message = g_strdup_vprintf (format, args); ^~~~~~ gio-tool.c:55:31: error: format string is not a string literal [-Werror,-Wformat-nonliteral] message = g_strdup_vprintf (format, args); ^~~~~~ 2 errors generated. To fix the first one, related with the function print_error(), this patch adds to the function prototype a compiler's attribute. For the second one, since the usage of that function is to print one string and the format is already provided, the patch simplifies the function by no receiving variadic arguments.
Created attachment 349596 [details] [review] gio-tool: Fix errors format string
Review of attachment 349596 [details] [review]: Looks okay, with a minor nitpick. ::: gio/gio-tool.h @@ +23,2 @@ void print_error (const gchar *format, + ...) __attribute__((format(printf, 1, 2))); You should use the G_GNUC_PRINTF() macro: https://developer.gnome.org/glib/stable/glib-Miscellaneous-Macros.html#G-GNUC-PRINTF:CAPS
Created attachment 349599 [details] [review] gio-tool: Fix errors format string Compiling with clang 3.8.1-18 (debian, x86_64) I ran across this error: gio-tool.c:40:31: error: format string is not a string literal [-Werror,-Wformat-nonliteral] message = g_strdup_vprintf (format, args); ^~~~~~ gio-tool.c:55:31: error: format string is not a string literal [-Werror,-Wformat-nonliteral] message = g_strdup_vprintf (format, args); ^~~~~~ 2 errors generated. To fix the first one, related with the function print_error(), this patch adds to the function prototype a compiler's attribute. For the second one, since the usage of that function is to print one string and the format is already provided, the patch simplifies the function by no receiving variadic arguments.
(In reply to Emmanuele Bassi (:ebassi) from comment #2) > Review of attachment 349596 [details] [review] [review]: > > Looks okay, with a minor nitpick. > > https://developer.gnome.org/glib/stable/glib-Miscellaneous-Macros.html#G- > GNUC-PRINTF:CAPS Done! Thanks Emmanuele.
Review of attachment 349599 [details] [review]: Looks good to me, thanks!
Attachment 349599 [details] pushed as 3d7534e - gio-tool: Fix errors format string