From 631c735a9a50f739fbeeb20e99ba5ad92cd97e1e Mon Sep 17 00:00:00 2001 From: YZBruh Date: Mon, 25 Aug 2025 13:20:21 +0300 Subject: [PATCH] pmt: reformat code --- src/FunctionManager.cpp | 5 +++-- src/PartitionManager.cpp | 25 +++++++++++++------------ src/functions/MemoryTestFunction.cpp | 3 +-- src/functions/RealPathFunction.cpp | 6 +++--- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/FunctionManager.cpp b/src/FunctionManager.cpp index 5efffe1..6c5dd44 100644 --- a/src/FunctionManager.cpp +++ b/src/FunctionManager.cpp @@ -70,9 +70,10 @@ void processCommandLine(std::vector &vec1, void basic_function_manager::registerFunction( std::unique_ptr _func, CLI::App &_app) { LOGN(PMTF, INFO) << "registering function: " << _func->name() << std::endl; - for (const auto& f : _functions) { + for (const auto &f : _functions) { if (strcmp(f->name(), _func->name()) != 0) { - LOGN(PMTF, INFO) << "Function is already registered: " << _func->name() << ". Skipping." << std::endl; + LOGN(PMTF, INFO) << "Function is already registered: " << _func->name() + << ". Skipping." << std::endl; return; } } diff --git a/src/PartitionManager.cpp b/src/PartitionManager.cpp index e0d6826..bf085da 100644 --- a/src/PartitionManager.cpp +++ b/src/PartitionManager.cpp @@ -16,18 +16,18 @@ #include "functions/functions.hpp" #include -#include +#include #include #include #include -#include #include #include +#include namespace PartitionManager { // Usage: REGISTER_FUNCTION(FUNCTION_CLASS); -#define REGISTER_FUNCTION(cls) \ +#define REGISTER_FUNCTION(cls) \ FuncManager.registerFunction(std::make_unique(), AppMain) basic_variables::basic_variables() @@ -40,30 +40,31 @@ basic_variables::basic_variables() } } -__attribute__((constructor)) -void init() { +__attribute__((constructor)) void init() { Helper::LoggingProperties::setLogFile("/sdcard/Documents/last_pmt_logs.log"); } static void sigHandler(const int sig) { - // Even if only SIGINT is to be captured for now, this is still a more appropriate code + // Even if only SIGINT is to be captured for now, this is still a more + // appropriate code if (sig == SIGINT) println("\n%sInterrupted.%s", YELLOW, STYLE_RESET); exit(sig); } static int write(void *cookie, const char *buf, const int size) { - auto *real = static_cast(cookie); - if (!Variables->quietProcess) return fwrite(buf, 1, static_cast(size), real); + auto *real = static_cast(cookie); + if (!Variables->quietProcess) + return fwrite(buf, 1, static_cast(size), real); else return size; } -static FILE* make_fp(FILE* real) { +static FILE *make_fp(FILE *real) { return funopen(real, nullptr, write, nullptr, nullptr); } auto Variables = std::make_unique(); -FILE* pstdout = make_fp(stdout); -FILE* pstderr = make_fp(stderr); +FILE *pstdout = make_fp(stdout); +FILE *pstderr = make_fp(stderr); int Main(int argc, char **argv) { try { @@ -151,7 +152,7 @@ int Main(int argc, char **argv) { // catch Helper::Error fprintf(pstderr, "%s%sERROR(S) OCCURRED:%s\n%s", RED, BOLD, STYLE_RESET, - error.what()); + error.what()); return EXIT_FAILURE; } catch (CLI::Error &error) { // catch CLI::Error diff --git a/src/functions/MemoryTestFunction.cpp b/src/functions/MemoryTestFunction.cpp index 7b85b49..b4cefc8 100644 --- a/src/functions/MemoryTestFunction.cpp +++ b/src/functions/MemoryTestFunction.cpp @@ -91,8 +91,7 @@ bool memoryTestFunction::run() { const double writeTime = std::chrono::duration(endWrite - startWrite).count(); println("Sequential write speed: %3.f MB/s", - (static_cast(testFileSize) / (1024.0 * 1024.0)) / - writeTime); + (static_cast(testFileSize) / (1024.0 * 1024.0)) / writeTime); LOGN(MTFUN, INFO) << "Sequential write test done!" << std::endl; if (!doNotReadTest) { diff --git a/src/functions/RealPathFunction.cpp b/src/functions/RealPathFunction.cpp index 17044dc..d861aa5 100644 --- a/src/functions/RealPathFunction.cpp +++ b/src/functions/RealPathFunction.cpp @@ -27,7 +27,8 @@ bool realPathFunction::init(CLI::App &_app) { cmd->add_option("partition(s)", partitions, "Partition name(s)") ->required() ->delimiter(','); - cmd->add_flag("--real-link-path", realLinkPath, "Print real link path(s)")->default_val(false); + cmd->add_flag("--real-link-path", realLinkPath, "Print real link path(s)") + ->default_val(false); return true; } @@ -49,8 +50,7 @@ bool realPathFunction::run() { if (realLinkPath) println("%s", Variables->PartMap->getRealLinkPathOf(partition).data()); - else - println("%s", Variables->PartMap->getRealPathOf(partition).data()); + else println("%s", Variables->PartMap->getRealPathOf(partition).data()); } return true;