From 18ed7c6cafec5a14751500ebfbb75d1262cfefbe Mon Sep 17 00:00:00 2001 From: QMK Bot Date: Thu, 9 Apr 2026 22:26:08 +1000 Subject: [PATCH] [CI] Format code according to conventions (#26138) Format code according to conventions --- drivers/bluetooth/ringbuffer.hpp | 101 +++++++++++---------- tests/test_common/keyboard_report_util.hpp | 10 +- tests/test_common/test_logger.hpp | 2 +- 3 files changed, 58 insertions(+), 55 deletions(-) diff --git a/drivers/bluetooth/ringbuffer.hpp b/drivers/bluetooth/ringbuffer.hpp index 70a3c4881d..ea0c564ec9 100644 --- a/drivers/bluetooth/ringbuffer.hpp +++ b/drivers/bluetooth/ringbuffer.hpp @@ -2,65 +2,68 @@ // A simple ringbuffer holding Size elements of type T template class RingBuffer { - protected: - T buf_[Size]; - uint8_t head_{0}, tail_{0}; - public: - inline uint8_t nextPosition(uint8_t position) { - return (position + 1) % Size; - } + protected: + T buf_[Size]; + uint8_t head_{0}, tail_{0}; - inline uint8_t prevPosition(uint8_t position) { - if (position == 0) { - return Size - 1; - } - return position - 1; - } - - inline bool enqueue(const T &item) { - static_assert(Size > 1, "RingBuffer size must be > 1"); - uint8_t next = nextPosition(head_); - if (next == tail_) { - // Full - return false; + public: + inline uint8_t nextPosition(uint8_t position) { + return (position + 1) % Size; } - buf_[head_] = item; - head_ = next; - return true; - } - - inline bool get(T &dest, bool commit = true) { - auto tail = tail_; - if (tail == head_) { - // No more data - return false; + inline uint8_t prevPosition(uint8_t position) { + if (position == 0) { + return Size - 1; + } + return position - 1; } - dest = buf_[tail]; - tail = nextPosition(tail); + inline bool enqueue(const T &item) { + static_assert(Size > 1, "RingBuffer size must be > 1"); + uint8_t next = nextPosition(head_); + if (next == tail_) { + // Full + return false; + } - if (commit) { - tail_ = tail; + buf_[head_] = item; + head_ = next; + return true; } - return true; - } - inline bool empty() const { return head_ == tail_; } + inline bool get(T &dest, bool commit = true) { + auto tail = tail_; + if (tail == head_) { + // No more data + return false; + } - inline uint8_t size() const { - int diff = head_ - tail_; - if (diff >= 0) { - return diff; + dest = buf_[tail]; + tail = nextPosition(tail); + + if (commit) { + tail_ = tail; + } + return true; } - return Size + diff; - } - inline T& front() { - return buf_[tail_]; - } + inline bool empty() const { + return head_ == tail_; + } - inline bool peek(T &item) { - return get(item, false); - } + inline uint8_t size() const { + int diff = head_ - tail_; + if (diff >= 0) { + return diff; + } + return Size + diff; + } + + inline T &front() { + return buf_[tail_]; + } + + inline bool peek(T &item) { + return get(item, false); + } }; diff --git a/tests/test_common/keyboard_report_util.hpp b/tests/test_common/keyboard_report_util.hpp index 2c33f0412e..8a7d716869 100644 --- a/tests/test_common/keyboard_report_util.hpp +++ b/tests/test_common/keyboard_report_util.hpp @@ -19,21 +19,21 @@ #include #include "gmock/gmock.h" -bool operator==(const report_keyboard_t& lhs, const report_keyboard_t& rhs); +bool operator==(const report_keyboard_t& lhs, const report_keyboard_t& rhs); std::ostream& operator<<(std::ostream& stream, const report_keyboard_t& value); class KeyboardReportMatcher : public testing::MatcherInterface { - public: + public: KeyboardReportMatcher(const std::vector& keys); virtual bool MatchAndExplain(report_keyboard_t& report, testing::MatchResultListener* listener) const override; virtual void DescribeTo(::std::ostream* os) const override; virtual void DescribeNegationTo(::std::ostream* os) const override; -private: + + private: report_keyboard_t m_report; }; - -template +template inline testing::Matcher KeyboardReport(Ts... keys) { return testing::MakeMatcher(new KeyboardReportMatcher(std::vector({keys...}))); } diff --git a/tests/test_common/test_logger.hpp b/tests/test_common/test_logger.hpp index 4964583ded..010adc138e 100644 --- a/tests/test_common/test_logger.hpp +++ b/tests/test_common/test_logger.hpp @@ -21,7 +21,7 @@ class TestLogger : public std::ostream { public: - TestLogger() : std::ostream(&m_log){}; + TestLogger() : std::ostream(&m_log) {}; TestLogger& info(); TestLogger& trace(); TestLogger& error();