Commit c017e407 authored by Benjamin Heisch's avatar Benjamin Heisch
Browse files

Changed cppcheck warnings

parent 996f7b2a
......@@ -15,7 +15,7 @@ debian_buster_x64_build:
- cmake -DINSTALL_PREFIX=$(pwd)/build/deps -DBUILD_DIR=build/deps -P scripts/install.cmake
- cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$(pwd)/build/deps -S . -B build/Release
- cmake --build build/Release/
- cmake -E env CXXFLAGS="-g -O0 -Wall -W -Wshadow -Wunused-variable -Wunused-parameter -Wunused-function -Wunused -Wno-system-headers -Wno-deprecated -Woverloaded-virtual -Wwrite-strings -fprofile-arcs -ftest-coverage -pedantic" C_FLAGS="-g -O0 -Wall -W -fprofile-arcs -ftest-coverage" LDFLAGS="-fprofile-arcs -ftest-coverage -lgcov" cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=$(pwd)/build/deps -S . -B build/Debug
- cmake -E env CXXFLAGS="-g -O0 -Wall -Wextra -Wpedantic -Wshadow -W --coverage" C_FLAGS="-g -O0 -Wall -W --coverage" LDFLAGS="--coverage -lgcov" cmake -G "Ninja" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=$(pwd)/build/deps -S . -B build/Debug
- cmake --build build/Debug
artifacts:
paths:
......@@ -27,12 +27,13 @@ debian_test:
stage: test
before_script:
- apt update
- DEBIAN_FRONTEND=noninteractive apt --yes install cmake gcovr
- DEBIAN_FRONTEND=noninteractive apt --yes install cmake gcovr cppcheck
script:
- cd build/Debug
- ctest -E pluginval
#- gcovr --fail-under-line 80 -s -j4 -r $(pwd)/../../ $gcovr --fail-under-line 80 -s -e '.*/deps/.*$' -e '.*(CMake|(T|t)tl|string_view).*$' --exclude-directories "test/|examples/|deps/" -r $(pwd)/../../ $(pwd)
#- gcovr --fail-under-line 80 -s -e '.*/deps/.*$' -e '.*(CMake|(T|t)tl|string_view).*$' --exclude-directories "test/|examples/|deps/" -r $(pwd)/../.. $(pwd)
- cppcheck -q --enable=warning,style,performance,portability --error-exitcode=1 --std=c++14 --language=c++ --project=compile_commands.json -ideps/
- gcovr --fail-under-line 80 -s -e '.*/deps/.*$' -e '.*(CMake|(T|t)tl|string_view).*$' --exclude-directories "test/|examples/|deps/" -r $(pwd)/../.. $(pwd)
#docker-test-linux-x64 :
# image: dockcross/linux-x64
# stage: test
......
......@@ -107,7 +107,7 @@ size_t getSizeOfPluginInfos()
return GlobalData().getNumberOfRegisteredPlugins();
}
std::vector<TTLPluginInfo> getPluginInfos(std::string binaryPath)
std::vector<TTLPluginInfo> getPluginInfos(const std::string& binaryPath)
{
std::vector<TTLPluginInfo> plugins(GlobalData().getNumberOfRegisteredPlugins());
for (size_t i = 0; i < plugins.size(); i++) {
......
......@@ -13,7 +13,7 @@
#include <exception>
inline std::string replaceInString(std::string strToChange, const std::string itemToReplace, const std::string substitute)
inline std::string replaceInString(std::string strToChange, const std::string& itemToReplace, const std::string& substitute)
{
while (strToChange.find(itemToReplace) != std::string::npos)
strToChange.replace(strToChange.find(itemToReplace), 1, substitute);
......@@ -104,10 +104,10 @@ public:
this->size_of_data = sizeof(MidiEventBuffer);
this->data = new MidiEventBuffer;
memset(data, 0, sizeof(MidiEventBuffer));
((MidiEventBuffer*)this->data)->seq.atom.type = features->uridmap.map(features->uridmap.handle, LV2_ATOM__Sequence);
((MidiEventBuffer*)this->data)->seq.atom.size = this->size_of_data -sizeof(LV2_Atom);
reinterpret_cast<MidiEventBuffer*>(this->data)->seq.atom.type = features->uridmap.map(features->uridmap.handle, LV2_ATOM__Sequence);
reinterpret_cast<MidiEventBuffer*>(this->data)->seq.atom.size = this->size_of_data -sizeof(LV2_Atom);
if(this->dir==Input)
lv2_atom_sequence_clear(&((MidiEventBuffer*)this->data)->seq);
lv2_atom_sequence_clear(&reinterpret_cast<MidiEventBuffer*>(this->data)->seq);
return;
case Audio:
this->size_of_data =sizeof(float)*sample_count;
......@@ -123,7 +123,7 @@ public:
{0 , {sizeof(MIDINoteEvent)-sizeof(LV2_Atom),features->uridmap.map(features->uridmap.handle, LV2_MIDI__MidiEvent) } },//LV2_Atom_Event
{b1,b2,b3} // new MidiMsg
};
lv2_atom_sequence_append_event(&((MidiEventBuffer*)this->data)->seq,
lv2_atom_sequence_append_event(&reinterpret_cast<MidiEventBuffer*>(this->data)->seq,
sizeof(MIDINoteEvent[40]), (LV2_Atom_Event*)&ev);
}
......@@ -131,10 +131,10 @@ public:
inline void free() {
switch (this->type) {
case Midi:
delete (MidiEventBuffer*)this->data;
delete reinterpret_cast<MidiEventBuffer*>(this->data);
return;
case Audio:
delete[](float*)this->data;
delete[] reinterpret_cast<float*>(this->data);
return;
default:
// delete this->data;
......@@ -232,7 +232,7 @@ private:
LilvWorld* world = nullptr;
public:
std::vector<Plugin> plugins;
inline LV2Module(std::string pathToPlugin) {
inline explicit LV2Module(const std::string& pathToPlugin) {
this->world = lilv_world_new();
// Use the path of the lv2 binary. Has to have manifest.ttl in that folder, to work.
......
......@@ -20,13 +20,13 @@ TEST_CASE("LV2 Midi Forwarding regression") {
for (auto& p : plug.ports) {
if (p.type == PortType::Midi && p.dir == Direction::Output) {
auto data = (MidiEventBuffer*)p.data;
auto data = reinterpret_cast<MidiEventBuffer*>(p.data);
INFO("Error, could not forward Midimessages.");
auto item1 = &data->midiEvents[0];
REQUIRE(item1->msg[0] == 0x1 );
REQUIRE(item1->msg[1] == 0x2);
REQUIRE(item1->msg[2] == 0x3 );
auto item2 = (MIDINoteEvent*)lv2_atom_sequence_next(&data->midiEvents->event);
auto item2 = reinterpret_cast<MIDINoteEvent*>(lv2_atom_sequence_next(&data->midiEvents->event));
REQUIRE(item2->msg[0] == 0xFF);
REQUIRE(item2->msg[1] == 0xFF);
REQUIRE(item2->msg[2] == 0xFF);
......
......@@ -19,7 +19,7 @@ if(XPLUG_VST3_SUPPORT)
# for MacOS X or iOS, watchOS, tvOS (since 3.10.3)
EXPORT_SYMBOLS(vst3 FUNCTION_NAMES _GetPluginFactory _bundleEntry _bundleExit)
elseif(UNIX AND NOT APPLE)
EXPORT_SYMBOLS(vst3 FUNCTION_NAMES GetPluginFactory ModuleEntry ModuleExit InitDll ExitDll)
EXPORT_SYMBOLS(vst3 FUNCTION_NAMES GetPluginFactory ModuleEntry ModuleExit InitDll ExitDll)
else()
MESSAGE()
endif(WIN32)
......
......@@ -138,10 +138,10 @@ class VST3Module {
private:
std::string lastError="";
std::string lastWarning="";
XPlug::library_t pluginLibrary; // The pluginlibrary
GetFactoryProc plugLoadFunction; // FactoryLoad Function
void* initfnc; // functionpointer to init function
void* exitfnc; // functionpointer to init function
XPlug::library_t pluginLibrary=nullptr; // The pluginlibrary
GetFactoryProc plugLoadFunction=nullptr; // FactoryLoad Function
void* initfnc=nullptr; // functionpointer to init function
void* exitfnc=nullptr; // functionpointer to init function
Steinberg::Vst::IComponent* processorComponent = nullptr;
......@@ -157,7 +157,7 @@ public:
std::function<bool()>runExitFncLampda; // Function to call exit function crossplattform.Returns Value from ExitDll/ExitModule/bundleExit
inline bool hasInitAndExitFunctions() { return initfnc != nullptr && exitfnc != nullptr; }
inline VST3Module(std::string pluginPath) {
inline explicit VST3Module(std::string pluginPath) {
using namespace XPlug;
using namespace Steinberg;
using namespace Vst;
......
......@@ -70,8 +70,7 @@ public:
std::shared_ptr<IFormatTestSuite> testSuitePtr = nullptr;
TestSuiteRegistrator()
{
testSuitePtr = std::shared_ptr<IFormatTestSuite>(new TestType());
RegisterTestSuite(testSuitePtr);
RegisterTestSuite(std::shared_ptr<IFormatTestSuite>(new TestType()));
}
};
......
......@@ -19,7 +19,7 @@ void RegisterTestSuite(std::shared_ptr<IFormatTestSuite> testSuite) {
GlobalData().testSuites.push_back(testSuite);
}
IFormatTestSuite* GetTestSuite(std::string formatName)
IFormatTestSuite* GetTestSuite(const std::string& formatName)
{
for (auto testSuite : GlobalData().testSuites)
if (testSuite->getFormatName() == formatName)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment