From 653c14fcbb403a69f21f0af92ee5bf84b4c8109d Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Thu, 19 Mar 2015 10:18:11 -0700 Subject: [PATCH] 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 --- src/drivers/device/i2c_linux.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/drivers/device/i2c_linux.cpp b/src/drivers/device/i2c_linux.cpp index e62da87979..4548b475af 100644 --- a/src/drivers/device/i2c_linux.cpp +++ b/src/drivers/device/i2c_linux.cpp @@ -63,7 +63,7 @@ I2C::I2C(const char *name, _bus(bus), _address(address), _fd(-1), - _dname(devname) + _dname() { // fill in _device_id fields for a I2C device _device_id.devid_s.bus_type = DeviceBusType_I2C; @@ -71,6 +71,9 @@ I2C::I2C(const char *name, _device_id.devid_s.address = address; // devtype needs to be filled in by the driver _device_id.devid_s.devtype = 0; + + if (devname) + _dname = devname; } I2C::~I2C()