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

Side by Side Diff: snapshot/system_snapshot_mac.cc

Issue 656703002: Convert NULL to nullptr (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Fix 80-column violations Created 6 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
« no previous file with comments | « snapshot/process_snapshot.h ('k') | snapshot/system_snapshot_mac_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 17 matching lines...) Expand all
28 #include "util/numeric/in_range_cast.h" 28 #include "util/numeric/in_range_cast.h"
29 29
30 namespace crashpad { 30 namespace crashpad {
31 31
32 namespace { 32 namespace {
33 33
34 template <typename T> 34 template <typename T>
35 T ReadIntSysctlByName(const char* name, T default_value) { 35 T ReadIntSysctlByName(const char* name, T default_value) {
36 T value; 36 T value;
37 size_t value_len = sizeof(value); 37 size_t value_len = sizeof(value);
38 if (sysctlbyname(name, &value, &value_len, NULL, 0) != 0) { 38 if (sysctlbyname(name, &value, &value_len, nullptr, 0) != 0) {
39 PLOG(WARNING) << "sysctlbyname " << name; 39 PLOG(WARNING) << "sysctlbyname " << name;
40 return default_value; 40 return default_value;
41 } 41 }
42 42
43 return value; 43 return value;
44 } 44 }
45 45
46 template <typename T> 46 template <typename T>
47 T CastIntSysctlByName(const char* name, T default_value) { 47 T CastIntSysctlByName(const char* name, T default_value) {
48 int int_value = ReadIntSysctlByName<int>(name, default_value); 48 int int_value = ReadIntSysctlByName<int>(name, default_value);
49 return InRangeCast<T>(int_value, default_value); 49 return InRangeCast<T>(int_value, default_value);
50 } 50 }
51 51
52 std::string ReadStringSysctlByName(const char* name) { 52 std::string ReadStringSysctlByName(const char* name) {
53 size_t buf_len; 53 size_t buf_len;
54 if (sysctlbyname(name, NULL, &buf_len, NULL, 0) != 0) { 54 if (sysctlbyname(name, nullptr, &buf_len, nullptr, 0) != 0) {
55 PLOG(WARNING) << "sysctlbyname (size) " << name; 55 PLOG(WARNING) << "sysctlbyname (size) " << name;
56 return std::string(); 56 return std::string();
57 } 57 }
58 58
59 if (buf_len == 0) { 59 if (buf_len == 0) {
60 return std::string(); 60 return std::string();
61 } 61 }
62 62
63 std::string value(buf_len - 1, '\0'); 63 std::string value(buf_len - 1, '\0');
64 if (sysctlbyname(name, &value[0], &buf_len, NULL, 0) != 0) { 64 if (sysctlbyname(name, &value[0], &buf_len, nullptr, 0) != 0) {
65 PLOG(WARNING) << "sysctlbyname " << name; 65 PLOG(WARNING) << "sysctlbyname " << name;
66 return std::string(); 66 return std::string();
67 } 67 }
68 68
69 return value; 69 return value;
70 } 70 }
71 71
72 #if defined(ARCH_CPU_X86_FAMILY) 72 #if defined(ARCH_CPU_X86_FAMILY)
73 void CallCPUID(uint32_t leaf, 73 void CallCPUID(uint32_t leaf,
74 uint32_t* eax, 74 uint32_t* eax,
75 uint32_t* ebx, 75 uint32_t* ebx,
76 uint32_t* ecx, 76 uint32_t* ecx,
77 uint32_t* edx) { 77 uint32_t* edx) {
78 asm("cpuid" 78 asm("cpuid"
79 : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx) 79 : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx)
80 : "a"(leaf), "b"(0), "c"(0), "d"(0)); 80 : "a"(leaf), "b"(0), "c"(0), "d"(0));
81 } 81 }
82 #endif 82 #endif
83 83
84 } // namespace 84 } // namespace
85 85
86 namespace internal { 86 namespace internal {
87 87
88 SystemSnapshotMac::SystemSnapshotMac() 88 SystemSnapshotMac::SystemSnapshotMac()
89 : SystemSnapshot(), 89 : SystemSnapshot(),
90 os_version_full_(), 90 os_version_full_(),
91 os_version_build_(), 91 os_version_build_(),
92 process_reader_(NULL), 92 process_reader_(nullptr),
93 snapshot_time_(NULL), 93 snapshot_time_(nullptr),
94 os_version_major_(0), 94 os_version_major_(0),
95 os_version_minor_(0), 95 os_version_minor_(0),
96 os_version_bugfix_(0), 96 os_version_bugfix_(0),
97 os_server_(false), 97 os_server_(false),
98 initialized_() { 98 initialized_() {
99 } 99 }
100 100
101 SystemSnapshotMac::~SystemSnapshotMac() { 101 SystemSnapshotMac::~SystemSnapshotMac() {
102 } 102 }
103 103
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 } else { 390 } else {
391 *daylight_name = tzname[0]; 391 *daylight_name = tzname[0];
392 *dst_status = kDoesNotObserveDaylightSavingTime; 392 *dst_status = kDoesNotObserveDaylightSavingTime;
393 *standard_offset_seconds = local.tm_gmtoff; 393 *standard_offset_seconds = local.tm_gmtoff;
394 *daylight_offset_seconds = local.tm_gmtoff; 394 *daylight_offset_seconds = local.tm_gmtoff;
395 } 395 }
396 } 396 }
397 397
398 } // namespace internal 398 } // namespace internal
399 } // namespace crashpad 399 } // namespace crashpad
OLDNEW
« no previous file with comments | « snapshot/process_snapshot.h ('k') | snapshot/system_snapshot_mac_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698