Skip to content

Commit

Permalink
checking optional before accessing value
Browse files Browse the repository at this point in the history
Signed-off-by: pietfried <pietgoempel@gmail.com>
  • Loading branch information
Pietfried authored and corneliusclaussen committed Mar 23, 2023
1 parent cb86b46 commit 5a0840d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/EnergyManager/Market.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ ScheduleReq Market::get_max_available_energy(const ScheduleReq& request) {
(*r).limits_to_leaves.total_power_W.value() / (*r).conversion_efficiency.value_or(1.);
}
// do we have a lower watt limit on root side?
if ((*r).limits_to_root.total_power_W.has_value() &&
if ((*r).limits_to_root.total_power_W.has_value() && a.limits_to_root.total_power_W.has_value() &&
a.limits_to_root.total_power_W.value() > (*r).limits_to_root.total_power_W.value()) {
a.limits_to_root.total_power_W = (*r).limits_to_root.total_power_W.value();
}
Expand Down

0 comments on commit 5a0840d

Please sign in to comment.