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 653137 - Warnings in Gstreamer (core) with Clang compiler
Warnings in Gstreamer (core) with Clang compiler
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other FreeBSD
: Normal normal
: 0.10.36
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2011-06-21 22:28 UTC by Koop Mast (kwm)
Modified: 2011-09-13 22:10 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
put seekstop in a logical place for me. Not sure if it is correct. (685 bytes, patch)
2011-06-21 22:32 UTC, Koop Mast (kwm)
committed Details | Review
Remove redundant () (604 bytes, patch)
2011-06-21 22:33 UTC, Koop Mast (kwm)
committed Details | Review

Description Koop Mast (kwm) 2011-06-21 22:28:16 UTC
The warnings below are from the 0.11 branch but a quick check shows that most if not all are also in the 0.10 tree. The Clang version used to produces these warnings is:

> clang -v
FreeBSD clang version 3.0 (trunk 132879) 20110612
Target: i386-unknown-freebsd9.0
Thread model: posix
Comment 1 Koop Mast (kwm) 2011-06-21 22:29:51 UTC
gstsegment.c:343:20: error: implicit conversion from enumeration type
      'GstSeekFlags' to different enumeration type 'GstSegmentFlags'
      [-Werror,-Wconversion]
  segment->flags = flags;
                 ~ ^~~~~
1 error generated.

I have no idea how to deal with this. Casting it to GstSegmentFlags works but I have no idea how correct that is.
Comment 2 Koop Mast (kwm) 2011-06-21 22:32:20 UTC
Created attachment 190396 [details] [review]
put seekstop in a logical place for me. Not sure if it is correct.

gstbaseparse.c:3745:34: error: self-comparison always evaluates to true
      [-Werror,-Wtautological-compare]
    if (seekstop >= 0 && seekpos <= seekpos)
                                 ^
1 error generated.
Comment 3 Koop Mast (kwm) 2011-06-21 22:33:40 UTC
Created attachment 190397 [details] [review]
Remove redundant ()

gstbasetransform.c:1980:14: error: equality comparison with extraneous
      parentheses [-Werror,-Wparentheses]
    if ((ret == GST_FLOW_OK)) {
         ~~~~^~~~~~~~~~~~~~
gstbasetransform.c:1980:14: note: remove extraneous parentheses around the
      comparison to silence this warning
    if ((ret == GST_FLOW_OK)) {
        ~    ^             ~
gstbasetransform.c:1980:14: note: use '=' to turn this equality comparison into
      an assignment
    if ((ret == GST_FLOW_OK)) {
             ^~
             =
1 error generated.
Comment 4 Koop Mast (kwm) 2011-06-21 22:35:10 UTC
gstlfocontrolsource.c:652:45: error: comparison of unsigned enum expression < 0
      is always false [-Werror,-Wtautological-compare]
  if (waveform >= num_waveforms || waveform < 0) {
                                   ~~~~~~~~ ^ ~
1 error generated.
Comment 5 Koop Mast (kwm) 2011-06-21 22:35:28 UTC
gsttee.c:812:27: error: use of logical && with constant operand; switch to
      bitwise & or remove constant [-Werror,-Wconstant-logical-operand]
  tee->sink_mode = active && GST_ACTIVATE_PULL;
                          ^  ~~~~~~~~~~~~~~~~~
1 error generated.
Comment 6 Wim Taymans 2011-06-22 15:19:31 UTC
Thanks, commited these:

commit 73983b3ec18497ad145b716b06268c8ad66c65af
Author: Koop Mast <kwm at FreeBSD.org>
Date:   Wed Jun 22 17:12:34 2011 +0200

    tee: use & instead of && for masking bits
    
    See #653137

commit c1983b9939b0fc0f069dee2d109533ccc5eabe71
Author: Koop Mast <kwm at FreeBSD.org>
Date:   Wed Jun 22 17:09:52 2011 +0200

    basetransform: remove redundant ()
    
    See #653137

commit ef1b2b0e8feb199988ee18aa617600c256c307b5
Author: Koop Mast <kwm at FreeBSD.org>
Date:   Wed Jun 22 17:05:27 2011 +0200

    baseparse: fix seekstop
    
    See #653137

commit 4fe5dd2b9da82d1bb7c6808f29b2b0c60fea6882
Author: Koop Mast <kwm at FreeBSD.org>
Date:   Wed Jun 22 16:58:53 2011 +0200

    segment: cast to right type
    
    See #653137
Comment 7 Wim Taymans 2011-06-22 15:20:06 UTC
The waveform < 0 thing is weird, I thought an enum was like an int.
Comment 8 Tim-Philipp Müller 2011-06-22 15:28:52 UTC
> The waveform < 0 thing is weird, I thought an enum was like an int.

Since it's an enum the compiler knows that it'll never be < 0, so the < 0 check should just be removed really.
Comment 9 Wim Taymans 2011-06-22 15:39:13 UTC
But what happens if I remove the <0 check and then do: 

gst_lfo_control_source_set_waveform (self, (GstLFOWaveform) -1));
Comment 10 Tim-Philipp Müller 2011-06-22 15:48:22 UTC
The same that happens when you call the function with a random pointer..
Comment 11 David Schleef 2011-06-24 19:09:45 UTC
(In reply to comment #7)
> The waveform < 0 thing is weird, I thought an enum was like an int.

It is implementation defined what the underlying type used to implement a specific enum is, so it could be int, unsigned int, or even short int, and could theoretically vary between different enum types.  I've never seen a compiler where it's not int (except with -fshort-enums).
Comment 12 Sebastian Dröge (slomo) 2011-06-26 12:33:18 UTC
(In reply to comment #10)
> The same that happens when you call the function with a random pointer..

But guard against that it would still be nice to have this check there. Maybe cast the enum to an int before checking if it's smaller than 0.
Comment 13 Vincent Penquerc'h 2011-08-09 07:46:17 UTC
If you add an enum with value -1, then the warning should go away, and you can use that new enum value instead of (GstLFOWaveform) -1.
Comment 14 Tim-Philipp Müller 2011-09-13 22:10:16 UTC
Let's try this then:

 commit 46e401b6d940c99bf1b5b0a3ba33f7a29a6a29b3
 Author: Tim-Philipp Müller <tim.muller@collabora.co.uk>
 Date:   Tue Sep 13 23:04:09 2011 +0100

    lfocontrolsource: fix clang compiler warning
    
    Cast enum to int before checking for negative values, which are
    impossible according to the enum list.
    
    gstlfocontrolsource.c:652:45: error: comparison of unsigned enum expression < 0
          is always false [-Werror,-Wtautological-compare]
      if (waveform >= num_waveforms || waveform < 0) {
                                       ~~~~~~~~ ^ ~
    
    https://bugzilla.gnome.org/show_bug.cgi?id=653137


If that doesn't work, I'd just remove the < 0 check.