From 967be2a4e82b1a125b26bb72a60318a4fb2b50c4 Mon Sep 17 00:00:00 2001 From: Brent Stapleton Date: Mon, 14 Jan 2019 10:35:25 -0800 Subject: uhd: mpm: apply clang-format to all files Applying formatting changes to all .cpp and .hpp files in the following directories: ``` find host/examples/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/tests/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/dboard/neon/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/dboard/magnesium/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/device3/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/mpmd/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/x300/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/utils/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find mpm/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file ``` Also formatted host/include/, except Cpp03 was used as a the language standard instead of Cpp11. ``` sed -i 's/ Cpp11/ Cpp03/g' .clang-format find host/include/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file ``` Formatting style was designated by the .clang-format file. --- mpm/lib/types/lockable.cpp | 14 +++------- mpm/lib/types/log_buf.cpp | 28 +++++--------------- mpm/lib/types/mmap_regs_iface.cpp | 56 ++++++++++++++------------------------- 3 files changed, 31 insertions(+), 67 deletions(-) (limited to 'mpm/lib/types') diff --git a/mpm/lib/types/lockable.cpp b/mpm/lib/types/lockable.cpp index 8710e8752..cdba9e335 100644 --- a/mpm/lib/types/lockable.cpp +++ b/mpm/lib/types/lockable.cpp @@ -11,9 +11,7 @@ using namespace mpm::types; class lockable_impl : public lockable { public: - lockable_impl( - std::shared_ptr spi_mutex - ) : _spi_mutex(spi_mutex) + lockable_impl(std::shared_ptr spi_mutex) : _spi_mutex(spi_mutex) { /* nop */ } @@ -32,11 +30,7 @@ private: std::shared_ptr _spi_mutex; }; -lockable::sptr lockable::make( - std::shared_ptr spi_mutex -) { - return std::make_shared( - spi_mutex - ); +lockable::sptr lockable::make(std::shared_ptr spi_mutex) +{ + return std::make_shared(spi_mutex); } - diff --git a/mpm/lib/types/log_buf.cpp b/mpm/lib/types/log_buf.cpp index f1ef0cbee..8e3f183cc 100644 --- a/mpm/lib/types/log_buf.cpp +++ b/mpm/lib/types/log_buf.cpp @@ -9,15 +9,11 @@ using namespace mpm::types; void log_buf::post( - const log_level_t log_level, - const std::string &component, - const std::string &message -) { + const log_level_t log_level, const std::string& component, const std::string& message) +{ { std::lock_guard l(_buf_lock); - _buf.push_back( - log_message(log_level, component, message) - ); + _buf.push_back(log_message(log_level, component, message)); } if (bool(_notify_callback)) { @@ -25,9 +21,8 @@ void log_buf::post( } } -void log_buf::set_notify_callback( - std::function callback -) { +void log_buf::set_notify_callback(std::function callback) +{ _notify_callback = callback; } @@ -35,20 +30,12 @@ std::tuple log_buf::pop() { std::lock_guard l(_buf_lock); if (_buf.empty()) { - return std::make_tuple( - log_level_t::NONE, - "", - "" - ); + return std::make_tuple(log_level_t::NONE, "", ""); } auto last_msg = _buf.front(); _buf.pop_front(); - return std::make_tuple( - last_msg.log_level, - last_msg.component, - last_msg.message - ); + return std::make_tuple(last_msg.log_level, last_msg.component, last_msg.message); } log_buf::sptr log_buf::make() @@ -61,4 +48,3 @@ log_buf::sptr log_buf::make_singleton() static auto log_sptr = log_buf::make(); return log_sptr; } - diff --git a/mpm/lib/types/mmap_regs_iface.cpp b/mpm/lib/types/mmap_regs_iface.cpp index 96457d7ad..18fa2abfa 100644 --- a/mpm/lib/types/mmap_regs_iface.cpp +++ b/mpm/lib/types/mmap_regs_iface.cpp @@ -4,30 +4,26 @@ // SPDX-License-Identifier: GPL-3.0-or-later // -#include +#include #include -#include -#include -#include -#include +#include #include +#include +#include #include -#include +#include +#include #include using namespace mpm::types; -mmap_regs_iface::mmap_regs_iface( - const std::string &path, +mmap_regs_iface::mmap_regs_iface(const std::string& path, const size_t length, const size_t offset, const bool read_only, - const bool open_now -) : _path(path) - , _length(length) - , _offset(offset) - , _read_only(read_only) + const bool open_now) + : _path(path), _length(length), _offset(offset), _read_only(read_only) { if (open_now) { open(); @@ -53,26 +49,23 @@ void mmap_regs_iface::open() } if (!_mmap) { - _mmap = (uint32_t *) ::mmap( - NULL, + _mmap = (uint32_t*)::mmap(NULL, _length, PROT_READ | (_read_only ? 0 : PROT_WRITE), MAP_SHARED, _fd, - (off_t) _offset - ); - if (((void *) _mmap) == MAP_FAILED) { + (off_t)_offset); + if (((void*)_mmap) == MAP_FAILED) { throw mpm::runtime_error("Failed to mmap!"); } } - log(mpm::types::log_level_t::TRACE, _path, - "Opened mmap_regs_iface"); + log(mpm::types::log_level_t::TRACE, _path, "Opened mmap_regs_iface"); } void mmap_regs_iface::close() { if (_mmap) { - int err = munmap((void *) _mmap, _length); + int err = munmap((void*)_mmap, _length); if (err) { throw mpm::runtime_error("Couldn't munmap!"); } @@ -85,14 +78,11 @@ void mmap_regs_iface::close() } _fd = -1; } - log(mpm::types::log_level_t::TRACE, _path, - "Closed mmap_regs_iface"); + log(mpm::types::log_level_t::TRACE, _path, "Closed mmap_regs_iface"); } -void mmap_regs_iface::poke32( - const uint32_t addr, - const uint32_t data -) { +void mmap_regs_iface::poke32(const uint32_t addr, const uint32_t data) +{ MPM_ASSERT_THROW(_mmap); _mmap[addr / sizeof(uint32_t)] = data; } @@ -104,14 +94,8 @@ uint32_t mmap_regs_iface::peek32(const uint32_t addr) } void mmap_regs_iface::log( - mpm::types::log_level_t level, - const std::string path, - const char *comment -) { + mpm::types::log_level_t level, const std::string path, const char* comment) +{ mpm::types::log_buf::make_singleton()->post( - level, - "MMAP_REGS_IFACE", - str(boost::format("[UIO %s] %s") - % path % comment) - ); + level, "MMAP_REGS_IFACE", str(boost::format("[UIO %s] %s") % path % comment)); } -- cgit v1.2.3