After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 781125 - gio-tool: Fix errors format string
gio-tool: Fix errors format string
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2017-04-10 11:09 UTC by Víctor Manuel Jáquez Leal
Modified: 2017-04-10 13:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gio-tool: Fix errors format string (4.23 KB, patch)
2017-04-10 11:09 UTC, Víctor Manuel Jáquez Leal
none Details | Review
gio-tool: Fix errors format string (4.21 KB, patch)
2017-04-10 11:25 UTC, Víctor Manuel Jáquez Leal
committed Details | Review

Description Víctor Manuel Jáquez Leal 2017-04-10 11:09:52 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.
Comment 1 Víctor Manuel Jáquez Leal 2017-04-10 11:09:56 UTC
Created attachment 349596 [details] [review]
gio-tool: Fix errors format string
Comment 2 Emmanuele Bassi (:ebassi) 2017-04-10 11:17:00 UTC
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
Comment 3 Víctor Manuel Jáquez Leal 2017-04-10 11:25:08 UTC
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.
Comment 4 Víctor Manuel Jáquez Leal 2017-04-10 11:26:01 UTC
(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.
Comment 5 Emmanuele Bassi (:ebassi) 2017-04-10 13:05:54 UTC
Review of attachment 349599 [details] [review]:

Looks good to me, thanks!
Comment 6 Víctor Manuel Jáquez Leal 2017-04-10 13:44:30 UTC
Attachment 349599 [details] pushed as 3d7534e - gio-tool: Fix errors format string