Chromium Code Reviews| Index: base/sys_info_linux.cc |
| diff --git a/base/sys_info_linux.cc b/base/sys_info_linux.cc |
| index 67bfe5a64e0d4f2b5644977eb7ff142d5fd31e45..97804e7f49c72c8641fef36b5f8ef42c7594536e 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,22 @@ 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(limit >= 0); |
| + DCHECK(static_cast<size_t>(limit) <= sizeof(limit)); |
|
Mark Mentovai
2011/10/24 18:51:55
You didn’t really mean sizeof, did you?
Robert Nagy
2011/10/24 19:30:20
Done.
|
| + limit_valid = true; |
| + } else { |
| + NOTREACHED(); |
| + return 0; |
| + } |
| } |
| - return limit; |
| + return static_cast<size_t>(limit); |
| } |
| } // namespace base |