GNOME Bugzilla – Bug 303106
gst_structure_get_uint() contra gcc4 signedness madness?
Last modified: 2005-08-26 00:13:20 UTC
I think we should have a gst_structure_get_uint() that we can cleanly use with unsigned integer pointers as out parameter with gcc4. Check out bug #303011 and gst/speed/gstspeed.[ch] for the problem. We have struct MyPlugin { ... guint channels; guint rate; ... }; and then do ret = gst_structure_get_int (s, "channels", &filter->channels); ret = gst_structure_get_int (s, "rate", &filter->rate); etc. and gcc4 barfs. And there must be hundreds of those in the plugins tree. Now, I think it's simply wrong and ugly to cast those out parameter pointers. Similarly I find it unacceptable to change the struct members to gint (if I have variables that can never be negative, they should stay unsigned IMHO, not to mention that changing them might trigger other signed/unsigned complaints elsewehre). The problem is of course that the underlying value types G_TYPE_INT and G_TYPE_UINT are not compatible, so g_value_get_* will complain if the value holds a type of a different signedness. So here's my suggestion, which I know is evil, but still think it's the best way: add gst_structure_get_uint() and make both _get_uint() and _get_int() handle both G_TYPE_INT and G_TYPE_UINT fields and cast them as appropriate. At least performance-wise this shouldn't be a problem, as those two types are fundamental types and thus integer constants. Proposed patch attached. Flame ahead :P Cheers -Tim
Created attachment 46047 [details] [review] proposed patch
Never mind, after more discussion on IRC the agreement was to just convert the unsigned ints to int. Cheers -Tim