GNOME Bugzilla – Bug 343346
[0.11] add G_GNUC_NULL_TERMINATED to gst_structure_empty_new()
Last modified: 2011-10-27 13:59:05 UTC
this patch adds G_GNUC_NULL_TERMINATED in the few places were it was missing. were needed, NULL is passed two times to avoid the warning "not enough variable arguments to fit a sentinel"
Created attachment 66450 [details] [review] patch for G_GNUC_NULL_TERMINATED
I'm not sure we can actually do this, although it would be nice. In existing apps, it is valid to do gst_structure_new ("Name", NULL), because it internally checks for the first fieldname being NULL, even though it's separate from the varargs. Of course, such code is better off using gst_structure_empty_new for a little more efficiency. However, adding the argument means that existing code using this idiom will fail to compile, even though it's valid. Ditto for the gst_caps_new methods. I think we have to punt this to 0.11.
Created attachment 66467 [details] [review] patch which uses gst_structure_empty_new instead of passing NULL, NULL
can you commit this _empty_new fixes without the G_GNUC_NULL_TERMINATED, for now?
> However, adding the argument means that existing code using this idiom will > fail to compile, even though it's valid. Ditto for the gst_caps_new methods. > > I think we have to punt this to 0.11. Really? I thought all that adding G_GNUC_NULL_TERMINATED did was make the compiler spew a warning if the argument list doesn't end as expected, so compilation should only fail if -Werror is being used, no?
Yes, I think you're right - but gst_structure_new (name, NULL) is legitimate and correctly behaving code, and we'd be breaking their compilation with a bogus and misleading warning.
commit c00c8903caf981651b7db0d876ad40e96b98df9e Author: Tim-Philipp Müller <tim.muller@collabora.co.uk> Date: Thu Oct 27 13:25:08 2011 +0100 structure: use G_GNUC_NULL_TERMINATED for gst_structure_new() If you get a warning, use gst_structure_empty_new(). https://bugzilla.gnome.org/show_bug.cgi?id=343346
commit 3406549cf66a8b8ea9a9500e8cf5132a6bd806e2 Author: Johan Boulé <bohan.gnome@retropaganda.info> Date: Thu Oct 27 14:56:24 2011 +0100 caps: use G_GNUC_NULL_TERMINATED for gst_caps_new_simple() and gst_caps_new_full() If you get warnings, use gst_caps_new_empty(). https://bugzilla.gnome.org/show_bug.cgi?id=343346