Index: base/sys_info_linux.cc |
diff --git a/base/sys_info_linux.cc b/base/sys_info_linux.cc |
index 67bfe5a64e0d4f2b5644977eb7ff142d5fd31e45..71f7d09c98270f229c16ffb65017e12d13fa8949 100644 |
--- a/base/sys_info_linux.cc |
+++ b/base/sys_info_linux.cc |
@@ -6,6 +6,7 @@ |
#include "base/file_util.h" |
#include "base/logging.h" |
+#include "base/string_number_conversions.h" |
namespace base { |
@@ -22,15 +23,21 @@ int64 SysInfo::AmountOfPhysicalMemory() { |
// static |
size_t SysInfo::MaxSharedMemorySize() { |
- static size_t limit; |
+ static int64 limit; |
static bool limit_valid = false; |
if (!limit_valid) { |
std::string contents; |
file_util::ReadFileToString(FilePath("/proc/sys/kernel/shmmax"), &contents); |
- limit = strtoul(contents.c_str(), NULL, 0); |
- limit_valid = true; |
+ DCHECK(!contents.empty()); |
+ if (base::StringToInt64(contents, &limit)) { |
+ DCHECK((size_t) limit <= sizeof(limit)); |
Mark Mentovai
2011/10/24 18:09:58
Use static_cast<size_t>(limit). Reference: http://
Mark Mentovai
2011/10/24 18:09:58
Also DCHECK(limit >= 0).
Robert Nagy
2011/10/24 18:20:17
Done.
Robert Nagy
2011/10/24 18:20:17
Done.
|
+ limit_valid = true; |
+ } else { |
+ NOTREACHED(); |
+ return 0; |
+ } |
} |
- return limit; |
+ return static_cast<size_t>(limit); |
} |
} // namespace base |