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
+1 -2
View File
@@ -2,8 +2,7 @@
#include "common/option.h"
typedef struct FFPhysicalMemoryOptions
{
typedef struct FFPhysicalMemoryOptions {
FFModuleArgs moduleArgs;
bool showEmptySlots;
} FFPhysicalMemoryOptions;
+53 -68
View File
@@ -6,96 +6,91 @@
#define FF_PHYSICALMEMORY_DISPLAY_NAME "Physical Memory"
bool ffPrintPhysicalMemory(FFPhysicalMemoryOptions* options)
{
bool ffPrintPhysicalMemory(FFPhysicalMemoryOptions* options) {
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFPhysicalMemoryResult));
const char* error = ffDetectPhysicalMemory(&result);
if(error)
{
if (error) {
ffPrintError(FF_PHYSICALMEMORY_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return false;
}
if (result.length == 0)
{
if (result.length == 0) {
ffPrintError(FF_PHYSICALMEMORY_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No physical memory detected");
return false;
}
FF_LIST_AUTO_DESTROY filtered = ffListCreate(sizeof(FFPhysicalMemoryResult*));
FF_LIST_FOR_EACH(FFPhysicalMemoryResult, device, result)
{
if (!options->showEmptySlots && !device->installed)
FF_LIST_FOR_EACH (FFPhysicalMemoryResult, device, result) {
if (!options->showEmptySlots && !device->installed) {
continue;
}
*(FFPhysicalMemoryResult**) ffListAdd(&filtered) = device;
}
if (filtered.length == 0)
{
if (filtered.length == 0) {
ffPrintError(FF_PHYSICALMEMORY_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No installed physical memory detected");
return false;
}
FF_STRBUF_AUTO_DESTROY prettySize = ffStrbufCreate();
for (uint32_t i = 0; i < filtered.length; ++i)
{
for (uint32_t i = 0; i < filtered.length; ++i) {
FFPhysicalMemoryResult* device = *FF_LIST_GET(FFPhysicalMemoryResult*, filtered, i);
ffStrbufClear(&prettySize);
if (device->installed)
if (device->installed) {
ffSizeAppendNum(device->size, &prettySize);
}
if (options->moduleArgs.outputFormat.length == 0)
{
if (options->moduleArgs.outputFormat.length == 0) {
ffPrintLogoAndKey(FF_PHYSICALMEMORY_DISPLAY_NAME, filtered.length == 1 ? 0 : (uint8_t) (i + 1), &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
if (device->installed)
{
if (device->installed) {
fputs(prettySize.chars, stdout);
fputs(" - ", stdout);
ffStrbufWriteTo(&device->type, stdout);
if (device->maxSpeed > 0)
if (device->maxSpeed > 0) {
printf("-%u", device->maxSpeed);
if (device->runningSpeed > 0 && device->runningSpeed != device->maxSpeed)
}
if (device->runningSpeed > 0 && device->runningSpeed != device->maxSpeed) {
printf(" @ %u MT/s", device->runningSpeed);
if (device->vendor.length > 0)
}
if (device->vendor.length > 0) {
printf(" (%s)", device->vendor.chars);
if (device->ecc)
}
if (device->ecc) {
fputs(" - ECC", stdout);
}
else
{
}
} else {
fputs("Empty", stdout);
if (device->formFactor.length > 0)
if (device->formFactor.length > 0) {
printf(" - %s", device->formFactor.chars);
if (device->locator.length > 0)
}
if (device->locator.length > 0) {
printf(" (%s)", device->locator.chars);
}
}
putchar('\n');
}
else
{
} else {
FF_PRINT_FORMAT_CHECKED(FF_PHYSICALMEMORY_DISPLAY_NAME, (uint8_t) (i + 1), &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
FF_ARG(device->size, "bytes"),
FF_ARG(prettySize, "size"),
FF_ARG(device->maxSpeed, "max-speed"),
FF_ARG(device->runningSpeed, "running-speed"),
FF_ARG(device->type, "type"),
FF_ARG(device->formFactor, "form-factor"),
FF_ARG(device->locator, "locator"),
FF_ARG(device->vendor, "vendor"),
FF_ARG(device->serial, "serial"),
FF_ARG(device->partNumber, "part-number"),
FF_ARG(device->ecc, "is-ecc-enabled"),
FF_ARG(device->installed, "is-installed"),
}));
FF_ARG(device->size, "bytes"),
FF_ARG(prettySize, "size"),
FF_ARG(device->maxSpeed, "max-speed"),
FF_ARG(device->runningSpeed, "running-speed"),
FF_ARG(device->type, "type"),
FF_ARG(device->formFactor, "form-factor"),
FF_ARG(device->locator, "locator"),
FF_ARG(device->vendor, "vendor"),
FF_ARG(device->serial, "serial"),
FF_ARG(device->partNumber, "part-number"),
FF_ARG(device->ecc, "is-ecc-enabled"),
FF_ARG(device->installed, "is-installed"),
}));
}
}
FF_LIST_FOR_EACH(FFPhysicalMemoryResult, device, result)
{
FF_LIST_FOR_EACH (FFPhysicalMemoryResult, device, result) {
ffStrbufDestroy(&device->type);
ffStrbufDestroy(&device->locator);
ffStrbufDestroy(&device->formFactor);
@@ -107,17 +102,15 @@ bool ffPrintPhysicalMemory(FFPhysicalMemoryOptions* options)
return true;
}
void ffParsePhysicalMemoryJsonObject(FFPhysicalMemoryOptions* options, yyjson_val* module)
{
void ffParsePhysicalMemoryJsonObject(FFPhysicalMemoryOptions* 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 (unsafe_yyjson_equals_str(key, "showEmptySlots"))
{
if (unsafe_yyjson_equals_str(key, "showEmptySlots")) {
options->showEmptySlots = yyjson_get_bool(val);
continue;
}
@@ -126,26 +119,22 @@ void ffParsePhysicalMemoryJsonObject(FFPhysicalMemoryOptions* options, yyjson_va
}
}
void ffGeneratePhysicalMemoryJsonConfig(FFPhysicalMemoryOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
{
void ffGeneratePhysicalMemoryJsonConfig(FFPhysicalMemoryOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs);
yyjson_mut_obj_add_bool(doc, module, "showEmptySlots", options->showEmptySlots);
}
bool ffGeneratePhysicalMemoryJsonResult(FF_MAYBE_UNUSED FFPhysicalMemoryOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
{
bool ffGeneratePhysicalMemoryJsonResult(FF_MAYBE_UNUSED FFPhysicalMemoryOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFPhysicalMemoryResult));
const char* error = ffDetectPhysicalMemory(&result);
if(error)
{
if (error) {
yyjson_mut_obj_add_str(doc, module, "error", error);
return false;
}
yyjson_mut_val* arr = yyjson_mut_obj_add_arr(doc, module, "result");
FF_LIST_FOR_EACH(FFPhysicalMemoryResult, device, result)
{
FF_LIST_FOR_EACH (FFPhysicalMemoryResult, device, result) {
yyjson_mut_val* obj = yyjson_mut_arr_add_obj(doc, arr);
yyjson_mut_obj_add_uint(doc, obj, "size", device->size);
yyjson_mut_obj_add_bool(doc, obj, "installed", device->installed);
@@ -160,8 +149,7 @@ bool ffGeneratePhysicalMemoryJsonResult(FF_MAYBE_UNUSED FFPhysicalMemoryOptions*
yyjson_mut_obj_add_bool(doc, obj, "ecc", device->ecc);
}
FF_LIST_FOR_EACH(FFPhysicalMemoryResult, device, result)
{
FF_LIST_FOR_EACH (FFPhysicalMemoryResult, device, result) {
ffStrbufDestroy(&device->type);
ffStrbufDestroy(&device->locator);
ffStrbufDestroy(&device->formFactor);
@@ -173,14 +161,12 @@ bool ffGeneratePhysicalMemoryJsonResult(FF_MAYBE_UNUSED FFPhysicalMemoryOptions*
return true;
}
void ffInitPhysicalMemoryOptions(FFPhysicalMemoryOptions* options)
{
void ffInitPhysicalMemoryOptions(FFPhysicalMemoryOptions* options) {
ffOptionInitModuleArg(&options->moduleArgs, "󰑭");
options->showEmptySlots = false;
}
void ffDestroyPhysicalMemoryOptions(FFPhysicalMemoryOptions* options)
{
void ffDestroyPhysicalMemoryOptions(FFPhysicalMemoryOptions* options) {
ffOptionDestroyModuleArg(&options->moduleArgs);
}
@@ -206,5 +192,4 @@ FFModuleBaseInfo ffPhysicalMemoryModuleInfo = {
{"Part number", "part-number"},
{"True if ECC enabled", "is-ecc-enabled"},
{"True if a memory module is installed in the slot", "is-installed"},
}))
};
}))};