Skip to content

Commit e0e9bfc

Browse files
committed
More cppcheck fixes around initialization and references
1 parent 5d4dd2b commit e0e9bfc

8 files changed

Lines changed: 20 additions & 24 deletions

lib

src/ngscopeclient/AboutDialog.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,12 @@ using namespace std;
5050
AboutDialog::AboutDialog(MainWindow* parent)
5151
: Dialog("About ngscopeclient", to_string_hex(reinterpret_cast<uintptr_t>(this)), ImVec2(600, 400))
5252
, m_parent(parent)
53-
{
53+
5454
//this file is currently maintained by hand and updated for each release
5555
//TODO: make a script for this using https://api.github.com/repos/ngscopeclient/scopehal-apps/contributors
56-
m_authorsMarkdown = ReadDataFile("md/authors.md");
57-
58-
m_licenseMarkdown = ReadDataFile("md/licenses.md");
59-
56+
, m_authorsMarkdown(ReadDataFile("md/authors.md"))
57+
, m_licenseMarkdown(ReadDataFile("md/licenses.md"))
58+
{
6059
InitVulkanInfo();
6160
}
6261

src/ngscopeclient/AddInstrumentDialog.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ AddInstrumentDialog::AddInstrumentDialog(
7676
if(!driver.empty())
7777
{
7878
int i = 0;
79-
for(auto driverName: m_drivers)
79+
for(auto& driverName : m_drivers)
8080
{
8181
if(driverName == driver)
8282
{
@@ -92,7 +92,7 @@ AddInstrumentDialog::AddInstrumentDialog(
9292
if(!transport.empty())
9393
{
9494
int i = 0;
95-
for(auto transportName: m_transports)
95+
for(auto& transportName : m_transports)
9696
{
9797
if(transportName == transport)
9898
{
@@ -325,7 +325,7 @@ void AddInstrumentDialog::UpdateCombos()
325325
int modelIndex = 0;
326326
auto selectedModel = supportedModels[0];
327327
// Model list
328-
for(auto model : supportedModels)
328+
for(auto& model : supportedModels)
329329
{
330330
m_models.push_back(model.modelName);
331331
if(modelIndex == m_selectedModel)
@@ -343,7 +343,7 @@ void AddInstrumentDialog::UpdateCombos()
343343

344344
// Transport list
345345
int transportIndex = 0;
346-
for(auto transport : selectedModel.supportedTransports)
346+
for(auto& transport : selectedModel.supportedTransports)
347347
{
348348
string transportName = to_string(transport.transportType);
349349
// Prepare transport type for default value
@@ -372,7 +372,7 @@ void AddInstrumentDialog::UpdateCombos()
372372
// Update endpoint list
373373
auto endpoints = SCPITransport::EnumEndpoints(m_transports[m_selectedTransport]);
374374
int endpointIndex = 0;
375-
for(auto endpoint : endpoints)
375+
for(auto& endpoint : endpoints)
376376
{
377377
m_endpoints.push_back(endpoint);
378378
m_endpointNames.push_back(endpoint.path + " ("+ endpoint.description +")");

src/ngscopeclient/Dialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ void Dialog::HelpMarker(const string& header, const vector<string>& bullets)
223223
ImGui::BeginTooltip();
224224
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 50);
225225
ImGui::TextUnformatted(header.c_str());
226-
for(auto s : bullets)
226+
for(auto& s : bullets)
227227
ImGui::BulletText("%s", s.c_str());
228228
ImGui::PopTextWrapPos();
229229
ImGui::EndTooltip();

src/ngscopeclient/EmbeddedTriggerPropertiesDialog.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,11 @@ EmbeddedTriggerPropertiesDialog::EmbeddedTriggerPropertiesDialog(shared_ptr<Osci
4242
ImVec2(300, 400),
4343
nullptr,
4444
true)
45+
, m_page(make_unique<TriggerPropertiesPage>(scope))
46+
, m_triggerTypeIndex(0)
4547
, m_scope(scope)
4648
{
47-
m_page = make_unique<TriggerPropertiesPage>(scope);
48-
4949
//Figure out combo index for active trigger
50-
m_triggerTypeIndex = 0;
5150
vector<string> types = scope->GetTriggerTypes();
5251
auto trig = scope->GetTrigger();
5352
string ttype;

src/ngscopeclient/FilterGraphEditor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ using namespace std;
5353

5454
FilterGraphGroup::FilterGraphGroup(FilterGraphEditor& ed)
5555
: m_parent(ed)
56+
, m_outputId(ed.AllocateID())
57+
, m_inputId(ed.AllocateID())
5658
{
57-
m_outputId = ed.AllocateID();
58-
m_inputId = ed.AllocateID();
5959
}
6060

6161
/**
@@ -2616,7 +2616,7 @@ void FilterGraphEditor::DoAddMenu()
26162616
ImGui::PushFont(nullptr, 0);
26172617

26182618
//Do all of the menu items
2619-
for(auto fname : sortedNames)
2619+
for(auto& fname : sortedNames)
26202620
{
26212621
//Hide everything but import filters
26222622
if(fname.find("Import") == string::npos)

src/ngscopeclient/MeasurementsDialog.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* ngscopeclient *
44
* *
5-
* Copyright (c) 2012-2023 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 *
@@ -42,15 +42,14 @@ using namespace std;
4242
// Construction / destruction
4343

4444
MeasurementsDialog::MeasurementsDialog(Session& session)
45-
: Dialog("Measurements", "Measurements", ImVec2(300, 400))
46-
, m_session(session)
45+
: Dialog("Measurements", "Measurements", ImVec2(300, 400), &session)
4746
{
4847

4948
}
5049

5150
MeasurementsDialog::~MeasurementsDialog()
5251
{
53-
for(auto s : m_streams)
52+
for(auto& s : m_streams)
5453
{
5554
auto ochan = dynamic_cast<OscilloscopeChannel*>(s.m_channel);
5655
if(ochan)

src/ngscopeclient/MeasurementsDialog.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* ngscopeclient *
44
* *
5-
* Copyright (c) 2012-2023 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 *
@@ -55,7 +55,6 @@ class MeasurementsDialog : public Dialog
5555
{ return (m_streamset.find(stream) != m_streamset.end()); }
5656

5757
protected:
58-
Session& m_session;
5958

6059
void RemoveStream(size_t i);
6160

0 commit comments

Comments
 (0)