summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYi Kong2018-07-13 19:39:22 -0500
committerYi Kong2018-07-13 19:50:55 -0500
commitc8d09ddceb6ed9771b100c36fe4ca81d6ee1cfb2 (patch)
tree96692c3a30c1e9237194294b55ec8fc6b2f1b71f /logd/LogTags.cpp
parentdc8483cc04ea9d2a716a4ba0916eb3941b54156c (diff)
downloadplatform-system-core-c8d09ddceb6ed9771b100c36fe4ca81d6ee1cfb2.tar.gz
platform-system-core-c8d09ddceb6ed9771b100c36fe4ca81d6ee1cfb2.tar.xz
platform-system-core-c8d09ddceb6ed9771b100c36fe4ca81d6ee1cfb2.zip
[logd] Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning. Test: m Bug: 68236239 Change-Id: I15ccb9cfc9967dae4320d9690f5097bc2f7d5bfe
Diffstat (limited to 'logd/LogTags.cpp')
-rw-r--r--logd/LogTags.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/logd/LogTags.cpp b/logd/LogTags.cpp
index ff7e76258..1ab9dd1b6 100644
--- a/logd/LogTags.cpp
+++ b/logd/LogTags.cpp
@@ -91,7 +91,7 @@ bool LogTags::RebuildFileEventLogTags(const char* filename, bool warn) {
91 fd = TEMP_FAILURE_RETRY(open( 91 fd = TEMP_FAILURE_RETRY(open(
92 filename, O_WRONLY | O_TRUNC | O_CLOEXEC | O_NOFOLLOW | O_BINARY)); 92 filename, O_WRONLY | O_TRUNC | O_CLOEXEC | O_NOFOLLOW | O_BINARY));
93 if (fd >= 0) { 93 if (fd >= 0) {
94 time_t now = time(NULL); 94 time_t now = time(nullptr);
95 struct tm tm; 95 struct tm tm;
96 localtime_r(&now, &tm); 96 localtime_r(&now, &tm);
97 char timebuf[20]; 97 char timebuf[20];
@@ -208,7 +208,7 @@ void LogTags::ReadFileEventLogTags(const char* filename, bool warn) {
208 } else if (lineStart) { 208 } else if (lineStart) {
209 if (*cp == '#') { 209 if (*cp == '#') {
210 /* comment; just scan to end */ 210 /* comment; just scan to end */
211 lineStart = NULL; 211 lineStart = nullptr;
212 } else if (isdigit(*cp)) { 212 } else if (isdigit(*cp)) {
213 unsigned long Tag = strtoul(cp, &cp, 10); 213 unsigned long Tag = strtoul(cp, &cp, 10);
214 if (warn && (Tag > emptyTag)) { 214 if (warn && (Tag > emptyTag)) {
@@ -235,7 +235,7 @@ void LogTags::ReadFileEventLogTags(const char* filename, bool warn) {
235 if (hasAlpha && 235 if (hasAlpha &&
236 ((cp >= endp) || (*cp == '#') || isspace(*cp))) { 236 ((cp >= endp) || (*cp == '#') || isspace(*cp))) {
237 if (Tag > emptyTag) { 237 if (Tag > emptyTag) {
238 if (*cp != '\n') lineStart = NULL; 238 if (*cp != '\n') lineStart = nullptr;
239 continue; 239 continue;
240 } 240 }
241 while ((cp < endp) && (*cp != '\n') && isspace(*cp)) 241 while ((cp < endp) && (*cp != '\n') && isspace(*cp))
@@ -245,14 +245,14 @@ void LogTags::ReadFileEventLogTags(const char* filename, bool warn) {
245 while ((cp < endp) && (*cp != '\n')) { 245 while ((cp < endp) && (*cp != '\n')) {
246 if (*cp == '#') { 246 if (*cp == '#') {
247 uid = sniffUid(cp, endp); 247 uid = sniffUid(cp, endp);
248 lineStart = NULL; 248 lineStart = nullptr;
249 break; 249 break;
250 } 250 }
251 ++cp; 251 ++cp;
252 } 252 }
253 while ((cp > format) && isspace(cp[-1])) { 253 while ((cp > format) && isspace(cp[-1])) {
254 --cp; 254 --cp;
255 lineStart = NULL; 255 lineStart = nullptr;
256 } 256 }
257 std::string Format(format, cp - format); 257 std::string Format(format, cp - format);
258 258
@@ -263,7 +263,7 @@ void LogTags::ReadFileEventLogTags(const char* filename, bool warn) {
263 android::prdebug("tag name invalid %.*s", 263 android::prdebug("tag name invalid %.*s",
264 (int)(cp - name + 1), name); 264 (int)(cp - name + 1), name);
265 } 265 }
266 lineStart = NULL; 266 lineStart = nullptr;
267 } 267 }
268 } else if (!isspace(*cp)) { 268 } else if (!isspace(*cp)) {
269 break; 269 break;
@@ -364,7 +364,7 @@ const char* LogTags::tagToName(uint32_t tag) const {
364 android::RWLock::AutoRLock readLock(const_cast<android::RWLock&>(rwlock)); 364 android::RWLock::AutoRLock readLock(const_cast<android::RWLock&>(rwlock));
365 365
366 it = tag2name.find(tag); 366 it = tag2name.find(tag);
367 if ((it == tag2name.end()) || (it->second.length() == 0)) return NULL; 367 if ((it == tag2name.end()) || (it->second.length() == 0)) return nullptr;
368 368
369 return it->second.c_str(); 369 return it->second.c_str();
370} 370}
@@ -383,7 +383,7 @@ const char* LogTags::tagToName(uint32_t tag) const {
383const char* android::tagToName(uint32_t tag) { 383const char* android::tagToName(uint32_t tag) {
384 LogTags* me = logtags; 384 LogTags* me = logtags;
385 385
386 if (!me) return NULL; 386 if (!me) return nullptr;
387 me->WritePmsgEventLogTags(tag); 387 me->WritePmsgEventLogTags(tag);
388 return me->tagToName(tag); 388 return me->tagToName(tag);
389} 389}
@@ -412,7 +412,7 @@ const char* LogTags::tagToFormat(uint32_t tag) const {
412 android::RWLock::AutoRLock readLock(const_cast<android::RWLock&>(rwlock)); 412 android::RWLock::AutoRLock readLock(const_cast<android::RWLock&>(rwlock));
413 413
414 iform = tag2format.find(tag); 414 iform = tag2format.find(tag);
415 if (iform == tag2format.end()) return NULL; 415 if (iform == tag2format.end()) return nullptr;
416 416
417 return iform->second.c_str(); 417 return iform->second.c_str();
418} 418}
@@ -441,7 +441,7 @@ uint32_t LogTags::nameToTag_locked(const std::string& name, const char* format,
441 bool& unique) { 441 bool& unique) {
442 key2tag_const_iterator ik; 442 key2tag_const_iterator ik;
443 443
444 bool write = format != NULL; 444 bool write = format != nullptr;
445 unique = write; 445 unique = write;
446 446
447 if (!write) { 447 if (!write) {
@@ -679,7 +679,7 @@ void LogTags::WritePersistEventLogTags(uint32_t tag, uid_t uid,
679// are in readonly mode. 679// are in readonly mode.
680uint32_t LogTags::nameToTag(uid_t uid, const char* name, const char* format) { 680uint32_t LogTags::nameToTag(uid_t uid, const char* name, const char* format) {
681 std::string Name = std::string(name); 681 std::string Name = std::string(name);
682 bool write = format != NULL; 682 bool write = format != nullptr;
683 bool updateUid = uid != AID_ROOT; 683 bool updateUid = uid != AID_ROOT;
684 bool updateFormat = format && *format; 684 bool updateFormat = format && *format;
685 bool unique; 685 bool unique;
@@ -848,7 +848,7 @@ std::string LogTags::formatGetEventTag(uid_t uid, const char* name,
848 848
849 if (!list) { 849 if (!list) {
850 // switch to read entry only if format == "*" 850 // switch to read entry only if format == "*"
851 if (format && (format[0] == '*') && !format[1]) format = NULL; 851 if (format && (format[0] == '*') && !format[1]) format = nullptr;
852 852
853 // WAI: for null format, only works for a single entry, we can have 853 // WAI: for null format, only works for a single entry, we can have
854 // multiple entries, one for each format, so we find first entry 854 // multiple entries, one for each format, so we find first entry