pmt: reformat code

This commit is contained in:
2025-08-25 13:20:21 +03:00
parent 80bcc0268d
commit 631c735a9a
4 changed files with 20 additions and 19 deletions

View File

@@ -72,7 +72,8 @@ void basic_function_manager::registerFunction(
LOGN(PMTF, INFO) << "registering function: " << _func->name() << std::endl; 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) { 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; return;
} }
} }

View File

@@ -16,13 +16,13 @@
#include "functions/functions.hpp" #include "functions/functions.hpp"
#include <PartitionManager/PartitionManager.hpp> #include <PartitionManager/PartitionManager.hpp>
#include <unistd.h> #include <csignal>
#include <cstdarg> #include <cstdarg>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <csignal>
#include <generated/buildInfo.hpp> #include <generated/buildInfo.hpp>
#include <string> #include <string>
#include <unistd.h>
namespace PartitionManager { namespace PartitionManager {
@@ -40,20 +40,21 @@ basic_variables::basic_variables()
} }
} }
__attribute__((constructor)) __attribute__((constructor)) void init() {
void init() {
Helper::LoggingProperties::setLogFile("/sdcard/Documents/last_pmt_logs.log"); Helper::LoggingProperties::setLogFile("/sdcard/Documents/last_pmt_logs.log");
} }
static void sigHandler(const int sig) { 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); if (sig == SIGINT) println("\n%sInterrupted.%s", YELLOW, STYLE_RESET);
exit(sig); exit(sig);
} }
static int write(void *cookie, const char *buf, const int size) { static int write(void *cookie, const char *buf, const int size) {
auto *real = static_cast<FILE *>(cookie); auto *real = static_cast<FILE *>(cookie);
if (!Variables->quietProcess) return fwrite(buf, 1, static_cast<size_t>(size), real); if (!Variables->quietProcess)
return fwrite(buf, 1, static_cast<size_t>(size), real);
else return size; else return size;
} }

View File

@@ -91,8 +91,7 @@ bool memoryTestFunction::run() {
const double writeTime = const double writeTime =
std::chrono::duration<double>(endWrite - startWrite).count(); std::chrono::duration<double>(endWrite - startWrite).count();
println("Sequential write speed: %3.f MB/s", println("Sequential write speed: %3.f MB/s",
(static_cast<double>(testFileSize) / (1024.0 * 1024.0)) / (static_cast<double>(testFileSize) / (1024.0 * 1024.0)) / writeTime);
writeTime);
LOGN(MTFUN, INFO) << "Sequential write test done!" << std::endl; LOGN(MTFUN, INFO) << "Sequential write test done!" << std::endl;
if (!doNotReadTest) { if (!doNotReadTest) {

View File

@@ -27,7 +27,8 @@ bool realPathFunction::init(CLI::App &_app) {
cmd->add_option("partition(s)", partitions, "Partition name(s)") cmd->add_option("partition(s)", partitions, "Partition name(s)")
->required() ->required()
->delimiter(','); ->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; return true;
} }
@@ -49,8 +50,7 @@ bool realPathFunction::run() {
if (realLinkPath) if (realLinkPath)
println("%s", Variables->PartMap->getRealLinkPathOf(partition).data()); println("%s", Variables->PartMap->getRealLinkPathOf(partition).data());
else else println("%s", Variables->PartMap->getRealPathOf(partition).data());
println("%s", Variables->PartMap->getRealPathOf(partition).data());
} }
return true; return true;