Commit f9322eec authored by Micha Mueller's avatar Micha Mueller
Browse files

Fix compiler errors in Perf plugin

parent d76931a3
......@@ -160,7 +160,7 @@ bool PerfeventConfigurator::readConfig(std::string cfgPath) {
}
//group which consists of only one sensor
PerfSensorBase* sensor = new PerfSensorBase(val.second.data());
std::shared_ptr<PerfSensorBase> sensor = std::make_shared<PerfSensorBase>(val.second.data());
if (readSensorBase(*sensor, val.second)) {
group->pushBackSensor(sensor);
......@@ -171,7 +171,6 @@ bool PerfeventConfigurator::readConfig(std::string cfgPath) {
}
} else {
LOG(warning) << "Template single " << _baseName << " " << val.second.data() << " could not be read! Omitting";
delete sensor;
delete group;
}
} else {
......@@ -196,24 +195,28 @@ bool PerfeventConfigurator::readConfig(std::string cfgPath) {
PerfSensorGroup group(val.second.data());
if (readSensorGroup(group, val.second)) {
//group which consists of only one sensor
PerfSensorBase* sensor;
std::shared_ptr<PerfSensorBase> sensor;
//perhaps one sensor is already present because it was copied from the template group
if (group.getSensors().size() != 0) {
sensor = dynamic_cast<PerfSensorBase*>(group.getSensors()[0]);
sensor->setName(val.second.data());
if (readSensorBase(*sensor, val.second)) {
customizeAndStore(group, val.second);
} else {
LOG(warning) << "Single " << _baseName << " " << val.second.data() << " could not be read! Omitting";
}
sensor = std::dynamic_pointer_cast<PerfSensorBase>(group.getSensors()[0]);
//check if cast was successful (sensor != nullptr)
if (sensor) {
sensor->setName(val.second.data());
if (readSensorBase(*sensor, val.second)) {
customizeAndStore(group, val.second);
} else {
LOG(warning) << "Single " << _baseName << " " << val.second.data() << " could not be read! Omitting";
}
} else {
LOG(warning) << "Single " << _baseName << " " << val.second.data() << " had a type mismatch when casting! Omitting";
}
} else {
sensor = new PerfSensorBase(val.second.data());
sensor = std::make_shared<PerfSensorBase>(val.second.data());
if (readSensorBase(*sensor, val.second)) {
group.pushBackSensor(sensor);
customizeAndStore(group, val.second);
} else {
LOG(warning) << "Single " << _baseName << " " << val.second.data() << " could not be read! Omitting";
delete sensor;
}
}
} else {
......
Markdown is supported
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