NVMeBasicContext: Reject bad I2C bus IDs
We can't possibly query such sensors, so ensure they can't exist.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I899979db57a84272be9b537d87e54756296695cf
diff --git a/src/NVMeSensor.cpp b/src/NVMeSensor.cpp
index 89b21b0..d293737 100644
--- a/src/NVMeSensor.cpp
+++ b/src/NVMeSensor.cpp
@@ -33,6 +33,11 @@
PowerState::on),
bus(busNumber), objServer(objectServer)
{
+ if (bus < 0)
+ {
+ throw std::invalid_argument("Invalid bus: Bus ID must not be negative");
+ }
+
sensorInterface = objectServer.add_interface(
"/xyz/openbmc_project/sensors/temperature/" + name,
"xyz.openbmc_project.Sensor.Value");