GNOME Bugzilla – Bug 582715
gcc warnings about unitialized
Last modified: 2009-05-15 10:03:29 UTC
I'm jhbuilding from git so -Werror is enabled, which turns these warnings from -Wall into an error. Firstly in gst/flv: gstflvmux.c: In function `gst_flv_mux_collected': gstflvmux.c:607: warning: 't' might be used uninitialized in this function The code is: const gchar *t; if (!strcmp (tag_name, GST_TAG_ARTIST)) t = "creator"; else if (!strcmp (tag_name, GST_TAG_TITLE)) t = "title"; And in sys/sunaudio: gstsunaudiomixerctrl.c: In function `gst_sunaudiomixer_ctrl_get_volume': gstsunaudiomixerctrl.c:179: warning: 'gain' might be used uninitialized in this function gstsunaudiomixerctrl.c:179: warning: 'balance' might be used uninitialized in this function The code is a switch statement that has no default case.
I wonder why gcc warns about the flvmux variable... my gcc detects that it will be always set to something. Whatever, patch follows ;)
Created attachment 134687 [details] [review] good-compiler-warnings.diff Please test this with your gcc, in theory it should now be clear that the variables are only used initialized
It's an old version of gcc, 3.4. The flv patch works, the sunaudio one doesn't because g_assert_not_reached is undeclared.
Created attachment 134688 [details] [review] good-compiler-warnings.diff Right, parenthesis were missing after g_assert_not_reached, sorry.
Created attachment 134690 [details] [review] more gcc fixes That works, and then this patch fixes a few more warnings. Now I'm getting this warning in sys/v4l2: v4l2_calls.c: In function `gst_v4l2_fill_lists': v4l2_calls.c:121: warning: missing braces around initializer v4l2_calls.c:121: warning: (near initialization for `input.name') v4l2_calls.c:144: warning: unsigned int format, different type arg (arg 8)
The 144 one needs a cast to guint, 121 proably needs to be {{ 0, }, } or something like that.
Created attachment 134694 [details] [review] final fixes Those fixes work, here's a final patch. Thanks.
Actually the change to add the brackets is not correct. It will result in a warning on Linux. I've changed it to a memset locally... apart from that we should get this committed ;)
commit 08a3f44d81cf715d40b57d523418997b47e2c506 Author: James Andrewartha <trs80@ucc.gu.uwa.edu.au> Date: Fri May 15 08:44:39 2009 +0200 Fix compiler warnings Fixes bug #582715.