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 FFPowerAdapterOptions
{
typedef struct FFPowerAdapterOptions {
FFModuleArgs moduleArgs;
} FFPowerAdapterOptions;
+29 -44
View File
@@ -6,47 +6,41 @@
#define FF_POWERADAPTER_DISPLAY_NAME "Power Adapter"
bool ffPrintPowerAdapter(FFPowerAdapterOptions* options)
{
bool ffPrintPowerAdapter(FFPowerAdapterOptions* options) {
FF_LIST_AUTO_DESTROY results = ffListCreate(sizeof(FFPowerAdapterResult));
const char* error = ffDetectPowerAdapter(&results);
if (error)
{
if (error) {
ffPrintError(FF_POWERADAPTER_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
return false;
}
if(results.length == 0)
{
if (results.length == 0) {
ffPrintError(FF_POWERADAPTER_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No power adapters found");
return false;
}
for(uint8_t i = 0; i < (uint8_t) results.length; i++)
{
for (uint8_t i = 0; i < (uint8_t) results.length; i++) {
FFPowerAdapterResult* result = FF_LIST_GET(FFPowerAdapterResult, results, i);
if(options->moduleArgs.outputFormat.length == 0)
{
if (options->moduleArgs.outputFormat.length == 0) {
ffPrintLogoAndKey(FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
if(result->name.length > 0)
if (result->name.length > 0) {
puts(result->name.chars);
else
} else {
printf("%dW\n", result->watts);
}
else
{
FF_PRINT_FORMAT_CHECKED(FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
FF_ARG(result->watts, "watts"),
FF_ARG(result->name, "name"),
FF_ARG(result->manufacturer, "manufacturer"),
FF_ARG(result->modelName, "model-name"),
FF_ARG(result->description, "description"),
FF_ARG(result->serial, "serial"),
}));
}
} else {
FF_PRINT_FORMAT_CHECKED(FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
FF_ARG(result->watts, "watts"),
FF_ARG(result->name, "name"),
FF_ARG(result->manufacturer, "manufacturer"),
FF_ARG(result->modelName, "model-name"),
FF_ARG(result->description, "description"),
FF_ARG(result->serial, "serial"),
}));
}
ffStrbufDestroy(&result->manufacturer);
@@ -59,39 +53,34 @@ bool ffPrintPowerAdapter(FFPowerAdapterOptions* options)
return true;
}
void ffGeneratePowerAdapterJsonConfig(FFPowerAdapterOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
{
void ffGeneratePowerAdapterJsonConfig(FFPowerAdapterOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs);
}
void ffParsePowerAdapterJsonObject(FFPowerAdapterOptions* options, yyjson_val* module)
{
void ffParsePowerAdapterJsonObject(FFPowerAdapterOptions* 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;
}
ffPrintError(FF_POWERADAPTER_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", unsafe_yyjson_get_str(key));
}
}
bool ffGeneratePowerAdapterJsonResult(FF_MAYBE_UNUSED FFPowerAdapterOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
{
bool ffGeneratePowerAdapterJsonResult(FF_MAYBE_UNUSED FFPowerAdapterOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
FF_LIST_AUTO_DESTROY results = ffListCreate(sizeof(FFPowerAdapterResult));
const char* error = ffDetectPowerAdapter(&results);
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(FFPowerAdapterResult, item, results)
{
FF_LIST_FOR_EACH (FFPowerAdapterResult, item, results) {
yyjson_mut_val* obj = yyjson_mut_arr_add_obj(doc, arr);
yyjson_mut_obj_add_strbuf(doc, obj, "description", &item->description);
yyjson_mut_obj_add_strbuf(doc, obj, "manufacturer", &item->manufacturer);
@@ -101,8 +90,7 @@ bool ffGeneratePowerAdapterJsonResult(FF_MAYBE_UNUSED FFPowerAdapterOptions* opt
yyjson_mut_obj_add_int(doc, obj, "watts", item->watts);
}
FF_LIST_FOR_EACH(FFPowerAdapterResult, item, results)
{
FF_LIST_FOR_EACH (FFPowerAdapterResult, item, results) {
ffStrbufDestroy(&item->manufacturer);
ffStrbufDestroy(&item->description);
ffStrbufDestroy(&item->modelName);
@@ -113,13 +101,11 @@ bool ffGeneratePowerAdapterJsonResult(FF_MAYBE_UNUSED FFPowerAdapterOptions* opt
return true;
}
void ffInitPowerAdapterOptions(FFPowerAdapterOptions* options)
{
void ffInitPowerAdapterOptions(FFPowerAdapterOptions* options) {
ffOptionInitModuleArg(&options->moduleArgs, "󰚥");
}
void ffDestroyPowerAdapterOptions(FFPowerAdapterOptions* options)
{
void ffDestroyPowerAdapterOptions(FFPowerAdapterOptions* options) {
ffOptionDestroyModuleArg(&options->moduleArgs);
}
@@ -139,5 +125,4 @@ FFModuleBaseInfo ffPowerAdapterModuleInfo = {
{"Power adapter model", "model"},
{"Power adapter description", "description"},
{"Power adapter serial number", "serial"},
}))
};
}))};