mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 00:03:58 +01:00
Chore: introduce macro ARRAY_SIZE
This commit is contained in:
@@ -39,7 +39,7 @@ void ffPrintCPU(FFCPUOptions* options)
|
||||
if (options->showPeCoreCount)
|
||||
{
|
||||
uint32_t typeCount = 0;
|
||||
while (cpu.coreTypes[typeCount].count != 0 && typeCount < sizeof(cpu.coreTypes) / sizeof(cpu.coreTypes[0])) typeCount++;
|
||||
while (cpu.coreTypes[typeCount].count != 0 && typeCount < ARRAY_SIZE(cpu.coreTypes)) typeCount++;
|
||||
if (typeCount > 0)
|
||||
{
|
||||
qsort(cpu.coreTypes, typeCount, sizeof(cpu.coreTypes[0]), (void*) sortCores);
|
||||
|
||||
@@ -107,7 +107,7 @@ void ffPrintDateTime(FFDateTimeOptions* options)
|
||||
}
|
||||
|
||||
char buffer[32];
|
||||
if (strftime(buffer, sizeof(buffer), "%F %T", tm) == 0) //yyyy-MM-dd HH:mm:ss
|
||||
if (strftime(buffer, ARRAY_SIZE(buffer), "%F %T", tm) == 0) //yyyy-MM-dd HH:mm:ss
|
||||
{
|
||||
ffPrintError(FF_DATETIME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "strftime() failed");
|
||||
return;
|
||||
|
||||
@@ -146,9 +146,9 @@ void ffPrintDisplay(FFDisplayOptions* options)
|
||||
if(result->refreshRate > 0)
|
||||
{
|
||||
if(options->preciseRefreshRate)
|
||||
snprintf(refreshRate, sizeof(refreshRate), "%g", ((int) (result->refreshRate * 1000 + 0.5)) / 1000.0);
|
||||
snprintf(refreshRate, ARRAY_SIZE(refreshRate), "%g", ((int) (result->refreshRate * 1000 + 0.5)) / 1000.0);
|
||||
else
|
||||
snprintf(refreshRate, sizeof(refreshRate), "%i", (uint32_t) (result->refreshRate + 0.5));
|
||||
snprintf(refreshRate, ARRAY_SIZE(refreshRate), "%i", (uint32_t) (result->refreshRate + 0.5));
|
||||
}
|
||||
else
|
||||
refreshRate[0] = 0;
|
||||
@@ -157,7 +157,7 @@ void ffPrintDisplay(FFDisplayOptions* options)
|
||||
if (result->serial)
|
||||
{
|
||||
const uint8_t* nums = (uint8_t*) &result->serial;
|
||||
snprintf(buf, sizeof(buf), "%2X-%2X-%2X-%2X", nums[0], nums[1], nums[2], nums[3]);
|
||||
snprintf(buf, ARRAY_SIZE(buf), "%2X-%2X-%2X-%2X", nums[0], nums[1], nums[2], nums[3]);
|
||||
}
|
||||
else
|
||||
buf[0] = '\0';
|
||||
|
||||
@@ -63,7 +63,7 @@ void ffPrintMedia(FFMediaOptions* options)
|
||||
"[Lyric Video]", "[Official Lyric Video]", "[Lyrics]",
|
||||
"| Lyric Video", "| Official Lyric Video", "| Lyrics",
|
||||
};
|
||||
ffStrbufRemoveStrings(&songPretty, sizeof(removeStrings) / sizeof(removeStrings[0]), removeStrings);
|
||||
ffStrbufRemoveStrings(&songPretty, ARRAY_SIZE(removeStrings), removeStrings);
|
||||
ffStrbufTrimRight(&songPretty, ' ');
|
||||
|
||||
if(songPretty.length == 0)
|
||||
|
||||
@@ -32,8 +32,8 @@ void ffPrintTerminalTheme(FFTerminalThemeOptions* options)
|
||||
char fg[32], bg[32];
|
||||
const char* fgType = result.fg.dark ? "Dark" : "Light";
|
||||
const char* bgType = result.bg.dark ? "Dark" : "Light";
|
||||
snprintf(fg, sizeof(fg), "#%02" PRIX16 "%02" PRIX16 "%02" PRIX16, result.fg.r, result.fg.g, result.fg.b);
|
||||
snprintf(bg, sizeof(bg), "#%02" PRIX16 "%02" PRIX16 "%02" PRIX16, result.bg.r, result.bg.g, result.bg.b);
|
||||
snprintf(fg, ARRAY_SIZE(fg), "#%02" PRIX16 "%02" PRIX16 "%02" PRIX16, result.fg.r, result.fg.g, result.fg.b);
|
||||
snprintf(bg, ARRAY_SIZE(bg), "#%02" PRIX16 "%02" PRIX16 "%02" PRIX16, result.bg.r, result.bg.g, result.bg.b);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TERMINALTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_TERMINALTHEME_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(fg, "fg-color"),
|
||||
FF_FORMAT_ARG(fgType, "fg-type"),
|
||||
|
||||
Reference in New Issue
Block a user