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

Side by Side Diff: base/sys_info_linux.cc

Issue 8382001: OpenBSD patches for base and build, part 2 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: remove duplicate return Created 9 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/sys_info.h" 5 #include "base/sys_info.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_number_conversions.h"
9 10
10 namespace base { 11 namespace base {
11 12
12 int64 SysInfo::AmountOfPhysicalMemory() { 13 int64 SysInfo::AmountOfPhysicalMemory() {
13 long pages = sysconf(_SC_PHYS_PAGES); 14 long pages = sysconf(_SC_PHYS_PAGES);
14 long page_size = sysconf(_SC_PAGE_SIZE); 15 long page_size = sysconf(_SC_PAGE_SIZE);
15 if (pages == -1 || page_size == -1) { 16 if (pages == -1 || page_size == -1) {
16 NOTREACHED(); 17 NOTREACHED();
17 return 0; 18 return 0;
18 } 19 }
19 20
20 return static_cast<int64>(pages) * page_size; 21 return static_cast<int64>(pages) * page_size;
21 } 22 }
22 23
23 // static 24 // static
24 size_t SysInfo::MaxSharedMemorySize() { 25 size_t SysInfo::MaxSharedMemorySize() {
25 static size_t limit; 26 static int64 limit;
26 static bool limit_valid = false; 27 static bool limit_valid = false;
27 if (!limit_valid) { 28 if (!limit_valid) {
28 std::string contents; 29 std::string contents;
29 file_util::ReadFileToString(FilePath("/proc/sys/kernel/shmmax"), &contents); 30 file_util::ReadFileToString(FilePath("/proc/sys/kernel/shmmax"), &contents);
30 limit = strtoul(contents.c_str(), NULL, 0); 31 DCHECK(!contents.empty());
31 limit_valid = true; 32 if (base::StringToInt64(contents, &limit)) {
33 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.
34 limit_valid = true;
35 } else {
36 NOTREACHED();
37 return 0;
38 }
32 } 39 }
33 return limit; 40 return static_cast<size_t>(limit);
34 } 41 }
35 42
36 } // namespace base 43 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698