Closed Bug 998867 Opened 5 years ago Closed 5 years ago

clang 3.4 build warning: MediaStreamGraph.cpp:1286:28: warning: variable 'sampleRate' is used uninitialized whenever 'for' loop exits because its condition is false [-Wsometimes-uninitialized]

Categories

(Core :: Audio/Video, defect)

defect
Not set

Tracking

()

RESOLVED DUPLICATE of bug 998179

People

(Reporter: dholbert, Unassigned)

References

(Blocks 1 open bug)

Details

New clang warning (with Clang 3.4 on Ubuntu 14.04):
{
 0:04.50 In file included from $OBJDIR/content/media/Unified_cpp_content_media1.cpp:67:
 0:04.50 Warning: -Wsometimes-uninitialized in $SRCDIR/content/media/MediaStreamGraph.cpp: variable 'sampleRate' is used uninitialized whenever 'for' loop exits because its condition is false
 0:04.50 $SRCDIR/content/media/MediaStreamGraph.cpp:1286:28: warning: variable 'sampleRate' is used uninitialized whenever 'for' loop exits because its condition is false [-Wsometimes-uninitialized]
 0:04.50       for (uint32_t i = 0; i < mStreams.Length(); ++i) {
 0:04.50                            ^~~~~~~~~~~~~~~~~~~~~
 0:04.50 $SRCDIR/content/media/MediaStreamGraph.cpp:1299:31: note: uninitialized use occurs here
 0:04.50       RoundUpToNextAudioBlock(sampleRate, mCurrentTime + MillisecondsToMediaTime(AUDIO_TARGET_MS));
 0:04.50                               ^~~~~~~~~~
 0:04.50 $SRCDIR/content/media/MediaStreamGraph.cpp:1286:28: note: remove the condition if it is always true
 0:04.50       for (uint32_t i = 0; i < mStreams.Length(); ++i) {
 0:04.50                            ^~~~~~~~~~~~~~~~~~~~~
 0:04.50 $SRCDIR/content/media/MediaStreamGraph.cpp:1283:25: note: initialize the variable 'sampleRate' to silence this warning
 0:04.50     TrackRate sampleRate;
}

This looks like a real issue, introduced a few days ago by http://hg.mozilla.org/mozilla-central/rev/d53bccef7150 (bug 997229), which removed the initialization of this variable.

Paul, is there a reasonable default value here?  (or can we otherwise tweak the logic to ensure that it's initialized?)
Summary: clang 3.4 build warning: → clang 3.4 build warning: MediaStreamGraph.cpp: variable 'sampleRate' is used uninitialized whenever 'for' loop exits because its condition is false
Flags: needinfo?(paul)
Summary: clang 3.4 build warning: MediaStreamGraph.cpp: variable 'sampleRate' is used uninitialized whenever 'for' loop exits because its condition is false → clang 3.4 build warning: MediaStreamGraph.cpp:1286:28: warning: variable 'sampleRate' is used uninitialized whenever 'for' loop exits because its condition is false [-Wsometimes-uninitialized]
Oh, looks like cpeterson filed this already. Sorry for the dupe-noise.
Status: NEW → RESOLVED
Closed: 5 years ago
Flags: needinfo?(paul)
Resolution: --- → DUPLICATE
Duplicate of bug: 998179
You need to log in before you can comment on or make changes to this bug.