GNOME Bugzilla – Bug 791215
C warning in generated code for gtk_message_dialog_new
Last modified: 2017-12-06 19:08:54 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);
Created attachment 365121 [details] [review] vala: Don't transform an explicit "null" into a valid format-string
Attachment 365121 [details] pushed as 84c8584 - vala: Don't transform an explicit "null" into a valid format-string