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 705987 - Gst.Base.Adapter.take() and map() are thought to have an out gsize parameter
Gst.Base.Adapter.take() and map() are thought to have an out gsize parameter
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Bindings: GTK+ GStreamer WebKitGTK+
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2013-08-14 12:29 UTC by Marcin Mikołajczyk
Modified: 2017-03-08 09:41 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Example file triggering a bug (282 bytes, text/x-vala)
2013-08-14 12:29 UTC, Marcin Mikołajczyk
Details

Description Marcin Mikołajczyk 2013-08-14 12:29:58 UTC
Created attachment 251609 [details]
Example file triggering a bug

Using Gstreamer 1.0 with Vala, valac thinks that Gst.Adapter.take() and Gst.Adapter.map() have an out gsize parameter and produces invalid code. 

In C, these functions have a signature of gpointer name(GstAdapter* adapter, gsize nbytes). Valac assumes the nbytes parameter to be an out parameter containing length of returned array.

Generated C code looks like this:

gsize size;
GstAdapter* adapter = NULL;
adapter = gst_adapter_new();
guint8* arr = NULL;
arr = gst_adapter_take(adapter, &size);

Upon compilation of provided example.vala file, a warning
example.vala.c:67:2: warning: passing argument 2 of ‘gst_adapter_take’ makes integer from pointer without a cast [enabled by default]
  _tmp5_ = gst_adapter_take (adapter, &_tmp4_);
  ^
In file included from example.vala.c:10:0:
/usr/include/gstreamer-1.0/gst/base/gstadapter.h:60:25: note: expected ‘gsize’ but argument is of type ‘gsize *’
 gpointer gst_adapter_take (GstAdapter *adapter, gsize nbytes);
is generated.

I asked about this issue on #vala IRC channel and confirmed that these functions (take and map) should take one parameter in Vala.
Comment 1 Rico Tzschichholz 2017-03-08 09:41:47 UTC
commit b3e02e1ecd76cf0443287ac6ef99d18be188e840
Author: Rico Tzschichholz <ricotz@ubuntu.com>
Date:   Wed Mar 8 09:50:02 2017 +0100

    gstreamer-1.0: Fix Gst.Base.Adapter.map/take bindings
    
    There is no explicit array-length returned while it is implicitly related
    to the in-parameter those methods are taking.