mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 00:03:58 +01:00
Global: fixes -ffast-math compatibility
Unifies unset double handling using `-DBL_MAX` sentinel Fixes #1894
This commit is contained in:
@@ -72,7 +72,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
|
||||
ffStrbufAppend(&str, &result->status);
|
||||
}
|
||||
|
||||
if(result->temperature == result->temperature) //FF_BATTERY_TEMP_UNSET
|
||||
if(result->temperature != FF_BATTERY_TEMP_UNSET)
|
||||
{
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendS(&str, " - ");
|
||||
@@ -221,7 +221,10 @@ void ffGenerateBatteryJsonResult(FFBatteryOptions* options, yyjson_mut_doc* doc,
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "status", &battery->status);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "technology", &battery->technology);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "serial", &battery->serial);
|
||||
yyjson_mut_obj_add_real(doc, obj, "temperature", battery->temperature);
|
||||
if (battery->temperature != FF_BATTERY_TEMP_UNSET)
|
||||
yyjson_mut_obj_add_real(doc, obj, "temperature", battery->temperature);
|
||||
else
|
||||
yyjson_mut_obj_add_null(doc, obj, "temperature");
|
||||
yyjson_mut_obj_add_uint(doc, obj, "cycleCount", battery->cycleCount);
|
||||
if (battery->timeRemaining > 0)
|
||||
yyjson_mut_obj_add_int(doc, obj, "timeRemaining", battery->timeRemaining);
|
||||
|
||||
@@ -81,7 +81,7 @@ void ffPrintCPU(FFCPUOptions* options)
|
||||
ffFreqAppendNum(freq, &str);
|
||||
}
|
||||
|
||||
if(cpu.temperature == cpu.temperature) //FF_CPU_TEMP_UNSET
|
||||
if(cpu.temperature != FF_CPU_TEMP_UNSET)
|
||||
{
|
||||
ffStrbufAppendS(&str, " - ");
|
||||
ffTempsAppendNum(cpu.temperature, &str, options->tempConfig, &options->moduleArgs);
|
||||
@@ -201,7 +201,10 @@ void ffGenerateCPUJsonResult(FFCPUOptions* options, yyjson_mut_doc* doc, yyjson_
|
||||
yyjson_mut_obj_add_uint(doc, core, "freq", cpu.coreTypes[i].freq);
|
||||
}
|
||||
|
||||
yyjson_mut_obj_add_real(doc, obj, "temperature", cpu.temperature);
|
||||
if (cpu.temperature != FF_CPU_TEMP_UNSET)
|
||||
yyjson_mut_obj_add_real(doc, obj, "temperature", cpu.temperature);
|
||||
else
|
||||
yyjson_mut_obj_add_null(doc, obj, "temperature");
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&cpu.name);
|
||||
|
||||
+11
-5
@@ -46,7 +46,7 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
|
||||
ffFreqAppendNum(gpu->frequency, &output);
|
||||
}
|
||||
|
||||
if(gpu->temperature == gpu->temperature) //FF_GPU_TEMP_UNSET
|
||||
if(gpu->temperature != FF_GPU_TEMP_UNSET)
|
||||
{
|
||||
ffStrbufAppendS(&output, " - ");
|
||||
ffTempsAppendNum(gpu->temperature, &output, options->tempConfig, &options->moduleArgs);
|
||||
@@ -126,7 +126,7 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY coreUsageNum = ffStrbufCreate();
|
||||
FF_STRBUF_AUTO_DESTROY coreUsageBar = ffStrbufCreate();
|
||||
if (gpu->coreUsage == gpu->coreUsage) //FF_GPU_CORE_USAGE_UNSET
|
||||
if (gpu->coreUsage != FF_GPU_CORE_USAGE_UNSET)
|
||||
{
|
||||
if (percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
ffPercentAppendNum(&coreUsageNum, gpu->coreUsage, options->percent, false, &options->moduleArgs);
|
||||
@@ -338,7 +338,10 @@ void ffGenerateGPUJsonResult(FFGPUOptions* options, yyjson_mut_doc* doc, yyjson_
|
||||
else
|
||||
yyjson_mut_obj_add_null(doc, obj, "coreCount");
|
||||
|
||||
yyjson_mut_obj_add_real(doc, obj, "coreUsage", gpu->coreUsage);
|
||||
if (gpu->coreUsage != FF_GPU_CORE_USAGE_UNSET)
|
||||
yyjson_mut_obj_add_real(doc, obj, "coreUsage", gpu->coreUsage);
|
||||
else
|
||||
yyjson_mut_obj_add_null(doc, obj, "coreUsage");
|
||||
|
||||
yyjson_mut_val* memoryObj = yyjson_mut_obj_add_obj(doc, obj, "memory");
|
||||
|
||||
@@ -371,7 +374,7 @@ void ffGenerateGPUJsonResult(FFGPUOptions* options, yyjson_mut_doc* doc, yyjson_
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "driver", &gpu->driver);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "name", &gpu->name);
|
||||
|
||||
if(gpu->temperature == gpu->temperature) //FF_GPU_TEMP_UNSET
|
||||
if(gpu->temperature != FF_GPU_TEMP_UNSET)
|
||||
yyjson_mut_obj_add_real(doc, obj, "temperature", gpu->temperature);
|
||||
else
|
||||
yyjson_mut_obj_add_null(doc, obj, "temperature");
|
||||
@@ -389,7 +392,10 @@ void ffGenerateGPUJsonResult(FFGPUOptions* options, yyjson_mut_doc* doc, yyjson_
|
||||
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "platformApi", &gpu->platformApi);
|
||||
|
||||
yyjson_mut_obj_add_uint(doc, obj, "frequency", gpu->frequency);
|
||||
if (gpu->frequency != FF_GPU_FREQUENCY_UNSET)
|
||||
yyjson_mut_obj_add_uint(doc, obj, "frequency", gpu->frequency);
|
||||
else
|
||||
yyjson_mut_obj_add_null(doc, obj, "frequency");
|
||||
|
||||
yyjson_mut_obj_add_uint(doc, obj, "deviceId", gpu->deviceId);
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ void ffPrintPhysicalDisk(FFPhysicalDiskOptions* options)
|
||||
ffStrbufAppendC(&buffer, ']');
|
||||
}
|
||||
|
||||
if (dev->temperature == dev->temperature) //FF_PHYSICALDISK_TEMP_UNSET
|
||||
if (dev->temperature != FF_PHYSICALDISK_TEMP_UNSET)
|
||||
{
|
||||
if(buffer.length > 0)
|
||||
ffStrbufAppendS(&buffer, " - ");
|
||||
@@ -209,7 +209,10 @@ void ffGeneratePhysicalDiskJsonResult(FFPhysicalDiskOptions* options, yyjson_mut
|
||||
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "revision", &dev->revision);
|
||||
|
||||
yyjson_mut_obj_add_real(doc, obj, "temperature", dev->temperature);
|
||||
if (dev->temperature != FF_PHYSICALDISK_TEMP_UNSET)
|
||||
yyjson_mut_obj_add_real(doc, obj, "temperature", dev->temperature);
|
||||
else
|
||||
yyjson_mut_obj_add_null(doc, obj, "temperature");
|
||||
}
|
||||
|
||||
FF_LIST_FOR_EACH(FFPhysicalDiskResult, dev, result)
|
||||
|
||||
+14
-5
@@ -55,7 +55,7 @@ void ffPrintWifi(FFWifiOptions* options)
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
if(item->conn.ssid.length)
|
||||
{
|
||||
if(item->conn.signalQuality == item->conn.signalQuality)
|
||||
if(item->conn.signalQuality != -DBL_MAX)
|
||||
{
|
||||
if(percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
@@ -86,7 +86,7 @@ void ffPrintWifi(FFWifiOptions* options)
|
||||
ffStrbufAppendC(&buffer, ' ');
|
||||
}
|
||||
|
||||
if(item->conn.signalQuality == item->conn.signalQuality)
|
||||
if(item->conn.signalQuality != -DBL_MAX)
|
||||
{
|
||||
if(percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
ffPercentAppendNum(&buffer, item->conn.signalQuality, options->percent, buffer.length > 0, &options->moduleArgs);
|
||||
@@ -184,9 +184,18 @@ void ffGenerateWifiJsonResult(FF_MAYBE_UNUSED FFWifiOptions* options, yyjson_mut
|
||||
yyjson_mut_obj_add_strbuf(doc, conn, "bssid", &wifi->conn.bssid);
|
||||
yyjson_mut_obj_add_strbuf(doc, conn, "protocol", &wifi->conn.protocol);
|
||||
yyjson_mut_obj_add_strbuf(doc, conn, "security", &wifi->conn.security);
|
||||
yyjson_mut_obj_add_real(doc, conn, "signalQuality", wifi->conn.signalQuality);
|
||||
yyjson_mut_obj_add_real(doc, conn, "rxRate", wifi->conn.rxRate);
|
||||
yyjson_mut_obj_add_real(doc, conn, "txRate", wifi->conn.txRate);
|
||||
if (wifi->conn.signalQuality != -DBL_MAX)
|
||||
yyjson_mut_obj_add_real(doc, conn, "signalQuality", wifi->conn.signalQuality);
|
||||
else
|
||||
yyjson_mut_obj_add_null(doc, conn, "signalQuality");
|
||||
if (wifi->conn.rxRate != -DBL_MAX)
|
||||
yyjson_mut_obj_add_real(doc, conn, "rxRate", wifi->conn.rxRate);
|
||||
else
|
||||
yyjson_mut_obj_add_null(doc, conn, "rxRate");
|
||||
if (wifi->conn.txRate != -DBL_MAX)
|
||||
yyjson_mut_obj_add_real(doc, conn, "txRate", wifi->conn.txRate);
|
||||
else
|
||||
yyjson_mut_obj_add_null(doc, conn, "txRate");
|
||||
yyjson_mut_obj_add_uint(doc, conn, "channel", wifi->conn.channel);
|
||||
yyjson_mut_obj_add_uint(doc, conn, "frequency", wifi->conn.frequency);
|
||||
}
|
||||
|
||||
@@ -151,7 +151,10 @@ void ffGenerateZpoolJsonResult(FF_MAYBE_UNUSED FFZpoolOptions* options, yyjson_m
|
||||
yyjson_mut_obj_add_uint(doc, obj, "used", zpool->used);
|
||||
yyjson_mut_obj_add_uint(doc, obj, "total", zpool->total);
|
||||
yyjson_mut_obj_add_uint(doc, obj, "version", zpool->version);
|
||||
yyjson_mut_obj_add_real(doc, obj, "fragmentation", zpool->fragmentation);
|
||||
if (zpool->fragmentation != -DBL_MAX)
|
||||
yyjson_mut_obj_add_real(doc, obj, "fragmentation", zpool->fragmentation);
|
||||
else
|
||||
yyjson_mut_obj_add_null(doc, obj, "fragmentation");
|
||||
}
|
||||
|
||||
FF_LIST_FOR_EACH(FFZpoolResult, zpool, results)
|
||||
|
||||
Reference in New Issue
Block a user