Skip to content

Commit

Permalink
Cleanup a collection of issues located by static analysis (#7848)
Browse files Browse the repository at this point in the history
Apply a collection of fixes found by a static analysis tool

Closes #7839
Closes #7840
Closes #7841
Closes #7842
Closes #7843
Closes #7844
Closes #7845
Closes #7846
Closes #7847
  • Loading branch information
baconpaul authored Nov 11, 2024
1 parent 16fc239 commit d006567
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 31 deletions.
8 changes: 1 addition & 7 deletions src/common/FxPresetAndClipboardManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,8 @@ void FxUserPreset::saveFxIn(SurgeStorage *storage, FxStorage *fx, const std::str
{
try
{
char fxName[TXT_SIZE];
fxName[0] = 0;
strxcpy(fxName, s.c_str(), TXT_SIZE);

if (strlen(fxName) == 0)
{
if (s.empty())
return;
}

/*
* OK so lets see if there's a path separator in the string
Expand Down
4 changes: 2 additions & 2 deletions src/common/LuaSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int Surge::LuaSupport::parseStringDefiningMultipleFunctions(
oss << lua_tostring(L, -1);
errorMessage = oss.str();
lua_pop(L, 1);
for (auto f : functions)
for (const auto &f : functions)
lua_pushnil(L);
return 0;
}
Expand Down Expand Up @@ -97,7 +97,7 @@ int Surge::LuaSupport::parseStringDefiningMultipleFunctions(
oss << lua_tostring(L, -1);
errorMessage = oss.str();
lua_pop(L, 1);
for (auto f : functions)
for (const auto &f : functions)
lua_pushnil(L);
return 0;
}
Expand Down
5 changes: 2 additions & 3 deletions src/common/ModulatorPresetManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "DebugHelpers.h"
#include "SurgeStorage.h"
#include "tinyxml/tinyxml.h"
#include "DebugHelpers.h"
#include "sst/plugininfra/strnatcmp.h"

namespace Surge
Expand Down Expand Up @@ -81,7 +80,7 @@ void ModulatorPreset::savePresetToUser(const fs::path &location, SurgeStorage *s
// OK the internal name has "lfo7_" at the top or what not. We need this
// loadable into any LFO so...
std::string in(curr->get_internal_name());
auto p = in.find("_");
auto p = in.find('_');
in = in.substr(p + 1);
TiXmlElement pn(in);

Expand Down Expand Up @@ -176,7 +175,7 @@ void ModulatorPreset::loadPresetFrom(const fs::path &location, SurgeStorage *s,
// OK the internal name has "lfo7_" at the top or what not. We need this
// loadable into any LFO so...
std::string in(curr->get_internal_name());
auto p = in.find("_");
auto p = in.find('_');
in = in.substr(p + 1);
auto valNode = params->FirstChildElement(in.c_str());
if (valNode)
Expand Down
2 changes: 1 addition & 1 deletion src/common/dsp/WavetableScriptEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ std::vector<float> evaluateScriptAtFrame(SurgeStorage *storage, const std::strin
Surge::LuaSupport::loadSurgePrelude(L, Surge::LuaSources::wtse_prelude);

std::string emsg;
auto res = Surge::LuaSupport::parseStringDefiningFunction(L, eqn.c_str(), "generate", emsg);
auto res = Surge::LuaSupport::parseStringDefiningFunction(L, eqn, "generate", emsg);
if (res)
{
Surge::LuaSupport::setSurgeFunctionEnvironment(L);
Expand Down
5 changes: 0 additions & 5 deletions src/common/dsp/effects/chowdsp/ExciterEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ void ExciterEffect::init_ctrltypes()
fxdata->p[exciter_tone].val_default.f = 0.5f;
fxdata->p[exciter_tone].posy_offset = 1;

fxdata->p[exciter_tone].set_name("Tone");
fxdata->p[exciter_tone].set_type(ct_percent);
fxdata->p[exciter_tone].val_default.f = 0.5f;
fxdata->p[exciter_tone].posy_offset = 1;

fxdata->p[exciter_att].set_name("Attack");
fxdata->p[exciter_att].set_type(ct_comp_attack_ms);
fxdata->p[exciter_att].val_max.f = std::log2(20.0f) / fxdata->p[exciter_att].displayInfo.b;
Expand Down
12 changes: 2 additions & 10 deletions src/common/dsp/modulators/MSEGModulationHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,16 +852,8 @@ void insertAtIndex(MSEGStorage *ms, int insertIndex)
nxt = 0;
}

if (nxt == insertIndex)
{
ms->segments[insertIndex].cpv = ms->segments[nxt].v0 * 0.5;
ms->segments[insertIndex].cpduration = 0.125;
}
else
{
ms->segments[insertIndex].cpv = ms->segments[nxt].v0 * 0.5;
ms->segments[insertIndex].cpduration = 0.125;
}
ms->segments[insertIndex].cpv = ms->segments[nxt].v0 * 0.5;
ms->segments[insertIndex].cpduration = 0.125;

/*
* Handle the loops. We have just inserted at index so if start or end
Expand Down
2 changes: 0 additions & 2 deletions src/common/dsp/oscillators/SineOscillator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,6 @@ void SineOscillator::process_block_internal(float pitch, float drift, float fmde
FB.newValue(fb_val);

float p alignas(16)[MAX_UNISON];
float sx alignas(16)[MAX_UNISON];
float cx alignas(16)[MAX_UNISON];
float olv alignas(16)[MAX_UNISON];
float orv alignas(16)[MAX_UNISON];

Expand Down
2 changes: 1 addition & 1 deletion src/common/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ const int DEFAULT_POLYLIMIT = 16;

const int DEFAULT_OSC_PORT_IN = 53280;
const int DEFAULT_OSC_PORT_OUT = 53281;
const std::string DEFAULT_OSC_IPADDR_OUT = "127.0.0.1";
const inline std::string DEFAULT_OSC_IPADDR_OUT = "127.0.0.1";
#endif // SURGE_SRC_COMMON_GLOBALS_H

0 comments on commit d006567

Please sign in to comment.