Disk: don't convert NAN to integer; don't print 0B / 0B (0%)

fix ASAN warning: `runtime error: nan is outside the range of representable values of type 'unsigned char'`
This commit is contained in:
李通洲
2022-10-18 18:50:38 +08:00
parent e3ea39afaa
commit 3d5ef186ba
3 changed files with 11 additions and 12 deletions
-7
View File
@@ -19,13 +19,6 @@ const FFDiskResult* ffDetectDisks()
if(result.disks.length == 0 && result.error.length == 0)
ffStrbufAppendS(&result.error, "No disks found");
for(uint32_t i = 0; i < result.disks.length; ++i)
{
FFDisk* disk = ffListGet(&result.disks, i);
disk->bytesPercentage = (uint8_t) (((long double) disk->bytesUsed / (long double) disk->bytesTotal) * 100.0);
disk->filesPercentage = (uint8_t) (((long double) disk->filesUsed / (long double) disk->filesTotal) * 100.0);
}
//We need to sort the disks, so that we can detect, which disk a path resides on
// For example for /boot/efi/bootmgr we need to check /boot/efi before /boot
//Note that we sort alphabetically here for a better ordering when printing the list,