mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 20:13:35 +08:00
Linux: Handle nullptr passed to I2C constructor
I2C class derives from CDev class which requires a devname but in at least some instances, a nullptr is passed for devname. Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
@@ -63,7 +63,7 @@ I2C::I2C(const char *name,
|
|||||||
_bus(bus),
|
_bus(bus),
|
||||||
_address(address),
|
_address(address),
|
||||||
_fd(-1),
|
_fd(-1),
|
||||||
_dname(devname)
|
_dname()
|
||||||
{
|
{
|
||||||
// fill in _device_id fields for a I2C device
|
// fill in _device_id fields for a I2C device
|
||||||
_device_id.devid_s.bus_type = DeviceBusType_I2C;
|
_device_id.devid_s.bus_type = DeviceBusType_I2C;
|
||||||
@@ -71,6 +71,9 @@ I2C::I2C(const char *name,
|
|||||||
_device_id.devid_s.address = address;
|
_device_id.devid_s.address = address;
|
||||||
// devtype needs to be filled in by the driver
|
// devtype needs to be filled in by the driver
|
||||||
_device_id.devid_s.devtype = 0;
|
_device_id.devid_s.devtype = 0;
|
||||||
|
|
||||||
|
if (devname)
|
||||||
|
_dname = devname;
|
||||||
}
|
}
|
||||||
|
|
||||||
I2C::~I2C()
|
I2C::~I2C()
|
||||||
|
|||||||
Reference in New Issue
Block a user