Global: pack all enums and make flag enums unsigned

This commit is contained in:
李通洲
2024-11-14 10:04:57 +08:00
parent e821a99873
commit 97e1b987dd
54 changed files with 100 additions and 73 deletions
+1 -1
View File
@@ -301,7 +301,7 @@ void ffInitBatteryOptions(FFBatteryOptions* options)
ffOptionInitModuleArg(&options->moduleArgs, "");
options->temp = false;
options->tempConfig = (FFColorRangeConfig) { 60, 80 };
options->percent = (FFColorRangeConfig) { 50, 20 };
options->percent = (FFPercentageModuleConfig) { 50, 20 };
#ifdef _WIN32
options->useSetupApi = false;
+1 -1
View File
@@ -12,7 +12,7 @@ typedef struct FFBatteryOptions
bool temp;
FFColorRangeConfig tempConfig;
FFColorRangeConfig percent;
FFPercentageModuleConfig percent;
#ifdef _WIN32
bool useSetupApi;
+1 -1
View File
@@ -202,7 +202,7 @@ void ffInitBluetoothOptions(FFBluetoothOptions* options)
);
ffOptionInitModuleArg(&options->moduleArgs, "");
options->showDisconnected = false;
options->percent = (FFColorRangeConfig) { 50, 20 };
options->percent = (FFPercentageModuleConfig) { 50, 20 };
}
void ffDestroyBluetoothOptions(FFBluetoothOptions* options)
+1 -1
View File
@@ -11,5 +11,5 @@ typedef struct FFBluetoothOptions
FFModuleArgs moduleArgs;
bool showDisconnected;
FFColorRangeConfig percent;
FFPercentageModuleConfig percent;
} FFBluetoothOptions;
+1 -1
View File
@@ -237,7 +237,7 @@ void ffInitBrightnessOptions(FFBrightnessOptions* options)
ffOptionInitModuleArg(&options->moduleArgs, "󰯪");
options->ddcciSleep = 10;
options->percent = (FFColorRangeConfig) { 100, 100 };
options->percent = (FFPercentageModuleConfig) { 100, 100 };
options->compact = false;
}
+1 -1
View File
@@ -11,6 +11,6 @@ typedef struct FFBrightnessOptions
FFModuleArgs moduleArgs;
uint32_t ddcciSleep; // ms
FFColorRangeConfig percent;
FFPercentageModuleConfig percent;
bool compact;
} FFBrightnessOptions;
+1 -1
View File
@@ -245,7 +245,7 @@ void ffInitBtrfsOptions(FFBtrfsOptions* options)
ffGenerateBtrfsJsonConfig
);
ffOptionInitModuleArg(&options->moduleArgs, "󱑛");
options->percent = (FFColorRangeConfig) { 50, 80 };
options->percent = (FFPercentageModuleConfig) { 50, 80 };
}
void ffDestroyBtrfsOptions(FFBtrfsOptions* options)
+1 -1
View File
@@ -10,5 +10,5 @@ typedef struct FFBtrfsOptions
FFModuleBaseInfo moduleInfo;
FFModuleArgs moduleArgs;
FFColorRangeConfig percent;
FFPercentageModuleConfig percent;
} FFBtrfsOptions;
+1 -1
View File
@@ -4,7 +4,7 @@
#include "common/option.h"
typedef enum FFColorsSymbol
typedef enum __attribute__((__packed__)) FFColorsSymbol
{
FF_COLORS_SYMBOL_BLOCK,
FF_COLORS_SYMBOL_BACKGROUND,
+1 -1
View File
@@ -214,7 +214,7 @@ void ffInitCPUUsageOptions(FFCPUUsageOptions* options)
);
ffOptionInitModuleArg(&options->moduleArgs, "󰓅");
options->separate = false;
options->percent = (FFColorRangeConfig) { 50, 80 };
options->percent = (FFPercentageModuleConfig) { 50, 80 };
options->waitTime = 200;
}
+1 -1
View File
@@ -11,6 +11,6 @@ typedef struct FFCPUUsageOptions
FFModuleArgs moduleArgs;
bool separate;
FFColorRangeConfig percent;
FFPercentageModuleConfig percent;
uint32_t waitTime; // in ms
} FFCPUUsageOptions;
+1 -1
View File
@@ -473,7 +473,7 @@ void ffInitDiskOptions(FFDiskOptions* options)
ffStrbufInit(&options->folders);
options->showTypes = FF_DISK_VOLUME_TYPE_REGULAR_BIT | FF_DISK_VOLUME_TYPE_EXTERNAL_BIT | FF_DISK_VOLUME_TYPE_READONLY_BIT;
options->calcType = FF_DISK_CALC_TYPE_FREE;
options->percent = (FFColorRangeConfig) { 50, 80 };
options->percent = (FFPercentageModuleConfig) { 50, 80 };
}
void ffDestroyDiskOptions(FFDiskOptions* options)
+4 -3
View File
@@ -5,7 +5,7 @@
#include "common/option.h"
#include "common/percent.h"
typedef enum FFDiskVolumeType
typedef enum __attribute__((__packed__)) FFDiskVolumeType
{
FF_DISK_VOLUME_TYPE_NONE = 0,
FF_DISK_VOLUME_TYPE_REGULAR_BIT = 1 << 0,
@@ -14,9 +14,10 @@ typedef enum FFDiskVolumeType
FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT = 1 << 3,
FF_DISK_VOLUME_TYPE_UNKNOWN_BIT = 1 << 4,
FF_DISK_VOLUME_TYPE_READONLY_BIT = 1 << 5,
FF_DISK_VOLUME_TYPE_FORCE_UNSIGNED = UINT8_MAX,
} FFDiskVolumeType;
typedef enum FFDiskCalcType
typedef enum __attribute__((__packed__)) FFDiskCalcType
{
FF_DISK_CALC_TYPE_FREE,
FF_DISK_CALC_TYPE_AVAILABLE,
@@ -30,5 +31,5 @@ typedef struct FFDiskOptions
FFstrbuf folders;
FFDiskVolumeType showTypes;
FFDiskCalcType calcType;
FFColorRangeConfig percent;
FFPercentageModuleConfig percent;
} FFDiskOptions;
+3 -2
View File
@@ -4,15 +4,16 @@
#include "common/option.h"
typedef enum FFDisplayCompactType
typedef enum __attribute__((__packed__)) FFDisplayCompactType
{
FF_DISPLAY_COMPACT_TYPE_NONE = 0,
FF_DISPLAY_COMPACT_TYPE_ORIGINAL_BIT = 1 << 0,
FF_DISPLAY_COMPACT_TYPE_SCALED_BIT = 1 << 1,
FF_DISPLAY_COMPACT_TYPE_REFRESH_RATE_BIT = 1 << 2,
FF_DISPLAY_COMPACT_TYPE_UNSIGNED = UINT8_MAX,
} FFDisplayCompactType;
typedef enum FFDisplayOrder
typedef enum __attribute__((__packed__)) FFDisplayOrder
{
FF_DISPLAY_ORDER_NONE,
FF_DISPLAY_ORDER_ASC,
+3
View File
@@ -122,6 +122,8 @@ void ffGenerateDNSJsonConfig(FFDNSOptions* options, yyjson_mut_doc* doc, yyjson_
if (defaultOptions.showType != options->showType)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch" // FF_DNS_TYPE_FORCE_UNSIGNED
switch (options->showType)
{
case FF_DNS_TYPE_IPV4_BIT:
@@ -134,6 +136,7 @@ void ffGenerateDNSJsonConfig(FFDNSOptions* options, yyjson_mut_doc* doc, yyjson_
yyjson_mut_obj_add_str(doc, module, "showType", "both");
break;
}
#pragma GCC diagnostic pop
}
}
+2 -1
View File
@@ -4,10 +4,11 @@
#include "common/option.h"
typedef enum FFDNSShowType {
typedef enum __attribute__((__packed__)) FFDNSShowType {
FF_DNS_TYPE_IPV4_BIT = 1,
FF_DNS_TYPE_IPV6_BIT = 2,
FF_DNS_TYPE_BOTH = FF_DNS_TYPE_IPV4_BIT | FF_DNS_TYPE_IPV6_BIT,
FF_DNS_TYPE_FORCE_UNSIGNED = UINT8_MAX,
} FFDNSShowType;
typedef struct FFDNSOptions
+1 -1
View File
@@ -160,7 +160,7 @@ void ffInitGamepadOptions(FFGamepadOptions* options)
ffGenerateGamepadJsonConfig
);
ffOptionInitModuleArg(&options->moduleArgs, "󰺵");
options->percent = (FFColorRangeConfig) { 50, 20 };
options->percent = (FFPercentageModuleConfig) { 50, 20 };
}
void ffDestroyGamepadOptions(FFGamepadOptions* options)
+1 -1
View File
@@ -9,5 +9,5 @@ typedef struct FFGamepadOptions
FFModuleBaseInfo moduleInfo;
FFModuleArgs moduleArgs;
FFColorRangeConfig percent;
FFPercentageModuleConfig percent;
} FFGamepadOptions;
+1 -1
View File
@@ -439,7 +439,7 @@ void ffInitGPUOptions(FFGPUOptions* options)
options->temp = false;
options->hideType = FF_GPU_TYPE_UNKNOWN;
options->tempConfig = (FFColorRangeConfig) { 60, 80 };
options->percent = (FFColorRangeConfig) { 50, 80 };
options->percent = (FFPercentageModuleConfig) { 50, 80 };
}
void ffDestroyGPUOptions(FFGPUOptions* options)
+3 -3
View File
@@ -5,14 +5,14 @@
#include "common/option.h"
#include "common/percent.h"
typedef enum FFGPUType
typedef enum __attribute__((__packed__)) FFGPUType
{
FF_GPU_TYPE_UNKNOWN,
FF_GPU_TYPE_INTEGRATED,
FF_GPU_TYPE_DISCRETE,
} FFGPUType;
typedef enum FFGPUDetectionMethod
typedef enum __attribute__((__packed__)) FFGPUDetectionMethod
{
FF_GPU_DETECTION_METHOD_AUTO,
FF_GPU_DETECTION_METHOD_PCI,
@@ -32,5 +32,5 @@ typedef struct FFGPUOptions
bool driverSpecific;
bool forceMethod;
FFColorRangeConfig tempConfig;
FFColorRangeConfig percent;
FFPercentageModuleConfig percent;
} FFGPUOptions;
+1 -1
View File
@@ -204,7 +204,7 @@ void ffInitLoadavgOptions(FFLoadavgOptions* options)
);
ffOptionInitModuleArg(&options->moduleArgs, "");
options->percent = (FFColorRangeConfig) { 50, 80 };
options->percent = (FFPercentageModuleConfig) { 50, 80 };
options->ndigits = 2;
options->compact = true;
}
+1 -1
View File
@@ -9,7 +9,7 @@ typedef struct FFLoadavgOptions
FFModuleBaseInfo moduleInfo;
FFModuleArgs moduleArgs;
FFColorRangeConfig percent;
FFPercentageModuleConfig percent;
uint8_t ndigits;
bool compact;
} FFLoadavgOptions;
+3 -1
View File
@@ -4,7 +4,7 @@
#include "common/option.h"
typedef enum FFLocalIpType
typedef enum __attribute__((__packed__)) FFLocalIpType
{
FF_LOCALIP_TYPE_NONE,
FF_LOCALIP_TYPE_LOOP_BIT = 1 << 0,
@@ -19,7 +19,9 @@ typedef enum FFLocalIpType
FF_LOCALIP_TYPE_COMPACT_BIT = 1 << 10,
FF_LOCALIP_TYPE_DEFAULT_ROUTE_ONLY_BIT = 1 << 11,
FF_LOCALIP_TYPE_ALL_IPS_BIT = 1 << 12,
FF_LOCALIP_TYPE_FORCE_UNSIGNED = UINT16_MAX,
} FFLocalIpType;
static_assert(sizeof(FFLocalIpType) == sizeof(uint16_t), "");
typedef struct FFLocalIpOptions
{
+1 -1
View File
@@ -152,7 +152,7 @@ void ffInitMemoryOptions(FFMemoryOptions* options)
ffGenerateMemoryJsonConfig
);
ffOptionInitModuleArg(&options->moduleArgs, "");
options->percent = (FFColorRangeConfig) { 50, 80 };
options->percent = (FFPercentageModuleConfig) { 50, 80 };
}
void ffDestroyMemoryOptions(FFMemoryOptions* options)
+1 -1
View File
@@ -10,5 +10,5 @@ typedef struct FFMemoryOptions
FFModuleBaseInfo moduleInfo;
FFModuleArgs moduleArgs;
FFColorRangeConfig percent;
FFPercentageModuleConfig percent;
} FFMemoryOptions;
+1 -1
View File
@@ -4,7 +4,7 @@
#include "common/option.h"
typedef enum FFOpenGLLibrary
typedef enum __attribute__((__packed__)) FFOpenGLLibrary
{
FF_OPENGL_LIBRARY_AUTO,
FF_OPENGL_LIBRARY_EGL,
+3 -1
View File
@@ -4,7 +4,7 @@
#include "common/option.h"
typedef enum FFPackagesFlags
typedef enum __attribute__((__packed__)) FFPackagesFlags
{
FF_PACKAGES_FLAG_NONE = 0,
FF_PACKAGES_FLAG_APK_BIT = 1 << 0,
@@ -35,7 +35,9 @@ typedef enum FFPackagesFlags
FF_PACKAGES_FLAG_PACSTALL_BIT = 1 << 25,
FF_PACKAGES_FLAG_MPORT_BIT = 1 << 26,
FF_PACKAGES_FLAG_QI_BIT = 1 << 27,
FF_PACKAGES_FLAG_FORCE_UNSIGNED = UINT32_MAX,
} FFPackagesFlags;
static_assert(sizeof(FFPackagesFlags) == sizeof(uint32_t), "");
typedef struct FFPackagesOptions
{
+2 -2
View File
@@ -5,7 +5,7 @@
#include "common/option.h"
#include "common/percent.h"
typedef enum FFSoundType
typedef enum __attribute__((__packed__)) FFSoundType
{
FF_SOUND_TYPE_MAIN,
FF_SOUND_TYPE_ACTIVE,
@@ -18,5 +18,5 @@ typedef struct FFSoundOptions
FFModuleArgs moduleArgs;
FFSoundType soundType;
FFColorRangeConfig percent;
FFPercentageModuleConfig percent;
} FFSoundOptions;
+1 -1
View File
@@ -253,7 +253,7 @@ void ffInitSoundOptions(FFSoundOptions* options)
ffOptionInitModuleArg(&options->moduleArgs, "");
options->soundType = FF_SOUND_TYPE_MAIN;
options->percent = (FFColorRangeConfig) { 80, 90 };
options->percent = (FFPercentageModuleConfig) { 80, 90 };
}
void ffDestroySoundOptions(FFSoundOptions* options)
+1 -1
View File
@@ -10,5 +10,5 @@ typedef struct FFSwapOptions
FFModuleBaseInfo moduleInfo;
FFModuleArgs moduleArgs;
FFColorRangeConfig percent;
FFPercentageModuleConfig percent;
} FFSwapOptions;
+1 -1
View File
@@ -161,7 +161,7 @@ void ffInitSwapOptions(FFSwapOptions* options)
ffGenerateSwapJsonConfig
);
ffOptionInitModuleArg(&options->moduleArgs, "󰓡");
options->percent = (FFColorRangeConfig) { 50, 80 };
options->percent = (FFPercentageModuleConfig) { 50, 80 };
}
void ffDestroySwapOptions(FFSwapOptions* options)
+1 -1
View File
@@ -9,5 +9,5 @@ typedef struct FFWifiOptions
FFModuleBaseInfo moduleInfo;
FFModuleArgs moduleArgs;
FFColorRangeConfig percent;
FFPercentageModuleConfig percent;
} FFWifiOptions;
+1 -1
View File
@@ -222,7 +222,7 @@ void ffInitWifiOptions(FFWifiOptions* options)
);
ffOptionInitModuleArg(&options->moduleArgs, "");
options->percent = (FFColorRangeConfig) { 50, 20 };
options->percent = (FFPercentageModuleConfig) { 50, 20 };
}
void ffDestroyWifiOptions(FFWifiOptions* options)
+1 -1
View File
@@ -10,5 +10,5 @@ typedef struct FFZpoolOptions
FFModuleBaseInfo moduleInfo;
FFModuleArgs moduleArgs;
FFColorRangeConfig percent;
FFPercentageModuleConfig percent;
} FFZpoolOptions;
+1 -1
View File
@@ -205,7 +205,7 @@ void ffInitZpoolOptions(FFZpoolOptions* options)
ffGenerateZpoolJsonConfig
);
ffOptionInitModuleArg(&options->moduleArgs, "󱑛");
options->percent = (FFColorRangeConfig) { 50, 80 };
options->percent = (FFPercentageModuleConfig) { 50, 80 };
}
void ffDestroyZpoolOptions(FFZpoolOptions* options)