Skip to content

Commit d94fa6b

Browse files
committed
More initialization and reference cppcheck fixes
1 parent fcc1b74 commit d94fa6b

8 files changed

Lines changed: 37 additions & 31 deletions

File tree

lib

src/ngscopeclient/PacketManager.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ void PacketManager::RemoveChildHistoryFrom(Packet* pack)
360360
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
361361
// ProtocolDisplayFilter
362362

363-
ProtocolDisplayFilter::ProtocolDisplayFilter(string str, size_t& i)
363+
ProtocolDisplayFilter::ProtocolDisplayFilter(const string& str, size_t& i)
364364
{
365365
//One or more clauses separated by operators
366366
while(i < str.length())
@@ -397,7 +397,7 @@ ProtocolDisplayFilter::~ProtocolDisplayFilter()
397397
delete c;
398398
}
399399

400-
bool ProtocolDisplayFilter::Validate(vector<string> headers, bool nakedLiteralOK)
400+
bool ProtocolDisplayFilter::Validate(const vector<string>& headers, bool nakedLiteralOK)
401401
{
402402
//No clauses? valid all-pass filter
403403
if(m_clauses.empty())
@@ -443,7 +443,7 @@ bool ProtocolDisplayFilter::Validate(vector<string> headers, bool nakedLiteralOK
443443
return true;
444444
}
445445

446-
void ProtocolDisplayFilter::EatSpaces(string str, size_t& i)
446+
void ProtocolDisplayFilter::EatSpaces(const string& str, size_t& i)
447447
{
448448
while( (i < str.length()) && isspace(str[i]) )
449449
i++;
@@ -499,7 +499,7 @@ string ProtocolDisplayFilter::Evaluate(const Packet* pack)
499499
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
500500
// ProtocolDisplayFilterClause
501501

502-
ProtocolDisplayFilterClause::ProtocolDisplayFilterClause(string str, size_t& i)
502+
ProtocolDisplayFilterClause::ProtocolDisplayFilterClause(const string& str, size_t& i)
503503
{
504504
ProtocolDisplayFilter::EatSpaces(str, i);
505505

@@ -637,7 +637,7 @@ ProtocolDisplayFilterClause::ProtocolDisplayFilterClause(string str, size_t& i)
637637
/**
638638
@brief Returns a copy of the input string with spaces removed
639639
*/
640-
string ProtocolDisplayFilterClause::EatSpaces(string str)
640+
string ProtocolDisplayFilterClause::EatSpaces(const string& str)
641641
{
642642
string ret;
643643
for(auto c : str)
@@ -713,7 +713,7 @@ ProtocolDisplayFilterClause::~ProtocolDisplayFilterClause()
713713
delete m_expression;
714714
}
715715

716-
bool ProtocolDisplayFilterClause::Validate(vector<string> headers)
716+
bool ProtocolDisplayFilterClause::Validate(const vector<string>& headers)
717717
{
718718
switch(m_type)
719719
{

src/ngscopeclient/PacketManager.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,17 @@ class ProtocolDisplayFilter;
9595
class ProtocolDisplayFilterClause
9696
{
9797
public:
98-
ProtocolDisplayFilterClause(std::string str, size_t& i);
98+
ProtocolDisplayFilterClause(const std::string& str, size_t& i);
9999
ProtocolDisplayFilterClause(const ProtocolDisplayFilterClause&) =delete;
100100
ProtocolDisplayFilterClause& operator=(const ProtocolDisplayFilterClause&) =delete;
101101

102102
virtual ~ProtocolDisplayFilterClause();
103103

104-
bool Validate(std::vector<std::string> headers);
104+
bool Validate(const std::vector<std::string>& headers);
105105

106106
std::string Evaluate(const Packet* pack);
107107

108-
static std::string EatSpaces(std::string str);
108+
static std::string EatSpaces(const std::string& str);
109109

110110
enum
111111
{
@@ -129,14 +129,14 @@ class ProtocolDisplayFilterClause
129129
class ProtocolDisplayFilter
130130
{
131131
public:
132-
ProtocolDisplayFilter(std::string str, size_t& i);
132+
ProtocolDisplayFilter(const std::string& str, size_t& i);
133133
ProtocolDisplayFilter(const ProtocolDisplayFilterClause&) =delete;
134134
ProtocolDisplayFilter& operator=(const ProtocolDisplayFilter&) =delete;
135135
virtual ~ProtocolDisplayFilter();
136136

137-
static void EatSpaces(std::string str, size_t& i);
137+
static void EatSpaces(const std::string& str, size_t& i);
138138

139-
bool Validate(std::vector<std::string> headers, bool nakedLiteralOK = false);
139+
bool Validate(const std::vector<std::string>& headers, bool nakedLiteralOK = false);
140140

141141
bool Match(const Packet* pack);
142142
std::string Evaluate(const Packet* pack);

src/ngscopeclient/Preference.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/***********************************************************************************************************************
22
* *
3-
* glscopeclient *
3+
* ngscopeclient *
44
* *
5-
* Copyright (c) 2012-2020 Andrew D. Zonenberg *
5+
* Copyright (c) 2012-2026 Andrew D. Zonenberg and contributors *
66
* All rights reserved. *
77
* *
88
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -359,7 +359,7 @@ void Preference::SetEnumRaw(std::int64_t value)
359359
Construct<std::int64_t>(value);
360360
}
361361

362-
void Preference::SetString(string value)
362+
void Preference::SetString(const string& value)
363363
{
364364
CleanUp();
365365
Construct<string>(value);

src/ngscopeclient/Preference.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/***********************************************************************************************************************
22
* *
3-
* glscopeclient *
3+
* ngscopeclient *
44
* *
5-
* Copyright (c) 2012-2022 Andrew D. Zonenberg *
5+
* Copyright (c) 2012-2026 Andrew D. Zonenberg and contributors *
66
* All rights reserved. *
77
* *
88
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -199,7 +199,7 @@ class Preference
199199
void SetBool(bool value);
200200
void SetReal(double value);
201201
void SetInt(std::int64_t value);
202-
void SetString(std::string value);
202+
void SetString(const std::string& value);
203203
void SetColor(const ImU32& value);
204204
void SetColorRaw(const impl::Color& value);
205205
void SetLabel(std::string label);

src/ngscopeclient/PreferenceDialog.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,11 @@ void PreferenceDialog::ProcessPreference(Preference& pref)
365365
auto id = pref.GetIdentifier();
366366
auto unit = pref.GetUnit();
367367
if(m_preferenceTemporaries.find(id) == m_preferenceTemporaries.end())
368+
{
369+
//Don't want to evaluate the PrettyPrint if the item isn't in the list
370+
//cppcheck-suppress stlFindInsert
368371
m_preferenceTemporaries[id] = unit.PrettyPrint(pref.GetReal());
372+
}
369373

370374
//Input box
371375
if(ImGui::InputText(label.c_str(), &m_preferenceTemporaries[id]))

src/ngscopeclient/ScopeDeskewWizard.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,14 @@ ScopeDeskewWizard::ScopeDeskewWizard(
8989
m_queue->GetQueue()->m_family ))
9090
, m_cmdBuf(std::move(vk::raii::CommandBuffers(*g_vkComputeDevice,
9191
vk::CommandBufferAllocateInfo(*m_pool, vk::CommandBufferLevel::ePrimary, 1)).front()))
92+
, m_uniform4xRatePipeline(make_shared<ComputePipeline>(
93+
"shaders/ScopeDeskewUniform4xRate.spv", 3, sizeof(UniformCrossCorrelateArgs)))
94+
, m_uniformUnequalRatePipeline(make_shared<ComputePipeline>(
95+
"shaders/ScopeDeskewUniformUnequalRate.spv", 3, sizeof(UniformCrossCorrelateArgs)))
96+
, m_uniformEqualRatePipeline(make_shared<ComputePipeline>(
97+
"shaders/ScopeDeskewUniformEqualRate.spv", 3, sizeof(UniformCrossCorrelateArgs)))
9298
, m_corrOut("corrOut")
9399
{
94-
m_uniformUnequalRatePipeline = make_shared<ComputePipeline>(
95-
"shaders/ScopeDeskewUniformUnequalRate.spv", 3, sizeof(UniformCrossCorrelateArgs));
96-
97-
m_uniformEqualRatePipeline = make_shared<ComputePipeline>(
98-
"shaders/ScopeDeskewUniformEqualRate.spv", 3, sizeof(UniformCrossCorrelateArgs));
99-
100-
m_uniform4xRatePipeline = make_shared<ComputePipeline>(
101-
"shaders/ScopeDeskewUniform4xRate.spv", 3, sizeof(UniformCrossCorrelateArgs));
102-
103100
if(g_hasDebugUtils)
104101
{
105102
g_vkComputeDevice->setDebugUtilsObjectNameEXT(

src/ngscopeclient/StreamBrowserDialog.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ bool StreamBrowserDialog::renderCombo(
275275
while((m_badgeXCur - xsz) < m_badgeXMin)
276276
{
277277
// Try and crop text
278-
resizedLabel = resizedLabel.substr(0,resizedLabel.size()-1);
278+
resizedLabel.resize(resizedLabel.size()-1);
279279
if(resizedLabel.size() < cropTextTo)
280280
break; // We don't want to make the text that short
281281
xsz = ImGui::CalcTextSize((resizedLabel + ELLIPSIS_CHAR).c_str()).x + padding;
@@ -1342,9 +1342,11 @@ void StreamBrowserDialog::DoSpectrometerSettings(shared_ptr<SCPISpectrometer> sp
13421342

13431343
//Create the object only when necessary
13441344
//cppcheck doesn't like this but doesn't realize we're creating a new object if it's not there already
1345-
//cppcheck-suppress stlFindInsert
13461345
if(m_timebaseConfig.find(scope) == m_timebaseConfig.end())
1346+
{
1347+
//cppcheck-suppress stlFindInsert
13471348
m_timebaseConfig[scope] = make_shared<StreamBrowserTimebaseInfo>(scope);
1349+
}
13481350

13491351
auto config = m_timebaseConfig[scope];
13501352

@@ -1499,7 +1501,10 @@ void StreamBrowserDialog::DoTimebaseSettings(shared_ptr<Oscilloscope> scope)
14991501
@param channelIndex the index of the channel to render
15001502
@param isLast true if this is the last channel of the instrument
15011503
*/
1502-
void StreamBrowserDialog::renderChannelNode(shared_ptr<Instrument> instrument, size_t channelIndex, bool isLast)
1504+
void StreamBrowserDialog::renderChannelNode(
1505+
shared_ptr<Instrument> instrument,
1506+
size_t channelIndex,
1507+
[[maybe_unused]] bool isLast)
15031508
{
15041509
// Get preferences for colors
15051510
auto& prefs = m_session->GetPreferences();

0 commit comments

Comments
 (0)