cl: https://chromium-review.googlesource.com/c/chromium/src/+/4159728 diff --git a/base/system/sys_info_posix.cc b/base/system/sys_info_posix.cc index 92e70aa..80c750ba 100644 --- a/base/system/sys_info_posix.cc +++ b/base/system/sys_info_posix.cc @@ -67,10 +67,16 @@ if (HANDLE_EINTR(statfs(path.value().c_str(), &stats)) != 0) return false; - switch (stats.f_type) { + // This static_cast is here because various libcs disagree about the size + // and signedness of statfs::f_type. In particular, glibc has it as either a + // signed long or a signed int depending on platform, and other libcs + // (following the statfs(2) man page) use unsigned int instead. To avoid + // either an unsigned -> signed cast, or a narrowing cast, we always upcast + // statfs::f_type to unsigned long. :( + switch (static_cast(stats.f_type)) { case TMPFS_MAGIC: - case static_cast(HUGETLBFS_MAGIC): - case static_cast(RAMFS_MAGIC): + case HUGETLBFS_MAGIC: + case RAMFS_MAGIC: return true; } return false;