From b161d20b48aca082deeddca64f3d3fa6e4dc99a8 Mon Sep 17 00:00:00 2001 From: Robin Linden Date: Thu, 28 Dec 2023 18:41:05 +0100 Subject: [PATCH 1/3] chore: Stop requiring bazel-opt to pass It's currently not possible to build jvm-toxcore-c via toktok-stack. --- .github/settings.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/settings.yml b/.github/settings.yml index 118920f46..19973be34 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -12,6 +12,5 @@ branches: protection: required_status_checks: contexts: - - bazel-opt - Codacy Static Code Analysis - code-review/reviewable From 05bd1abbda5e58e4d236563c3d2c0de25ed66d28 Mon Sep 17 00:00:00 2001 From: Robin Linden Date: Sat, 4 Nov 2023 00:35:36 +0100 Subject: [PATCH 2/3] chore: Fix build w/ libstdc++13 ``` In file included from cpp/src/util/logging.cpp:1: cpp/src/util/logging.h:47:36: error: unknown type name 'uint8_t' 47 | void output_hex (std::ostream &os, uint8_t const *data, size_t length); ``` --- cpp/src/util/logging.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cpp/src/util/logging.h b/cpp/src/util/logging.h index f65148868..6d4a0ffdc 100644 --- a/cpp/src/util/logging.h +++ b/cpp/src/util/logging.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include From f697eef5d0a16a025b187c3369288986e89bde2b Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 3 Nov 2023 23:37:32 +0000 Subject: [PATCH 3/3] style: Format the code the way restyled wants --- cpp/src/util/logging.h | 79 ++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 49 deletions(-) diff --git a/cpp/src/util/logging.h b/cpp/src/util/logging.h index 6d4a0ffdc..6c3bf8bad 100644 --- a/cpp/src/util/logging.h +++ b/cpp/src/util/logging.h @@ -5,80 +5,61 @@ #include #include - -struct scope_counter -{ +struct scope_counter { static std::size_t scope; - scope_counter () - { scope++; } + scope_counter() { scope++; } - ~scope_counter () - { scope--; } + ~scope_counter() { scope--; } - scope_counter (scope_counter const &rhs) = delete; + scope_counter(scope_counter const &rhs) = delete; }; -std::ostream &scope_indent (std::ostream &os, int line); +std::ostream &scope_indent(std::ostream &os, int line); #define SCOPE scope_counter const _scope - #ifdef HAVE_GLOG -# include -# undef LOG -# define LOG(KIND) scope_indent (COMPACT_GOOGLE_LOG_##KIND.stream(), __LINE__) +#include +#undef LOG +#define LOG(KIND) scope_indent(COMPACT_GOOGLE_LOG_##KIND.stream(), __LINE__) #else -namespace google -{ - inline void InitGoogleLogging (char const *) { } - inline void ShutdownGoogleLogging () { } - inline void LogToStderr () { } -} +namespace google { +inline void InitGoogleLogging(char const *) {} +inline void ShutdownGoogleLogging() {} +inline void LogToStderr() {} +} // namespace google -struct null_ostream - : std::ostream -{ -}; +struct null_ostream : std::ostream {}; -# define LOG(LEVEL) (null_ostream ()) -# define LOG_ASSERT(cond) assert (cond) +#define LOG(LEVEL) (null_ostream()) +#define LOG_ASSERT(cond) assert(cond) #endif -void output_hex (std::ostream &os, uint8_t const *data, size_t length); - +void output_hex(std::ostream &os, uint8_t const *data, size_t length); -struct formatter -{ - formatter (formatter &&fmt) - : text_ (std::move (fmt.text_)) - { } +struct formatter { + formatter(formatter &&fmt) : text_(std::move(fmt.text_)) {} - explicit formatter (std::vector text) - : text_ (std::move (text)) - { } + explicit formatter(std::vector text) : text_(std::move(text)) {} - friend std::ostream &operator << (std::ostream &os, formatter const &fmt); + friend std::ostream &operator<<(std::ostream &os, formatter const &fmt); private: std::vector const text_; }; +template +formatter format(char const (&fmt)[N], Args const &...args) { + std::vector text(snprintf(nullptr, 0, fmt, args...) + 1); + snprintf(text.data(), text.size(), fmt, args...); -template -formatter -format (char const (&fmt)[N], Args const &...args) -{ - std::vector text (snprintf (nullptr, 0, fmt, args...) + 1); - snprintf (text.data (), text.size (), fmt, args...); - - return formatter (std::move (text)); + return formatter(std::move(text)); } -template -std::ostream & -operator << (std::ostream &os, std::array const &array) -{ - output_hex (os, array.data (), array.size ()); +template +std::ostream &operator<<(std::ostream &os, + std::array const &array) { + output_hex(os, array.data(), array.size()); return os; }