summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYi Kong2018-07-16 20:11:34 -0500
committerYi Kong2018-07-16 20:11:34 -0500
commite1731a4f2e05f1abb4a45602067708851eaf1e14 (patch)
tree339c0ce3d3de7d6f5e0fb9bdada9b6210d1d470f /libutils/Tokenizer.cpp
parent895acebe946e34d2626716c5c4d7d7f2cc28c39d (diff)
downloadplatform-system-core-e1731a4f2e05f1abb4a45602067708851eaf1e14.tar.gz
platform-system-core-e1731a4f2e05f1abb4a45602067708851eaf1e14.tar.xz
platform-system-core-e1731a4f2e05f1abb4a45602067708851eaf1e14.zip
[libutils] Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning. Test: m Bug: 68236239 Change-Id: I5e89ec8c42151875439d2656475a8739ab9cb7dc
Diffstat (limited to 'libutils/Tokenizer.cpp')
-rw-r--r--libutils/Tokenizer.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/libutils/Tokenizer.cpp b/libutils/Tokenizer.cpp
index b68a2cfa3..f73d6991f 100644
--- a/libutils/Tokenizer.cpp
+++ b/libutils/Tokenizer.cpp
@@ -28,7 +28,7 @@
28namespace android { 28namespace android {
29 29
30static inline bool isDelimiter(char ch, const char* delimiters) { 30static inline bool isDelimiter(char ch, const char* delimiters) {
31 return strchr(delimiters, ch) != NULL; 31 return strchr(delimiters, ch) != nullptr;
32} 32}
33 33
34Tokenizer::Tokenizer(const String8& filename, FileMap* fileMap, char* buffer, 34Tokenizer::Tokenizer(const String8& filename, FileMap* fileMap, char* buffer,
@@ -46,7 +46,7 @@ Tokenizer::~Tokenizer() {
46} 46}
47 47
48status_t Tokenizer::open(const String8& filename, Tokenizer** outTokenizer) { 48status_t Tokenizer::open(const String8& filename, Tokenizer** outTokenizer) {
49 *outTokenizer = NULL; 49 *outTokenizer = nullptr;
50 50
51 int result = NO_ERROR; 51 int result = NO_ERROR;
52 int fd = ::open(filename.string(), O_RDONLY); 52 int fd = ::open(filename.string(), O_RDONLY);
@@ -64,12 +64,12 @@ status_t Tokenizer::open(const String8& filename, Tokenizer** outTokenizer) {
64 FileMap* fileMap = new FileMap(); 64 FileMap* fileMap = new FileMap();
65 bool ownBuffer = false; 65 bool ownBuffer = false;
66 char* buffer; 66 char* buffer;
67 if (fileMap->create(NULL, fd, 0, length, true)) { 67 if (fileMap->create(nullptr, fd, 0, length, true)) {
68 fileMap->advise(FileMap::SEQUENTIAL); 68 fileMap->advise(FileMap::SEQUENTIAL);
69 buffer = static_cast<char*>(fileMap->getDataPtr()); 69 buffer = static_cast<char*>(fileMap->getDataPtr());
70 } else { 70 } else {
71 delete fileMap; 71 delete fileMap;
72 fileMap = NULL; 72 fileMap = nullptr;
73 73
74 // Fall back to reading into a buffer since we can't mmap files in sysfs. 74 // Fall back to reading into a buffer since we can't mmap files in sysfs.
75 // The length we obtained from stat is wrong too (it will always be 4096) 75 // The length we obtained from stat is wrong too (it will always be 4096)
@@ -81,7 +81,7 @@ status_t Tokenizer::open(const String8& filename, Tokenizer** outTokenizer) {
81 result = -errno; 81 result = -errno;
82 ALOGE("Error reading file '%s': %s", filename.string(), strerror(errno)); 82 ALOGE("Error reading file '%s': %s", filename.string(), strerror(errno));
83 delete[] buffer; 83 delete[] buffer;
84 buffer = NULL; 84 buffer = nullptr;
85 } else { 85 } else {
86 length = size_t(nrd); 86 length = size_t(nrd);
87 } 87 }
@@ -98,7 +98,7 @@ status_t Tokenizer::open(const String8& filename, Tokenizer** outTokenizer) {
98 98
99status_t Tokenizer::fromContents(const String8& filename, 99status_t Tokenizer::fromContents(const String8& filename,
100 const char* contents, Tokenizer** outTokenizer) { 100 const char* contents, Tokenizer** outTokenizer) {
101 *outTokenizer = new Tokenizer(filename, NULL, 101 *outTokenizer = new Tokenizer(filename, nullptr,
102 const_cast<char*>(contents), false, strlen(contents)); 102 const_cast<char*>(contents), false, strlen(contents));
103 return OK; 103 return OK;
104} 104}