ipmbsensor: fix clang-tidy warning
clang-tidy-20 is much more aggressive about accessing std::optional
values, even though we have plenty of fencing in this case. Use
`value_or` to squash the clang-tidy warning.
```
../src/ipmb/IpmbSensor.cpp:165:53: error: unchecked access to optional value [bugprone-unchecked-optional-access,-warnings-as-errors]
165 | "sendRequest", commandAddress, netfn, lun, *initCommand, initData);
| ^
```
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ice3ac15dc74c3193d24a03d627555244ffc0dadb
diff --git a/src/ipmb/IpmbSensor.cpp b/src/ipmb/IpmbSensor.cpp
index 658c875..a1f5db2 100644
--- a/src/ipmb/IpmbSensor.cpp
+++ b/src/ipmb/IpmbSensor.cpp
@@ -125,10 +125,7 @@
{
loadDefaults();
setInitialProperties(getSubTypeUnits());
- if (initCommand)
- {
- runInitCmd();
- }
+ runInitCmd();
read();
}
@@ -151,7 +148,7 @@
void IpmbSensor::runInitCmd()
{
- if (!initCommand)
+ if (!initCommand.has_value())
{
return;
}
@@ -162,7 +159,8 @@
},
"xyz.openbmc_project.Ipmi.Channel.Ipmb",
"/xyz/openbmc_project/Ipmi/Channel/Ipmb", "org.openbmc.Ipmb",
- "sendRequest", commandAddress, netfn, lun, *initCommand, initData);
+ "sendRequest", commandAddress, netfn, lun, initCommand.value_or(0),
+ initData);
}
void IpmbSensor::loadDefaults()