From 39807cc9e2f554c626ab386996064e707e7e310f Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 19 Nov 2019 14:48:24 -0800 Subject: mpm: i2cdev: Fix formatting and compiler warnings - Remove superfluous includes - Fix return value of _open() (was int, now void) => Fewer compiler warnings - Apply clang-format - Add {} to all ifs --- mpm/lib/i2c/i2cdev_iface.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'mpm/lib') diff --git a/mpm/lib/i2c/i2cdev_iface.cpp b/mpm/lib/i2c/i2cdev_iface.cpp index b346597a8..9d2c6b4b2 100644 --- a/mpm/lib/i2c/i2cdev_iface.cpp +++ b/mpm/lib/i2c/i2cdev_iface.cpp @@ -1,18 +1,16 @@ // // Copyright 2018 Ettus Research, a National Instruments Company +// Copyright 2019 Ettus Research, a National Instruments Brand // // SPDX-License-Identifier: GPL-3.0-or-later // - #include "i2cdev.h" #include #include #include #include #include -#include -#include using namespace mpm::i2c; @@ -32,22 +30,25 @@ public: , _ten_bit_addr(ten_bit_addr) , _timeout_ms(timeout_ms) { - if (do_open) + if (do_open) { _open(); - else + } else { _fd = -ENODEV; + } } ~i2cdev_iface_impl() { - if (_fd >= 0) + if (_fd >= 0) { close(_fd); + } } int transfer(uint8_t* tx, size_t tx_len, uint8_t* rx, size_t rx_len, bool do_close) { - if (_fd < 0) + if (_fd < 0) { _open(); + } int ret = i2cdev_transfer(_fd, _addr, _ten_bit_addr, tx, tx_len, rx, rx_len); @@ -57,7 +58,7 @@ public: } if (ret) { - throw mpm::runtime_error(str(boost::format("I2C Transaction failed!"))); + throw mpm::runtime_error("I2C Transaction failed!"); } return ret; @@ -89,16 +90,16 @@ private: const bool _ten_bit_addr; const unsigned int _timeout_ms; - int _open(void) + void _open(void) { if (i2cdev_open(&_fd, _device.c_str(), _timeout_ms) < 0) { throw mpm::runtime_error( - str(boost::format("Could not initialize i2cdev device %s") % _device)); + std::string("Could not initialize i2cdev device ") + _device); } if (_fd < 0) { throw mpm::runtime_error( - str(boost::format("Could not open i2cdev device %s") % _device)); + std::string("Could not open i2cdev device ") + _device); } } }; -- cgit v1.2.3