mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Chore: fix code smell
This commit is contained in:
@@ -36,7 +36,7 @@ static const char* detectFsLabel(struct statfs* fs, FFDisk* disk)
|
||||
return "geom_gettree() failed";
|
||||
}
|
||||
|
||||
for (cLabels = geomTree.lg_class.lh_first; !ffStrEquals(cLabels->lg_name, "LABEL"); cLabels = cLabels->lg_class.le_next);
|
||||
for (cLabels = geomTree.lg_class.lh_first; cLabels && !ffStrEquals(cLabels->lg_name, "LABEL"); cLabels = cLabels->lg_class.le_next);
|
||||
if (!cLabels)
|
||||
return "Class LABEL is not found";
|
||||
}
|
||||
@@ -165,7 +165,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
|
||||
disk->bytesUsed = 0; // To be filled in ./disk.c
|
||||
|
||||
disk->filesTotal = (uint32_t) fs->f_files;
|
||||
disk->filesUsed = (uint32_t) (disk->filesTotal - (uint64_t)fs->f_ffree);
|
||||
disk->filesUsed = (uint32_t) (fs->f_files - fs->f_ffree);
|
||||
|
||||
ffStrbufInitS(&disk->mountFrom, fs->f_mntfromname);
|
||||
ffStrbufInitS(&disk->mountpoint, fs->f_mntonname);
|
||||
@@ -185,7 +185,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
|
||||
#ifndef __DragonFly__
|
||||
struct stat st;
|
||||
if(stat(fs->f_mntonname, &st) == 0 && st.st_birthtimespec.tv_sec > 0)
|
||||
disk->createTime = (uint64_t)((st.st_birthtimespec.tv_sec * 1000) + (st.st_birthtimespec.tv_nsec / 1000000));
|
||||
disk->createTime = (uint64_t)(((uint64_t) st.st_birthtimespec.tv_sec * 1000) + (st.st_birthtimespec.tv_nsec / 1000000));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
|
||||
for (dev_t dev; (dev = next_dev(&pos)) >= B_OK;)
|
||||
{
|
||||
fs_info fs;
|
||||
if (fs_stat_dev(dev, &fs) < -1) continue;
|
||||
if (fs_stat_dev(dev, &fs) < 0) continue;
|
||||
|
||||
node_ref node(fs.dev, fs.root);
|
||||
BDirectory dir(&node);
|
||||
@@ -32,10 +32,10 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
|
||||
disk->bytesTotal = (uint64_t)fs.total_blocks * (uint64_t) fs.block_size;
|
||||
disk->bytesFree = (uint64_t)fs.free_blocks * (uint64_t) fs.block_size;
|
||||
disk->bytesAvailable = disk->bytesFree;
|
||||
disk->bytesUsed = 0; // To be filled in ./disk. c
|
||||
disk->bytesUsed = 0; // To be filled in ./disk.c
|
||||
|
||||
disk->filesTotal = (uint32_t) fs.total_nodes;
|
||||
disk->filesUsed = (uint32_t) (disk->filesTotal - (uint64_t)fs.free_nodes);
|
||||
disk->filesUsed = (uint32_t) (fs.total_nodes - fs.free_nodes);
|
||||
|
||||
ffStrbufInitS(&disk->mountFrom, fs.device_name);
|
||||
ffStrbufInitS(&disk->mountpoint, path.Path());
|
||||
|
||||
@@ -209,7 +209,10 @@ static bool isRemovable(FFDisk* currentDisk)
|
||||
char sysBlockVolume[PATH_MAX]; // /sys/devices/pci0000:00/0000:00:14.0/usb4/4-3/4-3:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1
|
||||
if (realpath(sysBlockPartition, sysBlockVolume) == NULL)
|
||||
return false;
|
||||
strcpy(strrchr(sysBlockVolume, '/') + 1, "removable");
|
||||
char* lastSlash = strrchr(sysBlockVolume, '/');
|
||||
if (lastSlash == NULL)
|
||||
return false;
|
||||
strcpy(lastSlash + 1, "removable");
|
||||
|
||||
char removableChar = '0';
|
||||
return ffReadFileData(sysBlockVolume, 1, &removableChar) > 0 && removableChar == '1';
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
|
||||
const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options)
|
||||
{
|
||||
struct gmesh geomTree;
|
||||
__attribute__((__cleanup__(geom_deletetree)))
|
||||
struct gmesh geomTree = {};
|
||||
if (geom_gettree(&geomTree) < 0)
|
||||
return "geom_gettree() failed";
|
||||
|
||||
@@ -21,6 +22,9 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options)
|
||||
return "geom_stats_open() failed";
|
||||
|
||||
void* snap = geom_stats_snapshot_get();
|
||||
if (!snap)
|
||||
return "geom_stats_snapshot_get() failed";
|
||||
|
||||
struct devstat* snapIter;
|
||||
while ((snapIter = geom_stats_snapshot_next(snap)) != NULL)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user