1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-11 23:54:18 +00:00

A few tweaks to help the clang static analyser avoid false alarms.

This commit is contained in:
jules 2013-09-26 16:17:36 +01:00
parent a9d15e04da
commit 8809efcb7a
4 changed files with 30 additions and 20 deletions

View file

@ -133,31 +133,31 @@ public:
trackUnitsPerFrame = GetMovieTimeScale (movie) * samplesPerFrame
/ GetMediaTimeScale (media);
OSStatus err = MovieAudioExtractionBegin (movie, 0, &extractor);
MovieAudioExtractionBegin (movie, 0, &extractor);
unsigned long output_layout_size;
err = MovieAudioExtractionGetPropertyInfo (extractor,
kQTPropertyClass_MovieAudioExtraction_Audio,
kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout,
0, &output_layout_size, 0);
OSStatus err = MovieAudioExtractionGetPropertyInfo (extractor,
kQTPropertyClass_MovieAudioExtraction_Audio,
kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout,
0, &output_layout_size, 0);
if (err != noErr)
return;
HeapBlock <AudioChannelLayout> qt_audio_channel_layout;
qt_audio_channel_layout.calloc (output_layout_size, 1);
err = MovieAudioExtractionGetProperty (extractor,
kQTPropertyClass_MovieAudioExtraction_Audio,
kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout,
output_layout_size, qt_audio_channel_layout, 0);
MovieAudioExtractionGetProperty (extractor,
kQTPropertyClass_MovieAudioExtraction_Audio,
kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout,
output_layout_size, qt_audio_channel_layout, 0);
qt_audio_channel_layout[0].mChannelLayoutTag = kAudioChannelLayoutTag_Stereo;
err = MovieAudioExtractionSetProperty (extractor,
kQTPropertyClass_MovieAudioExtraction_Audio,
kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout,
output_layout_size,
qt_audio_channel_layout);
MovieAudioExtractionSetProperty (extractor,
kQTPropertyClass_MovieAudioExtraction_Audio,
kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout,
output_layout_size,
qt_audio_channel_layout);
err = MovieAudioExtractionGetProperty (extractor,
kQTPropertyClass_MovieAudioExtraction_Audio,

View file

@ -279,8 +279,7 @@ public:
inline ElementType getFirst() const
{
const ScopedLockType lock (getLock());
return (numUsed > 0) ? data.elements [0]
: ElementType();
return numUsed > 0 ? data.elements[0] : ElementType();
}
/** Returns the last element in the array, or a default value if the array is empty.
@ -290,8 +289,7 @@ public:
inline ElementType getLast() const
{
const ScopedLockType lock (getLock());
return (numUsed > 0) ? data.elements [numUsed - 1]
: ElementType();
return numUsed > 0 ? data.elements[numUsed - 1] : ElementType();
}
/** Returns a pointer to the actual array data.
@ -317,6 +315,11 @@ public:
*/
inline ElementType* end() const noexcept
{
#if JUCE_DEBUG
if (data.elements == nullptr || numUsed <= 0) // (to keep static analysers happy)
return data.elements;
#endif
return data.elements + numUsed;
}
@ -519,6 +522,7 @@ public:
if (isPositiveAndBelow (indexToChange, numUsed))
{
jassert (data.elements != nullptr);
data.elements [indexToChange] = newValue;
}
else if (indexToChange >= 0)

View file

@ -167,7 +167,7 @@ public:
{
const ScopedLockType lock (getLock());
return numUsed > 0 ? data.elements [0]
: static_cast <ObjectClass*> (nullptr);
: static_cast<ObjectClass*> (nullptr);
}
/** Returns a pointer to the last object in the array.
@ -179,7 +179,7 @@ public:
{
const ScopedLockType lock (getLock());
return numUsed > 0 ? data.elements [numUsed - 1]
: static_cast <ObjectClass*> (nullptr);
: static_cast<ObjectClass*> (nullptr);
}
/** Returns a pointer to the actual array data.
@ -205,6 +205,11 @@ public:
*/
inline ObjectClass** end() const noexcept
{
#if JUCE_DEBUG
if (data.elements == nullptr || numUsed <= 0) // (to keep static analysers happy)
return data.elements;
#endif
return data.elements + numUsed;
}

View file

@ -180,6 +180,7 @@ public:
inline ObjectClass* getObjectPointer (const int index) const noexcept
{
const ScopedLockType lock (getLock());
jassert (isPositiveAndBelow (index, numUsed));
return isPositiveAndBelow (index, numUsed) ? data.elements [index]
: nullptr;
}