From a6bdecd8a8833f6e928b4fbe901977c13b22f670 Mon Sep 17 00:00:00 2001 From: Philipp Storz Date: Mon, 16 Oct 2023 21:02:55 +0200 Subject: [PATCH] fix: Fix sign-compare warning src/InodeCache.cpp on FreeBSD (#1331) As on FreeBSD 13.2 statfs.f_bavail is signed, InodeCache.cpp cannot be compiled but gets a sign-compare warning: src/InodeCache.cpp:409:30: error: comparison of integers of different signs: 'long' and 'unsigned long' [-Werror,-Wsign-compare] if (buf.f_bavail * 512 < k_min_fs_mib_left * 1024 * 1024) { ~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. The problem is avoided by using static_cast to uint64_t. --- src/InodeCache.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/InodeCache.cpp b/src/InodeCache.cpp index 69c6dcabf..c86c66837 100644 --- a/src/InodeCache.cpp +++ b/src/InodeCache.cpp @@ -416,7 +416,8 @@ InodeCache::initialize() LOG("fstatfs failed: {}", strerror(errno)); return false; } - if (buf.f_bavail * 512 < k_min_fs_mib_left * 1024 * 1024) { + if (static_cast(buf.f_bavail) * 512 + < k_min_fs_mib_left * 1024 * 1024) { LOG("Filesystem has less than {} MiB free space, not using inode cache", k_min_fs_mib_left); return false; -- 2.47.2