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 791215 - C warning in generated code for gtk_message_dialog_new
C warning in generated code for gtk_message_dialog_new
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Bindings
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2017-12-04 16:47 UTC by Philipp Wolfer
Modified: 2017-12-06 19:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
vala: Don't transform an explicit "null" into a valid format-string (2.61 KB, patch)
2017-12-06 15:24 UTC, Rico Tzschichholz
committed Details | Review

Description Philipp Wolfer 2017-12-04 16:47:03 UTC
Calling Gtk.MessageDialog with an empty string for message_format like this:

var msg = new Gtk.MessageDialog (parent, Gtk.DialogFlags.MODAL,
        Gtk.MessageType.WARNING, Gtk.ButtonsType.OK, "");

The generated code will produce a compilation warning:

src/application.c:1064:118: warning: zero-length gnu_printf format string [-Wformat-zero-length]
  _tmp3_ = (GtkMessageDialog*) gtk_message_dialog_new (_tmp2_, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "");


According to the documentation gtk_message_dialog_new could be called with null for message_format, so trying this:

var msg = new Gtk.MessageDialog (parent, Gtk.DialogFlags.MODAL,
        Gtk.MessageType.WARNING, Gtk.ButtonsType.OK, null);

But now the generated code will instead pass "%s" as message_format with a single parameter null, resulting in the following warnings:

src/application.c:1064:2: warning: reading through null pointer (argument 6) [-Wformat=]
  _tmp3_ = (GtkMessageDialog*) gtk_message_dialog_new (_tmp2_, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "%s", NULL);
  ^~~~~~
src/application.c:1064:120: warning: format '%s' expects argument of type 'char *', but argument 6 has type 'void *' [-Wformat=]
  _tmp3_ = (GtkMessageDialog*) gtk_message_dialog_new (_tmp2_, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "%s", NULL);
Comment 1 Rico Tzschichholz 2017-12-06 15:24:51 UTC
Created attachment 365121 [details] [review]
vala: Don't transform an explicit "null" into a valid format-string
Comment 2 Rico Tzschichholz 2017-12-06 19:08:48 UTC
Attachment 365121 [details] pushed as 84c8584 - vala: Don't transform an explicit "null" into a valid format-string