Chore: run clang-format

```bash
find . -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.hpp" \) ! -path "src/3rdparty/*" -print0 | xargs -0 clang-format -i
```
This commit is contained in:
李通洲
2026-03-29 09:28:49 +08:00
parent cdd4cee968
commit e0eba8ce21
690 changed files with 28093 additions and 30062 deletions
+34 -43
View File
@@ -6,13 +6,11 @@
#include "detection/memory/memory.h"
#include "modules/memory/memory.h"
bool ffPrintMemory(FFMemoryOptions* options)
{
bool ffPrintMemory(FFMemoryOptions* options) {
FFMemoryResult storage = {};
const char* error = ffDetectMemory(&storage);
if(error)
{
if (error) {
ffPrintError(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return false;
}
@@ -28,81 +26,77 @@ bool ffPrintMemory(FFMemoryOptions* options)
: (double) storage.bytesUsed / (double) storage.bytesTotal * 100.0;
FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type;
if(options->moduleArgs.outputFormat.length == 0)
{
if (options->moduleArgs.outputFormat.length == 0) {
ffPrintLogoAndKey(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
if (storage.bytesTotal == 0)
if (storage.bytesTotal == 0) {
puts("Disabled");
else
{
} else {
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
if(percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
{
if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT) {
ffPercentAppendBar(&str, percentage, options->percent, &options->moduleArgs);
ffStrbufAppendC(&str, ' ');
}
if(!(percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
if (!(percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) {
ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars);
}
if(percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
if (percentType & FF_PERCENTAGE_TYPE_NUM_BIT) {
ffPercentAppendNum(&str, percentage, options->percent, str.length > 0, &options->moduleArgs);
}
ffStrbufTrimRight(&str, ' ');
ffStrbufPutTo(&str, stdout);
}
}
else
{
} else {
FF_STRBUF_AUTO_DESTROY percentageNum = ffStrbufCreate();
if (percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
if (percentType & FF_PERCENTAGE_TYPE_NUM_BIT) {
ffPercentAppendNum(&percentageNum, percentage, options->percent, false, &options->moduleArgs);
}
FF_STRBUF_AUTO_DESTROY percentageBar = ffStrbufCreate();
if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT) {
ffPercentAppendBar(&percentageBar, percentage, options->percent, &options->moduleArgs);
}
FF_PRINT_FORMAT_CHECKED(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
FF_ARG(usedPretty, "used"),
FF_ARG(totalPretty, "total"),
FF_ARG(percentageNum, "percentage"),
FF_ARG(percentageBar, "percentage-bar"),
}));
FF_PRINT_FORMAT_CHECKED(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
FF_ARG(usedPretty, "used"),
FF_ARG(totalPretty, "total"),
FF_ARG(percentageNum, "percentage"),
FF_ARG(percentageBar, "percentage-bar"),
}));
}
return true;
}
void ffParseMemoryJsonObject(FFMemoryOptions* options, yyjson_val* module)
{
void ffParseMemoryJsonObject(FFMemoryOptions* options, yyjson_val* module) {
yyjson_val *key, *val;
size_t idx, max;
yyjson_obj_foreach(module, idx, max, key, val)
{
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
yyjson_obj_foreach (module, idx, max, key, val) {
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) {
continue;
}
if (ffPercentParseJsonObject(key, val, &options->percent))
if (ffPercentParseJsonObject(key, val, &options->percent)) {
continue;
}
ffPrintError(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", unsafe_yyjson_get_str(key));
}
}
void ffGenerateMemoryJsonConfig(FFMemoryOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
{
void ffGenerateMemoryJsonConfig(FFMemoryOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs);
ffPercentGenerateJsonConfig(doc, module, options->percent);
}
bool ffGenerateMemoryJsonResult(FF_MAYBE_UNUSED FFMemoryOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
{
bool ffGenerateMemoryJsonResult(FF_MAYBE_UNUSED FFMemoryOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
FFMemoryResult storage = {};
const char* error = ffDetectMemory(&storage);
if(error)
{
if (error) {
yyjson_mut_obj_add_str(doc, module, "error", error);
return false;
}
@@ -114,14 +108,12 @@ bool ffGenerateMemoryJsonResult(FF_MAYBE_UNUSED FFMemoryOptions* options, yyjson
return true;
}
void ffInitMemoryOptions(FFMemoryOptions* options)
{
void ffInitMemoryOptions(FFMemoryOptions* options) {
ffOptionInitModuleArg(&options->moduleArgs, "");
options->percent = (FFPercentageModuleConfig) { 50, 80, 0 };
options->percent = (FFPercentageModuleConfig) {50, 80, 0};
}
void ffDestroyMemoryOptions(FFMemoryOptions* options)
{
void ffDestroyMemoryOptions(FFMemoryOptions* options) {
ffOptionDestroyModuleArg(&options->moduleArgs);
}
@@ -139,5 +131,4 @@ FFModuleBaseInfo ffMemoryModuleInfo = {
{"Total size", "total"},
{"Percentage used (num)", "percentage"},
{"Percentage used (bar)", "percentage-bar"},
}))
};
}))};