From 59da243fed03b011a993acf772d3bc44c5b94c77 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Thu, 2 Feb 2012 22:28:44 +0100 Subject: [PATCH] ZynAddSubFX: Pruning code from static analysis Static analysis performed with cppcheck and clang (cherry picked from commit 7540c6b46e2e6158a38464aeb9a8b35fefc3c9a9) --- plugins/zynaddsubfx/src/Effects/Phaser.h | 1 - plugins/zynaddsubfx/src/Effects/Reverb.cpp | 10 ++++------ plugins/zynaddsubfx/src/Misc/Util.h | 1 + plugins/zynaddsubfx/src/Params/PresetsStore.cpp | 2 +- plugins/zynaddsubfx/src/Params/PresetsStore.h | 2 +- plugins/zynaddsubfx/src/Seq/MIDIFile.cpp | 10 ++++------ plugins/zynaddsubfx/src/Seq/MIDIFile.h | 4 ---- plugins/zynaddsubfx/src/Synth/Envelope.cpp | 3 ++- plugins/zynaddsubfx/src/Synth/Envelope.h | 3 +-- plugins/zynaddsubfx/src/Synth/OscilGen.cpp | 2 +- plugins/zynaddsubfx/src/UI/PartUI.fl | 2 +- 11 files changed, 16 insertions(+), 24 deletions(-) diff --git a/plugins/zynaddsubfx/src/Effects/Phaser.h b/plugins/zynaddsubfx/src/Effects/Phaser.h index f5ee1b03f..75ff79173 100644 --- a/plugins/zynaddsubfx/src/Effects/Phaser.h +++ b/plugins/zynaddsubfx/src/Effects/Phaser.h @@ -58,7 +58,6 @@ class Phaser:public Effect unsigned char Poutsub; //if I wish to subtract the output instead of adding unsigned char Pphase; unsigned char Phyper; //lfo^2 -- converts tri into hyper-sine - unsigned char Pbarber; //Enable parber pole phasing unsigned char Panalog; //Control parameters diff --git a/plugins/zynaddsubfx/src/Effects/Reverb.cpp b/plugins/zynaddsubfx/src/Effects/Reverb.cpp index 419cee4a6..5eb877103 100644 --- a/plugins/zynaddsubfx/src/Effects/Reverb.cpp +++ b/plugins/zynaddsubfx/src/Effects/Reverb.cpp @@ -248,10 +248,8 @@ void Reverb::settime(unsigned char Ptime) void Reverb::setlohidamp(unsigned char Plohidamp) { - REALTYPE x; - if(Plohidamp < 64) - Plohidamp = 64; //remove this when the high part from lohidamp will be added + Plohidamp = 64; //remove this when the high part from lohidamp will be added this->Plohidamp = Plohidamp; if(Plohidamp == 64) { @@ -263,7 +261,7 @@ void Reverb::setlohidamp(unsigned char Plohidamp) lohidamptype = 1; if(Plohidamp > 64) lohidamptype = 2; - x = fabs((REALTYPE)(Plohidamp - 64) / 64.1); + REALTYPE x = fabs((REALTYPE)(Plohidamp - 64) / 64.1); lohifb = x * x; } } @@ -330,7 +328,7 @@ void Reverb::setlpf(unsigned char Plpf) void Reverb::settype(unsigned char Ptype) { const int NUM_TYPES = 3; - int combtunings[NUM_TYPES][REV_COMBS] = { + const int combtunings[NUM_TYPES][REV_COMBS] = { //this is unused (for random) {0, 0, 0, 0, 0, 0, 0, 0 }, //Freeverb by Jezar at Dreampoint @@ -338,7 +336,7 @@ void Reverb::settype(unsigned char Ptype) //Freeverb by Jezar at Dreampoint //duplicate {1116, 1188, 1277, 1356, 1422, 1491, 1557, 1617 } }; - int aptunings[NUM_TYPES][REV_APS] = { + const int aptunings[NUM_TYPES][REV_APS] = { //this is unused (for random) {0, 0, 0, 0 }, //Freeverb by Jezar at Dreampoint diff --git a/plugins/zynaddsubfx/src/Misc/Util.h b/plugins/zynaddsubfx/src/Misc/Util.h index 341bdf546..d77f457f4 100644 --- a/plugins/zynaddsubfx/src/Misc/Util.h +++ b/plugins/zynaddsubfx/src/Misc/Util.h @@ -23,6 +23,7 @@ #ifndef UTIL_H #define UTIL_H +#include #include #include #include "../globals.h" diff --git a/plugins/zynaddsubfx/src/Params/PresetsStore.cpp b/plugins/zynaddsubfx/src/Params/PresetsStore.cpp index 46a8bd682..4292f912c 100644 --- a/plugins/zynaddsubfx/src/Params/PresetsStore.cpp +++ b/plugins/zynaddsubfx/src/Params/PresetsStore.cpp @@ -88,7 +88,7 @@ bool PresetsStore::presetstruct::operator<(const presetstruct &b) const } -void PresetsStore::rescanforpresets(string type) +void PresetsStore::rescanforpresets(const string &type) { //std::cout << "Scanning For Presets" << std::endl; //std::cout << "Of Type: " << type << std::endl; diff --git a/plugins/zynaddsubfx/src/Params/PresetsStore.h b/plugins/zynaddsubfx/src/Params/PresetsStore.h index f498e7829..08437956e 100644 --- a/plugins/zynaddsubfx/src/Params/PresetsStore.h +++ b/plugins/zynaddsubfx/src/Params/PresetsStore.h @@ -52,7 +52,7 @@ class PresetsStore }; std::vector presets; - void rescanforpresets(const std::string type); + void rescanforpresets(const std::string &type); private: struct { diff --git a/plugins/zynaddsubfx/src/Seq/MIDIFile.cpp b/plugins/zynaddsubfx/src/Seq/MIDIFile.cpp index b732f49f7..4e14486fa 100644 --- a/plugins/zynaddsubfx/src/Seq/MIDIFile.cpp +++ b/plugins/zynaddsubfx/src/Seq/MIDIFile.cpp @@ -22,6 +22,7 @@ #include #include +#include #include "MIDIFile.h" @@ -235,8 +236,7 @@ void MIDIFile::parsenoteoff(char ntrack, char chan, unsigned int dt) unsigned char note; note = getbyte(); - unsigned char noteoff_velocity = getbyte(); //unused by zynaddsubfx - noteoff_velocity = 0; + (void) getbyte(); //Read in unused noteoff_velocity if(chan >= NUM_MIDI_CHANNELS) return; @@ -346,7 +346,6 @@ void MIDIFile::clearmidifile() midifilesize = 0; midifilek = 0; midieof = false; - data.tick = 0.05; } unsigned char MIDIFile::getbyte() @@ -394,14 +393,13 @@ unsigned short int MIDIFile::getint16() unsigned int MIDIFile::getvarint32() { unsigned long result = 0; - unsigned char b; - /// printf("\n[start]"); if((result = getbyte()) & 0x80) { result &= 0x7f; + uint8_t b; do { - b = getbyte(); + b = getbyte(); result = (result << 7) + (b & 0x7f); } while(b & 0x80); } diff --git a/plugins/zynaddsubfx/src/Seq/MIDIFile.h b/plugins/zynaddsubfx/src/Seq/MIDIFile.h index 374d98c1c..ed1153bd2 100644 --- a/plugins/zynaddsubfx/src/Seq/MIDIFile.h +++ b/plugins/zynaddsubfx/src/Seq/MIDIFile.h @@ -83,10 +83,6 @@ class MIDIFile //skip some bytes void skipnbytes(int n); - - struct { - double tick; //how many seconds one tick has - } data; }; #endif diff --git a/plugins/zynaddsubfx/src/Synth/Envelope.cpp b/plugins/zynaddsubfx/src/Synth/Envelope.cpp index 7cf33a946..86ea3119c 100644 --- a/plugins/zynaddsubfx/src/Synth/Envelope.cpp +++ b/plugins/zynaddsubfx/src/Synth/Envelope.cpp @@ -20,8 +20,9 @@ */ -#include +#include #include "Envelope.h" +#include "../Params/EnvelopeParams.h" Envelope::Envelope(EnvelopeParams *envpars, REALTYPE basefreq) { diff --git a/plugins/zynaddsubfx/src/Synth/Envelope.h b/plugins/zynaddsubfx/src/Synth/Envelope.h index 1a15813a7..dc3b6f259 100644 --- a/plugins/zynaddsubfx/src/Synth/Envelope.h +++ b/plugins/zynaddsubfx/src/Synth/Envelope.h @@ -23,7 +23,6 @@ #ifndef ENVELOPE_H #define ENVELOPE_H -#include #include "../globals.h" #include "../Params/EnvelopeParams.h" @@ -33,7 +32,7 @@ class Envelope public: /**Constructor*/ - Envelope(EnvelopeParams *envpars, REALTYPE basefreq); + Envelope(class EnvelopeParams *envpars, REALTYPE basefreq); /**Destructor*/ ~Envelope(); void relasekey(); diff --git a/plugins/zynaddsubfx/src/Synth/OscilGen.cpp b/plugins/zynaddsubfx/src/Synth/OscilGen.cpp index 9eb609850..47a1ec253 100644 --- a/plugins/zynaddsubfx/src/Synth/OscilGen.cpp +++ b/plugins/zynaddsubfx/src/Synth/OscilGen.cpp @@ -933,7 +933,7 @@ void OscilGen::prepare() void OscilGen::adaptiveharmonic(FFTFREQS f, REALTYPE freq) { - if((Padaptiveharmonics == 0) /*||(freq<1.0)*/) + if(Padaptiveharmonics == 0 /*||(freq<1.0)*/) return; if(freq < 1.0) freq = 440.0; diff --git a/plugins/zynaddsubfx/src/UI/PartUI.fl b/plugins/zynaddsubfx/src/UI/PartUI.fl index fcf15f0e4..fc8dcd5e8 100644 --- a/plugins/zynaddsubfx/src/UI/PartUI.fl +++ b/plugins/zynaddsubfx/src/UI/PartUI.fl @@ -1049,7 +1049,7 @@ char tmp[10]; while (klimits[k]!=0){ sprintf(tmp,"%d",klimits[k]); keylimitlist->add(tmp); - if ((val==-1)){ + if (val==-1){ if (klimits[k]>part->Pkeylimit) val=k; }; k++;