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 303106 - gst_structure_get_uint() contra gcc4 signedness madness?
gst_structure_get_uint() contra gcc4 signedness madness?
Status: RESOLVED INVALID
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
0.8.8
Other Linux
: Normal enhancement
: NONE
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2005-05-05 09:49 UTC by Tim-Philipp Müller
Modified: 2005-08-26 00:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed patch (2.66 KB, patch)
2005-05-05 09:50 UTC, Tim-Philipp Müller
rejected Details | Review

Description Tim-Philipp Müller 2005-05-05 09:49:18 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
Comment 1 Tim-Philipp Müller 2005-05-05 09:50:30 UTC
Created attachment 46047 [details] [review]
proposed patch
Comment 2 Tim-Philipp Müller 2005-05-05 12:55:21 UTC
Never mind, after more discussion on IRC the agreement was to just convert the
unsigned ints to int.

Cheers
 -Tim