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 752052 - appsrc: Initialize min and max vars in get_property() for fix compiler warnings
appsrc: Initialize min and max vars in get_property() for fix compiler warnings
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal minor
: 1.11.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-07-07 08:37 UTC by Tobias Mueller
Modified: 2016-12-25 13:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (1.57 KB, patch)
2015-07-07 08:37 UTC, Tobias Mueller
committed Details | Review

Description Tobias Mueller 2015-07-07 08:37:15 UTC
Created attachment 306981 [details] [review]
patch

gstappsrc:  Initializing min and max in gst_app_src_get_property
    
    This gets rid of this compiler message:
    
    gstappsrc.c: In function 'gst_app_src_get_property':
    gstappsrc.c:741:7: error: 'max' may be used uninitialized in this
    function [-Werror=maybe-uninitialized]
           g_value_set_int64 (value, max);
           ^
    gstappsrc.c:733:7: error: 'min' may be used uninitialized in this
    function [-Werror=maybe-uninitialized]
           g_value_set_int64 (value, min);
           ^
    
    GCC's analysis is correct.  If appsrc is not GST_IS_APP_SRC, then
    gst_app_src_get_latency will return without setting min and max.
Comment 1 Sebastian Dröge (slomo) 2015-07-07 10:23:49 UTC
Review of attachment 306981 [details] [review]:

Actually, this case should never really happen. Add some g_return_if_fail() at the top of get_property().
Comment 2 Tobias Mueller 2015-07-07 12:47:22 UTC
(In reply to Sebastian Dröge (slomo) from comment #1)
> Add some g_return_if_fail() at the top of get_property().
I'm afraid that this doesn't make the compiler happy.

The only thing that I could get to work is this:

  GstAppSrc *appsrc = GST_APP_SRC_CAST (object);
  GstAppSrcPrivate *priv = appsrc->priv;
  //g_return_if_fail (GST_IS_APP_SRC (object));
  //g_return_if_fail (GST_IS_APP_SRC (appsrc));
  if  (!GST_IS_APP_SRC (object)) return;
  else
  if  (!GST_IS_APP_SRC (appsrc)) return;
  else

  switch (prop_id) {
    case PROP_CAPS:
    ...

note the two if statements.  I don't understand why GCC requires both.

Also note that g_return_if_fail does not seem to get us anything.  I guess this is because it is a macro which can compile to (void)0;.  But I'm only guessing.

An easy way out is to assume that GCC is just wrong and to ignore this bug report.  But I'd be careful assuming that...
Comment 3 Tim-Philipp Müller 2015-07-07 12:55:23 UTC
Are you compiling with -DG_DISABLE_CHECKS or somesuch?
Comment 4 Tim-Philipp Müller 2016-12-25 13:21:29 UTC
Thanks for the bug report and the patch!

> An easy way out is to assume that GCC is just wrong and to ignore
> this bug report.  But I'd be careful assuming that...

GCC is most certainly wrong in this case, but it can't know that here. This is a GObject vfunc, so we can be fairly sure that this really is a GstAppSrc. IS_APP_SRC checks in get/set_property funcs don't really make sense IMHO and I tend to remove them whenever I see them.

Since we compile with -Werror we just need to work around these false-positives as we do in other places.


commit 57ff3ea72fd30fa900c069bb948745f3bfdff9d1
Author: Tobias Mueller <muelli@cryptobitch.de>
Date:   Thu Jul 2 07:23:23 2015 +0200

    appsrc: fix compiler warning
    
    Initialize min and max _get_property() to gets rid of these
    compiler warnings:
    
    gstappsrc.c:741:7: error: 'max' may be used uninitialized in this function
           g_value_set_int64 (value, max);
           ^
    gstappsrc.c:733:7: error: 'min' may be used uninitialized in this function
           g_value_set_int64 (value, min);
           ^
    Which happens because gcc doesn't know that GST_IS_APP_SRC will never
    fail here.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=752052