Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2885)

Unified Diff: base/files/file_util_linux.cc

Issue 1997153002: libchrome: Several upstreamable fixes from libchrome Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Addressed feedback Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/files/file_util_linux.cc
diff --git a/base/files/file_util_linux.cc b/base/files/file_util_linux.cc
index b230fd96484c7d8e75f408edc912019d60ffb728..b0c6e0328507fde90d4e09e7d24c4b1089216159 100644
--- a/base/files/file_util_linux.cc
+++ b/base/files/file_util_linux.cc
@@ -6,6 +6,7 @@
#include <errno.h>
#include <linux/magic.h>
+#include <stdint.h>
#include <sys/vfs.h>
#include "base/files/file_path.h"
@@ -23,7 +24,10 @@ bool GetFileSystemType(const FilePath& path, FileSystemType* type) {
// Not all possible |statfs_buf.f_type| values are in linux/magic.h.
// Missing values are copied from the statfs man page.
- switch (statfs_buf.f_type) {
+ // In some platforms, |statfs_buf.f_type| is declared as signed, but some of
+ // the values will overflow it, causing narrowing warnings. Cast to the
+ // largest possible unsigned integer type to avoid it.
+ switch (static_cast<uintmax_t>(statfs_buf.f_type)) {
case 0:
*type = FILE_SYSTEM_0;
break;

Powered by Google App Engine
This is Rietveld 408576698