GNOME Bugzilla – Bug 653137
Warnings in Gstreamer (core) with Clang compiler
Last modified: 2011-09-13 22:10: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
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.
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.
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.
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.
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.
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
The waveform < 0 thing is weird, I thought an enum was like an int.
> 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.
But what happens if I remove the <0 check and then do: gst_lfo_control_source_set_waveform (self, (GstLFOWaveform) -1));
The same that happens when you call the function with a random pointer..
(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).
(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.
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.
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.