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
+73 -78
View File
@@ -7,102 +7,100 @@
#define FF_CPUCACHE_DISPLAY_NAME "CPU Cache"
static void printCPUCacheNormal(const FFCPUCacheResult* result, FFCPUCacheOptions* options)
{
static void printCPUCacheNormal(const FFCPUCacheResult* result, FFCPUCacheOptions* options) {
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
char levelStr[4] = "L";
for (uint32_t i = 0; i < ARRAY_SIZE(result->caches) && result->caches[i].length > 0; i++)
{
for (uint32_t i = 0; i < ARRAY_SIZE(result->caches) && result->caches[i].length > 0; i++) {
ffStrbufClear(&key);
levelStr[1] = (char) ('1' + i);
if (options->moduleArgs.key.length == 0)
if (options->moduleArgs.key.length == 0) {
ffStrbufAppendF(&key, "%s (%s)", FF_CPUCACHE_DISPLAY_NAME, levelStr);
else
{
} else {
uint32_t index = i + 1;
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) {
FF_ARG(index, "index"),
FF_ARG(levelStr, "level"),
FF_ARG(options->moduleArgs.keyIcon, "icon"),
}));
FF_ARG(index, "index"),
FF_ARG(levelStr, "level"),
FF_ARG(options->moduleArgs.keyIcon, "icon"),
}));
}
ffStrbufClear(&buffer);
uint32_t sum = 0;
FF_LIST_FOR_EACH(FFCPUCache, src, result->caches[i])
{
FF_LIST_FOR_EACH (FFCPUCache, src, result->caches[i]) {
char typeStr = '?';
switch (src->type)
{
case FF_CPU_CACHE_TYPE_DATA: typeStr = 'D'; break;
case FF_CPU_CACHE_TYPE_INSTRUCTION: typeStr = 'I'; break;
case FF_CPU_CACHE_TYPE_UNIFIED: typeStr = 'U'; break;
case FF_CPU_CACHE_TYPE_TRACE: typeStr = 'T'; break;
switch (src->type) {
case FF_CPU_CACHE_TYPE_DATA:
typeStr = 'D';
break;
case FF_CPU_CACHE_TYPE_INSTRUCTION:
typeStr = 'I';
break;
case FF_CPU_CACHE_TYPE_UNIFIED:
typeStr = 'U';
break;
case FF_CPU_CACHE_TYPE_TRACE:
typeStr = 'T';
break;
}
if (buffer.length)
if (buffer.length) {
ffStrbufAppendS(&buffer, ", ");
if (src->num > 1)
}
if (src->num > 1) {
ffStrbufAppendF(&buffer, "%ux", src->num);
}
ffSizeAppendNum(src->size, &buffer);
ffStrbufAppendF(&buffer, " (%c)", typeStr);
sum += src->size * src->num;
}
if(options->moduleArgs.outputFormat.length == 0)
{
if (options->moduleArgs.outputFormat.length == 0) {
ffPrintLogoAndKey(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY);
ffStrbufPutTo(&buffer, stdout);
}
else
{
} else {
FF_STRBUF_AUTO_DESTROY buffer2 = ffStrbufCreate();
ffSizeAppendNum(sum, &buffer2);
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
FF_ARG(buffer, "result"),
FF_ARG(buffer2, "sum"),
}));
FF_ARG(buffer, "result"),
FF_ARG(buffer2, "sum"),
}));
}
}
}
static void printCPUCacheCompact(const FFCPUCacheResult* result, FFCPUCacheOptions* options)
{
static void printCPUCacheCompact(const FFCPUCacheResult* result, FFCPUCacheOptions* options) {
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
uint64_t sum = 0;
for (uint32_t i = 0; i < ARRAY_SIZE(result->caches) && result->caches[i].length > 0; i++)
{
if (buffer.length)
for (uint32_t i = 0; i < ARRAY_SIZE(result->caches) && result->caches[i].length > 0; i++) {
if (buffer.length) {
ffStrbufAppendS(&buffer, ", ");
}
uint32_t value = 0;
FF_LIST_FOR_EACH(FFCPUCache, src, result->caches[i])
FF_LIST_FOR_EACH (FFCPUCache, src, result->caches[i]) {
value += src->size * src->num;
}
ffSizeAppendNum(value, &buffer);
ffStrbufAppendF(&buffer, " (L%u)", i + 1);
sum += value;
}
if (options->moduleArgs.outputFormat.length == 0)
{
if (options->moduleArgs.outputFormat.length == 0) {
ffPrintLogoAndKey(FF_CPUCACHE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
ffStrbufPutTo(&buffer, stdout);
}
else
{
} else {
FF_STRBUF_AUTO_DESTROY buffer2 = ffStrbufCreate();
ffSizeAppendNum(sum, &buffer2);
FF_PRINT_FORMAT_CHECKED(FF_CPUCACHE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
FF_ARG(buffer, "result"),
FF_ARG(buffer2, "sum"),
}));
FF_ARG(buffer, "result"),
FF_ARG(buffer2, "sum"),
}));
}
}
bool ffPrintCPUCache(FFCPUCacheOptions* options)
{
bool ffPrintCPUCache(FFCPUCacheOptions* options) {
bool success = false;
FFCPUCacheResult result = {
.caches = {
@@ -115,16 +113,16 @@ bool ffPrintCPUCache(FFCPUCacheOptions* options)
const char* error = ffDetectCPUCache(&result);
if(error)
{
if (error) {
ffPrintError(FF_CPUCACHE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
goto exit;
}
if (!options->compact)
if (!options->compact) {
printCPUCacheNormal(&result, options);
else
} else {
printCPUCacheCompact(&result, options);
}
success = true;
exit:
@@ -136,17 +134,15 @@ exit:
return success;
}
void ffParseCPUCacheJsonObject(FFCPUCacheOptions* options, yyjson_val* module)
{
void ffParseCPUCacheJsonObject(FFCPUCacheOptions* 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, "compact"))
{
if (unsafe_yyjson_equals_str(key, "compact")) {
options->compact = yyjson_get_bool(val);
continue;
}
@@ -155,15 +151,13 @@ void ffParseCPUCacheJsonObject(FFCPUCacheOptions* options, yyjson_val* module)
}
}
void ffGenerateCPUCacheJsonConfig(FFCPUCacheOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
{
void ffGenerateCPUCacheJsonConfig(FFCPUCacheOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs);
yyjson_mut_obj_add_bool(doc, module, "compact", options->compact);
}
bool ffGenerateCPUCacheJsonResult(FF_MAYBE_UNUSED FFCPUCacheOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
{
bool ffGenerateCPUCacheJsonResult(FF_MAYBE_UNUSED FFCPUCacheOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
bool success = false;
FFCPUCacheResult result = {
.caches = {
@@ -176,29 +170,33 @@ bool ffGenerateCPUCacheJsonResult(FF_MAYBE_UNUSED FFCPUCacheOptions* options, yy
const char* error = ffDetectCPUCache(&result);
if (error)
{
if (error) {
yyjson_mut_obj_add_str(doc, module, "error", error);
goto exit;
}
yyjson_mut_val* caches = yyjson_mut_obj_add_obj(doc, module, "result");
for (uint32_t i = 0; i < ARRAY_SIZE(result.caches) && result.caches[i].length > 0; i++)
{
for (uint32_t i = 0; i < ARRAY_SIZE(result.caches) && result.caches[i].length > 0; i++) {
yyjson_mut_val* level = yyjson_mut_obj_add_arr(doc, caches, &"l1\0l2\0l3\0l4\0"[i * 3]);
FF_LIST_FOR_EACH(FFCPUCache, src, result.caches[i])
{
FF_LIST_FOR_EACH (FFCPUCache, src, result.caches[i]) {
yyjson_mut_val* item = yyjson_mut_arr_add_obj(doc, level);
yyjson_mut_obj_add_uint(doc, item, "size", src->size);
yyjson_mut_obj_add_uint(doc, item, "num", src->num);
const char* typeStr = "unknown";
switch (src->type)
{
case FF_CPU_CACHE_TYPE_DATA: typeStr = "data"; break;
case FF_CPU_CACHE_TYPE_INSTRUCTION: typeStr = "instruction"; break;
case FF_CPU_CACHE_TYPE_UNIFIED: typeStr = "unified"; break;
case FF_CPU_CACHE_TYPE_TRACE: typeStr = "trace"; break;
switch (src->type) {
case FF_CPU_CACHE_TYPE_DATA:
typeStr = "data";
break;
case FF_CPU_CACHE_TYPE_INSTRUCTION:
typeStr = "instruction";
break;
case FF_CPU_CACHE_TYPE_UNIFIED:
typeStr = "unified";
break;
case FF_CPU_CACHE_TYPE_TRACE:
typeStr = "trace";
break;
}
yyjson_mut_obj_add_uint(doc, item, "lineSize", src->lineSize);
yyjson_mut_obj_add_str(doc, item, "type", typeStr);
@@ -214,15 +212,13 @@ exit:
return success;
}
void ffInitCPUCacheOptions(FFCPUCacheOptions* options)
{
void ffInitCPUCacheOptions(FFCPUCacheOptions* options) {
ffOptionInitModuleArg(&options->moduleArgs, "");
options->compact = false;
}
void ffDestroyCPUCacheOptions(FFCPUCacheOptions* options)
{
void ffDestroyCPUCacheOptions(FFCPUCacheOptions* options) {
ffOptionDestroyModuleArg(&options->moduleArgs);
}
@@ -238,5 +234,4 @@ FFModuleBaseInfo ffCPUCacheModuleInfo = {
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
{"Separate result", "result"},
{"Sum result", "sum"},
}))
};
}))};
+1 -2
View File
@@ -2,8 +2,7 @@
#include "common/option.h"
typedef struct FFCPUCacheOptions
{
typedef struct FFCPUCacheOptions {
FFModuleArgs moduleArgs;
bool compact;