Check object existence before adding it to the PST
Currently, adding new objects/components to the FixedSlotSequence PST is not being checked, meaning that it is possible to add NULL objects here without any warning. This causes NULL-pointer errors when non-existent components are added, which can be hard to debug. To solve this, add a check for the object existence before adding it to PST and emit an error message. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
This commit is contained in:
parent
fa6cbe7e0c
commit
d17146d847
@ -57,6 +57,11 @@ ReturnValue_t FixedTimeslotTask::startTask() {
|
|||||||
|
|
||||||
ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
|
ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
|
||||||
uint32_t slotTimeMs, int8_t executionStep) {
|
uint32_t slotTimeMs, int8_t executionStep) {
|
||||||
|
if (!objectManager->get<ExecutableObjectIF>(componentId)) {
|
||||||
|
error << "Component " << std::hex << componentId << " not found, not adding it to pst" << std::endl;
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
pst.addSlot(componentId, slotTimeMs, executionStep, this);
|
pst.addSlot(componentId, slotTimeMs, executionStep, this);
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,11 @@ uint32_t FixedTimeslotTask::getPeriodMs() const {
|
|||||||
|
|
||||||
ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
|
ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
|
||||||
uint32_t slotTimeMs, int8_t executionStep) {
|
uint32_t slotTimeMs, int8_t executionStep) {
|
||||||
|
if (!objectManager->get<ExecutableObjectIF>(componentId)) {
|
||||||
|
error << "Component " << std::hex << componentId << " not found, not adding it to pst" << std::endl;
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
pst.addSlot(componentId, slotTimeMs, executionStep, this);
|
pst.addSlot(componentId, slotTimeMs, executionStep, this);
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user