Browse Source

Fixed some coverity warnings.

tags/2021-05-28
jules 12 years ago
parent
commit
01e3e4c40c
19 changed files with 74 additions and 54 deletions
  1. +2
    -4
      extras/JuceDemo/Source/demos/AudioDemoLatencyPage.cpp
  2. +1
    -2
      extras/JuceDemo/Source/demos/AudioDemoSynthPage.cpp
  3. +2
    -3
      extras/JuceDemo/Source/demos/WidgetsDemo.cpp
  4. +1
    -0
      modules/juce_audio_basics/effects/juce_IIRFilter.cpp
  5. +4
    -1
      modules/juce_audio_basics/effects/juce_Reverb.h
  6. +26
    -27
      modules/juce_audio_basics/sources/juce_BufferingAudioSource.cpp
  7. +4
    -0
      modules/juce_audio_basics/sources/juce_ResamplingAudioSource.cpp
  8. +1
    -0
      modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp
  9. +3
    -4
      modules/juce_audio_formats/sampler/juce_Sampler.cpp
  10. +3
    -1
      modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp
  11. +3
    -2
      modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp
  12. +1
    -1
      modules/juce_core/threads/juce_ThreadLocalValue.h
  13. +1
    -0
      modules/juce_core/time/juce_PerformanceCounter.cpp
  14. +6
    -0
      modules/juce_core/xml/juce_XmlDocument.cpp
  15. +2
    -1
      modules/juce_core/zip/juce_ZipFile.cpp
  16. +5
    -3
      modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp
  17. +6
    -3
      modules/juce_gui_basics/widgets/juce_TreeView.cpp
  18. +2
    -2
      modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp
  19. +1
    -0
      modules/juce_gui_extra/misc/juce_SplashScreen.cpp

+ 2
- 4
extras/JuceDemo/Source/demos/AudioDemoLatencyPage.cpp View File

@@ -38,10 +38,8 @@ public:
sampleRate (0),
isRunning (false),
resultsBox (resultsBox_)
{
}
~LatencyTester()
deviceInputLatency (0),
deviceOutputLatency (0)
{
}


+ 1
- 2
extras/JuceDemo/Source/demos/AudioDemoSynthPage.cpp View File

@@ -47,8 +47,7 @@ class SineWaveVoice : public SynthesiserVoice
{
public:
SineWaveVoice()
: angleDelta (0.0),
tailOff (0.0)
: currentAngle (0), angleDelta (0), level (0), tailOff (0)
{
}


+ 2
- 3
extras/JuceDemo/Source/demos/WidgetsDemo.cpp View File

@@ -246,9 +246,8 @@ public:
void changeListenerCallback (ChangeBroadcaster* source)
{
ColourSelector* cs = dynamic_cast <ColourSelector*> (source);
setColour (TextButton::buttonColourId, cs->getCurrentColour());
if (ColourSelector* cs = dynamic_cast <ColourSelector*> (source))
setColour (TextButton::buttonColourId, cs->getCurrentColour());
}
};


+ 1
- 0
modules/juce_audio_basics/effects/juce_IIRFilter.cpp View File

@@ -32,6 +32,7 @@
IIRFilter::IIRFilter()
: active (false), v1 (0), v2 (0)
{
zeromem (coefficients, sizeof (coefficients));
}
IIRFilter::IIRFilter (const IIRFilter& other)


+ 4
- 1
modules/juce_audio_basics/effects/juce_Reverb.h View File

@@ -220,7 +220,10 @@ private:
class CombFilter
{
public:
CombFilter() noexcept : bufferSize (0), bufferIndex (0) {}
CombFilter() noexcept
: bufferSize (0), bufferIndex (0),
feedback (0), last (0), damp1 (0), damp2 (0)
{}
void setSize (const int size)
{


+ 26
- 27
modules/juce_audio_basics/sources/juce_BufferingAudioSource.cpp View File

@@ -35,6 +35,7 @@ BufferingAudioSource::BufferingAudioSource (PositionableAudioSource* source_,
bufferValidStart (0),
bufferValidEnd (0),
nextPlayPos (0),
sampleRate (0),
wasSourceLooping (false),
isPrepared (false)
{
@@ -208,42 +209,40 @@ bool BufferingAudioSource::readNextBufferChunk()
}
}
if (sectionToReadStart != sectionToReadEnd)
{
jassert (buffer.getNumSamples() > 0);
const int bufferIndexStart = (int) (sectionToReadStart % buffer.getNumSamples());
const int bufferIndexEnd = (int) (sectionToReadEnd % buffer.getNumSamples());
if (sectionToReadStart == sectionToReadEnd)
return false;
if (bufferIndexStart < bufferIndexEnd)
{
readBufferSection (sectionToReadStart,
(int) (sectionToReadEnd - sectionToReadStart),
bufferIndexStart);
}
else
{
const int initialSize = buffer.getNumSamples() - bufferIndexStart;
jassert (buffer.getNumSamples() > 0);
const int bufferIndexStart = (int) (sectionToReadStart % buffer.getNumSamples());
const int bufferIndexEnd = (int) (sectionToReadEnd % buffer.getNumSamples());
readBufferSection (sectionToReadStart,
initialSize,
bufferIndexStart);
if (bufferIndexStart < bufferIndexEnd)
{
readBufferSection (sectionToReadStart,
(int) (sectionToReadEnd - sectionToReadStart),
bufferIndexStart);
}
else
{
const int initialSize = buffer.getNumSamples() - bufferIndexStart;
readBufferSection (sectionToReadStart + initialSize,
(int) (sectionToReadEnd - sectionToReadStart) - initialSize,
0);
}
readBufferSection (sectionToReadStart,
initialSize,
bufferIndexStart);
readBufferSection (sectionToReadStart + initialSize,
(int) (sectionToReadEnd - sectionToReadStart) - initialSize,
0);
}
{
const ScopedLock sl2 (bufferStartPosLock);
bufferValidStart = newBVS;
bufferValidEnd = newBVE;
return true;
}
else
{
return false;
}
return true;
}
void BufferingAudioSource::readBufferSection (const int64 start, const int length, const int bufferOffset)


+ 4
- 0
modules/juce_audio_basics/sources/juce_ResamplingAudioSource.cpp View File

@@ -29,10 +29,14 @@ ResamplingAudioSource::ResamplingAudioSource (AudioSource* const inputSource,
ratio (1.0),
lastRatio (1.0),
buffer (numChannels_, 0),
bufferPos (0),
sampsInBuffer (0),
subSampleOffset (0),
numChannels (numChannels_)
{
jassert (input != nullptr);
zeromem (coefficients, sizeof (coefficients));
}
ResamplingAudioSource::~ResamplingAudioSource() {}


+ 1
- 0
modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp View File

@@ -94,6 +94,7 @@ AudioDeviceManager::AudioDeviceManager()
listNeedsScanning (true),
useInputNames (false),
inputLevel (0),
testSoundPosition (0),
tempBuffer (2, 2),
cpuUsageMs (0),
timeToCpuScale (0)


+ 3
- 4
modules/juce_audio_formats/sampler/juce_Sampler.cpp View File

@@ -73,10 +73,9 @@ bool SamplerSound::appliesToChannel (const int /*midiChannel*/)
SamplerVoice::SamplerVoice()
: pitchRatio (0.0),
sourceSamplePosition (0.0),
lgain (0.0f),
rgain (0.0f),
isInAttack (false),
isInRelease (false)
lgain (0.0f), rgain (0.0f),
attackReleaseLevel (0), attackDelta (0), releaseDelta (0),
isInAttack (false), isInRelease (false)
{
}


+ 3
- 1
modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp View File

@@ -924,7 +924,9 @@ void AudioProcessorGraph::Node::setParentGraph (AudioProcessorGraph* const graph
AudioProcessorGraph::AudioProcessorGraph()
: lastNodeId (0),
renderingBuffers (1, 1),
currentAudioOutputBuffer (1, 1)
currentAudioInputBuffer (nullptr),
currentAudioOutputBuffer (1, 1),
currentMidiInputBuffer (nullptr)
{
}


+ 3
- 2
modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp View File

@@ -77,13 +77,13 @@ class AudioThumbnail::LevelDataSource : public TimeSliceClient
public:
LevelDataSource (AudioThumbnail& thumb, AudioFormatReader* newReader, int64 hash)
: lengthInSamples (0), numSamplesFinished (0), sampleRate (0), numChannels (0),
hashCode (hash), owner (thumb), reader (newReader)
hashCode (hash), owner (thumb), reader (newReader), lastReaderUseTime (0)
{
}
LevelDataSource (AudioThumbnail& thumb, InputSource* src)
: lengthInSamples (0), numSamplesFinished (0), sampleRate (0), numChannels (0),
hashCode (src->hashCode()), owner (thumb), source (src)
hashCode (src->hashCode()), owner (thumb), source (src), lastReaderUseTime (0)
{
}
@@ -525,6 +525,7 @@ AudioThumbnail::AudioThumbnail (const int originalSamplesPerThumbnailSample,
window (new CachedWindow()),
samplesPerThumbSample (originalSamplesPerThumbnailSample),
totalSamples (0),
numSamplesFinished (0),
numChannels (0),
sampleRate (0)
{


+ 1
- 1
modules/juce_core/threads/juce_ThreadLocalValue.h View File

@@ -178,7 +178,7 @@ private:
struct ObjectHolder
{
ObjectHolder (const Thread::ThreadID& tid)
: threadId (tid), object()
: threadId (tid), next (nullptr), object()
{}
Thread::ThreadID threadId;


+ 1
- 0
modules/juce_core/time/juce_PerformanceCounter.cpp View File

@@ -33,6 +33,7 @@ PerformanceCounter::PerformanceCounter (const String& name_,
numRuns (0),
runsPerPrint (runsPerPrintout),
totalTime (0),
started (0),
outputFile (loggingFile)
{
if (outputFile != File::nonexistent)


+ 6
- 0
modules/juce_core/xml/juce_XmlDocument.cpp View File

@@ -29,12 +29,18 @@
XmlDocument::XmlDocument (const String& documentText)
: originalText (documentText),
input (nullptr),
outOfData (false),
errorOccurred (false),
needToLoadDTD (false),
ignoreEmptyTextElements (true)
{
}
XmlDocument::XmlDocument (const File& file)
: input (nullptr),
outOfData (false),
errorOccurred (false),
needToLoadDTD (false),
ignoreEmptyTextElements (true),
inputSource (new FileInputSource (file))
{


+ 2
- 1
modules/juce_core/zip/juce_ZipFile.cpp View File

@@ -450,7 +450,8 @@ public:
storedPathname (storedPath.isEmpty() ? f.getFileName() : storedPath),
compressionLevel (compression),
compressedSize (0),
headerStart (0)
headerStart (0),
checksum (0)
{
}


+ 5
- 3
modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp View File

@@ -2612,10 +2612,12 @@ void LookAndFeel::layoutFileBrowserComponent (FileBrowserComponent& browserComp,
y += controlsHeight + 4;
Component* const listAsComp = dynamic_cast <Component*> (fileListComponent);
listAsComp->setBounds (x, y, w, browserComp.getHeight() - y - bottomSectionHeight);
if (Component* const listAsComp = dynamic_cast <Component*> (fileListComponent))
{
listAsComp->setBounds (x, y, w, browserComp.getHeight() - y - bottomSectionHeight);
y = listAsComp->getBottom() + 4;
}
y = listAsComp->getBottom() + 4;
filenameBox->setBounds (x + 50, y, w - 50, controlsHeight);
}


+ 6
- 3
modules/juce_gui_basics/widgets/juce_TreeView.cpp View File

@@ -30,7 +30,8 @@ public:
ContentComponent (TreeView& tree)
: owner (tree),
buttonUnderMouse (nullptr),
isDragging (false)
isDragging (false),
needSelectionOnMouseUp (false)
{
}
@@ -924,7 +925,7 @@ class TreeView::InsertPointHighlight : public Component
{
public:
InsertPointHighlight()
: lastItem (nullptr)
: lastItem (nullptr), lastIndex (0)
{
setSize (100, 12);
setAlwaysOnTop (true);
@@ -1122,6 +1123,8 @@ TreeViewItem::TreeViewItem()
y (0),
itemHeight (0),
totalHeight (0),
itemWidth (0),
totalWidth (0),
selected (false),
redrawNeeded (true),
drawLinesInside (true),
@@ -1370,7 +1373,7 @@ Rectangle<int> TreeViewItem::getItemPosition (const bool relativeToTreeViewTopLe
Rectangle<int> r (indentX, y, jmax (0, width), totalHeight);
if (relativeToTreeViewTopLeft)
if (relativeToTreeViewTopLeft && ownerView != nullptr)
r -= ownerView->viewport->getViewPosition();
return r;


+ 2
- 2
modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp View File

@@ -23,8 +23,8 @@
*/
BubbleMessageComponent::BubbleMessageComponent (int fadeOutLengthMs)
: fadeOutLength (fadeOutLengthMs),
deleteAfterUse (false)
: fadeOutLength (fadeOutLengthMs), mouseClickCounter (0),
expiryTime (0), deleteAfterUse (false)
{
}


+ 1
- 0
modules/juce_gui_extra/misc/juce_SplashScreen.cpp View File

@@ -23,6 +23,7 @@
*/
SplashScreen::SplashScreen()
: originalClickCounter (0)
{
setOpaque (true);
}


Loading…
Cancel
Save