From 66deb4316b72c3fb904dc6042e228039f9411979 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Tue, 21 Jan 2025 09:41:40 +0800 Subject: [PATCH] Disk (NetBSD): silence compiler warnings Ref: https://github.com/NetBSD/pkgsrc/blob/ef998fe87c836293a337726e5f212011d4ee0327/sysutils/fastfetch/patches/patch-src_detection_disk_disk__bsd.c --- src/detection/disk/disk_bsd.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/detection/disk/disk_bsd.c b/src/detection/disk/disk_bsd.c index 957314f10..3ad7e745b 100644 --- a/src/detection/disk/disk_bsd.c +++ b/src/detection/disk/disk_bsd.c @@ -8,7 +8,6 @@ #ifdef __NetBSD__ #include #include -#define getfsstat(...) getvfsstat(__VA_ARGS__) #define statfs statvfs #define f_flags f_flag #define f_bsize f_frsize @@ -125,14 +124,22 @@ static void detectFsInfo(struct statfs* fs, FFDisk* disk) const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) { + #ifndef __NetBSD__ int size = getfsstat(NULL, 0, MNT_WAIT); - - if(size <= 0) - return "getfsstat(NULL, 0, MNT_WAIT) failed"; + if(size <= 0) return "getfsstat(NULL, 0, MNT_WAIT) failed"; + #else + int size = getvfsstat(NULL, 0, ST_WAIT); + if(size <= 0) return "getvfsstat(NULL, 0, ST_WAIT) failed"; + #endif FF_AUTO_FREE struct statfs* buf = malloc(sizeof(*buf) * (unsigned) size); + #ifndef __NetBSD__ if(getfsstat(buf, (int) (sizeof(*buf) * (unsigned) size), MNT_NOWAIT) <= 0) return "getfsstat(buf, size, MNT_NOWAIT) failed"; + #else + if(getvfsstat(buf, sizeof(*buf) * (unsigned) size, ST_NOWAIT) <= 0) + return "getvfsstat(buf, size, ST_NOWAIT) failed"; + #endif for(struct statfs* fs = buf; fs < buf + size; ++fs) {