From: Philipp Storz Date: Mon, 16 Oct 2023 19:02:55 +0000 (+0200) Subject: fix: Fix sign-compare warning src/InodeCache.cpp on FreeBSD (#1331) X-Git-Tag: v4.9~34 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a6bdecd8a8833f6e928b4fbe901977c13b22f670;p=thirdparty%2Fccache.git 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. --- 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;