clang-tidy: bugprone-virtual-near-miss

A few virtual functions are called by constructors or destructors, which is
dangerous in C++ (as an overridden virtual impl won't be called, only the
one in the current class).  Fix by either marking the function final or
not calling at all (if possible).
This commit is contained in:
Peter Johnson
2020-12-26 22:06:28 -08:00
parent cbe59fa3bf
commit b60eb1544b
22 changed files with 14 additions and 25 deletions

View File

@@ -23,7 +23,6 @@ NTCommandSchedulerModel::NTCommandSchedulerModel(NT_Inst instance,
m_nt.AddListener(m_commands);
m_nt.AddListener(m_ids);
m_nt.AddListener(m_cancel);
Update();
}
void NTCommandSchedulerModel::CancelCommand(size_t index) {

View File

@@ -19,7 +19,6 @@ NTCommandSelectorModel::NTCommandSelectorModel(NT_Inst instance,
m_runningData.SetDigital(true);
m_nt.AddListener(m_running);
m_nt.AddListener(m_name);
Update();
}
void NTCommandSelectorModel::SetRunning(bool run) {

View File

@@ -21,7 +21,6 @@ NTDigitalInputModel::NTDigitalInputModel(NT_Inst inst, wpi::StringRef path)
m_nt.AddListener(m_name);
m_valueData.SetDigital(true);
Update();
}
void NTDigitalInputModel::Update() {

View File

@@ -22,7 +22,6 @@ NTDigitalOutputModel::NTDigitalOutputModel(NT_Inst inst, wpi::StringRef path)
m_nt.AddListener(m_controllable);
m_valueData.SetDigital(true);
Update();
}
void NTDigitalOutputModel::SetValue(bool val) {

View File

@@ -37,7 +37,6 @@ NTFMSModel::NTFMSModel(NT_Inst inst, wpi::StringRef path)
m_enabled.SetDigital(true);
m_test.SetDigital(true);
m_autonomous.SetDigital(true);
Update();
}
wpi::StringRef NTFMSModel::GetGameSpecificMessage(

View File

@@ -147,7 +147,7 @@ void NTField2DModel::GroupModel::ObjectModel::SetPoseImpl(double x, double y,
return;
}
auto origArr = value->GetDoubleArray();
if (origArr.size() < static_cast<size_t>((m_index + 1) * 3)) {
if (static_cast<int>(origArr.size()) < ((m_index + 1) * 3)) {
return;
}

View File

@@ -17,7 +17,6 @@ NTGyroModel::NTGyroModel(NT_Inst instance, wpi::StringRef path)
m_nameValue(path.rsplit('/').second) {
m_nt.AddListener(m_angle);
m_nt.AddListener(m_name);
Update();
}
void NTGyroModel::Update() {

View File

@@ -27,7 +27,6 @@ NTPIDControllerModel::NTPIDControllerModel(NT_Inst instance,
m_nt.AddListener(m_i);
m_nt.AddListener(m_d);
m_nt.AddListener(m_setpoint);
Update();
}
void NTPIDControllerModel::SetP(double value) {

View File

@@ -18,7 +18,6 @@ NTSpeedControllerModel::NTSpeedControllerModel(NT_Inst instance,
m_nameValue(path.rsplit('/').second) {
m_nt.AddListener(m_value);
m_nt.AddListener(m_name);
Update();
}
void NTSpeedControllerModel::SetPercent(double value) {

View File

@@ -19,8 +19,6 @@ NTStringChooserModel::NTStringChooserModel(NT_Inst inst, wpi::StringRef path)
m_nt.AddListener(m_selected);
m_nt.AddListener(m_active);
m_nt.AddListener(m_options);
Update();
}
void NTStringChooserModel::SetDefault(wpi::StringRef val) {

View File

@@ -17,7 +17,6 @@ NTSubsystemModel::NTSubsystemModel(NT_Inst instance, wpi::StringRef path)
m_nt.AddListener(m_name);
m_nt.AddListener(m_defaultCommand);
m_nt.AddListener(m_currentCommand);
Update();
}
void NTSubsystemModel::Update() {