From: Joel Rosdahl Date: Wed, 24 Aug 2022 17:12:32 +0000 (+0200) Subject: fix: Avoid narrowing warning for struct statfs f_type field X-Git-Tag: v4.7~97 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bed8a2c1e436a2b23fd2facd06b67cd98f629a32;p=thirdparty%2Fccache.git fix: Avoid narrowing warning for struct statfs f_type field As noted in #1142. --- diff --git a/src/InodeCache.cpp b/src/InodeCache.cpp index add674889..006ffab8c 100644 --- a/src/InodeCache.cpp +++ b/src/InodeCache.cpp @@ -95,7 +95,11 @@ fd_is_on_known_to_work_file_system(int fd) LOG("fstatfs failed: {}", strerror(errno)); } else { #ifdef HAVE_LINUX_FS_H - switch (buf.f_type) { + // statfs's f_type field is a signed 32-bit integer on some platforms. Large + // values therefore cause narrowing warnings, so cast the value to a large + // unsigned type. + const auto f_type = static_cast(buf.f_type); + switch (f_type) { // Is a filesystem you know works with the inode cache missing in this // list? Please submit an issue or pull request to the ccache project. case 0x9123683e: // BTRFS_SUPER_MAGIC @@ -106,7 +110,7 @@ fd_is_on_known_to_work_file_system(int fd) break; default: LOG("Filesystem type 0x{:x} not known to work for the inode cache", - buf.f_type); + f_type); } #elif defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) // macOS X and some BSDs static const std::vector known_to_work_filesystems = {