[cmds] Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning.
Test: m
Bug: 68236239
Change-Id: I1635395d653ace5a11c75795f4a7d2bf2d9e0b1b
Merged-In: I73a0a82e3e32001f8ffb0880250c7023dd8290d3
diff --git a/cmds/atrace/atrace.cpp b/cmds/atrace/atrace.cpp
index 506fbd9..2e41eb5 100644
--- a/cmds/atrace/atrace.cpp
+++ b/cmds/atrace/atrace.cpp
@@ -226,8 +226,8 @@
static bool g_compress = false;
static bool g_nohup = false;
static int g_initialSleepSecs = 0;
-static const char* g_categoriesFile = NULL;
-static const char* g_kernelTraceFuncs = NULL;
+static const char* g_categoriesFile = nullptr;
+static const char* g_kernelTraceFuncs = nullptr;
static const char* g_debugAppCmdLine = "";
static const char* g_outputFile = nullptr;
@@ -403,7 +403,7 @@
for (int i = 0; i < MAX_SYS_FILES; i++) {
const char* path = category.sysfiles[i].path;
bool req = category.sysfiles[i].required == REQ;
- if (path != NULL) {
+ if (path != nullptr) {
if (req) {
if (!fileIsWritable(path)) {
return false;
@@ -428,7 +428,7 @@
for (int i = 0; i < MAX_SYS_FILES; i++) {
const char* path = category.sysfiles[i].path;
bool req = category.sysfiles[i].required == REQ;
- if (path != NULL) {
+ if (path != nullptr) {
if (req) {
if (!fileExists(path)) {
return false;
@@ -544,10 +544,10 @@
Vector<String16> services = sm->listServices();
for (size_t i = 0; i < services.size(); i++) {
sp<IBinder> obj = sm->checkService(services[i]);
- if (obj != NULL) {
+ if (obj != nullptr) {
Parcel data;
if (obj->transact(IBinder::SYSPROPS_TRANSACTION, data,
- NULL, 0) != OK) {
+ nullptr, 0) != OK) {
if (false) {
// XXX: For some reason this fails on tablets trying to
// poke the "phone" service. It's not clear whether some
@@ -637,9 +637,9 @@
{
int i = 0;
char* start = cmdline;
- while (start != NULL) {
+ while (start != nullptr) {
char* end = strchr(start, ',');
- if (end != NULL) {
+ if (end != nullptr) {
*end = '\0';
end++;
}
@@ -669,7 +669,7 @@
const TracingCategory &c = k_categories[i];
for (int j = 0; j < MAX_SYS_FILES; j++) {
const char* path = c.sysfiles[j].path;
- if (path != NULL && fileIsWritable(path)) {
+ if (path != nullptr && fileIsWritable(path)) {
ok &= setKernelOptionEnable(path, false);
}
}
@@ -705,7 +705,7 @@
ok = false;
}
}
- func = strtok(NULL, ",");
+ func = strtok(nullptr, ",");
}
free(myFuncs);
return ok;
@@ -716,7 +716,7 @@
{
bool ok = true;
- if (funcs == NULL || funcs[0] == '\0') {
+ if (funcs == nullptr || funcs[0] == '\0') {
// Disable kernel function tracing.
if (fileIsWritable(k_currentTracerPath)) {
ok &= writeStr(k_currentTracerPath, "nop");
@@ -738,7 +738,7 @@
char* func = strtok(myFuncs, ",");
while (func) {
ok &= appendStr(k_ftraceFilterPath, func);
- func = strtok(NULL, ",");
+ func = strtok(nullptr, ",");
}
free(myFuncs);
@@ -780,7 +780,7 @@
if (!categories_file) {
return true;
}
- Tokenizer* tokenizer = NULL;
+ Tokenizer* tokenizer = nullptr;
if (Tokenizer::open(String8(categories_file), &tokenizer) != NO_ERROR) {
return false;
}
@@ -882,7 +882,7 @@
for (int j = 0; j < MAX_SYS_FILES; j++) {
const char* path = c.sysfiles[j].path;
bool required = c.sysfiles[j].required == REQ;
- if (path != NULL) {
+ if (path != nullptr) {
if (fileIsWritable(path)) {
ok &= setKernelOptionEnable(path, true);
} else if (required) {
@@ -907,7 +907,7 @@
setTraceOverwriteEnable(true);
setTraceBufferSizeKB(1);
setPrintTgidEnableIfPresent(false);
- setKernelTraceFuncs(NULL);
+ setKernelTraceFuncs(nullptr);
setUserInitiatedTraceProperty(false);
}
@@ -1065,10 +1065,10 @@
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_handler = handleSignal;
- sigaction(SIGHUP, &sa, NULL);
- sigaction(SIGINT, &sa, NULL);
- sigaction(SIGQUIT, &sa, NULL);
- sigaction(SIGTERM, &sa, NULL);
+ sigaction(SIGHUP, &sa, nullptr);
+ sigaction(SIGINT, &sa, nullptr);
+ sigaction(SIGQUIT, &sa, nullptr);
+ sigaction(SIGTERM, &sa, nullptr);
}
static void listSupportedCategories()
@@ -1158,13 +1158,13 @@
int ret;
int option_index = 0;
static struct option long_options[] = {
- {"async_start", no_argument, 0, 0 },
- {"async_stop", no_argument, 0, 0 },
- {"async_dump", no_argument, 0, 0 },
- {"only_userspace", no_argument, 0, 0 },
- {"list_categories", no_argument, 0, 0 },
- {"stream", no_argument, 0, 0 },
- { 0, 0, 0, 0 }
+ {"async_start", no_argument, nullptr, 0 },
+ {"async_stop", no_argument, nullptr, 0 },
+ {"async_dump", no_argument, nullptr, 0 },
+ {"only_userspace", no_argument, nullptr, 0 },
+ {"list_categories", no_argument, nullptr, 0 },
+ {"stream", no_argument, nullptr, 0 },
+ {nullptr, 0, nullptr, 0 }
};
ret = getopt_long(argc, argv, "a:b:cf:k:ns:t:zo:",