From 19d5c00350893a2c9408d8d5a93d1d705b278562 Mon Sep 17 00:00:00 2001 From: Yi Kong Date: Fri, 20 Jul 2018 13:39:55 -0700 Subject: [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 --- cmds/service/service.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'cmds/service/service.cpp') diff --git a/cmds/service/service.cpp b/cmds/service/service.cpp index bc11256a73..34a3fdc420 100644 --- a/cmds/service/service.cpp +++ b/cmds/service/service.cpp @@ -30,7 +30,7 @@ using namespace android; void writeString16(Parcel& parcel, const char* string) { - if (string != NULL) + if (string != nullptr) { parcel.writeString16(String16(string)); } @@ -43,7 +43,7 @@ void writeString16(Parcel& parcel, const char* string) // get the name of the generic interface we hold a reference to static String16 get_interface_name(sp service) { - if (service != NULL) { + if (service != nullptr) { Parcel data, reply; status_t err = service->transact(IBinder::INTERFACE_TRANSACTION, data, &reply); if (err == NO_ERROR) { @@ -93,7 +93,7 @@ int main(int argc, char* const argv[]) #endif sp sm = defaultServiceManager(); fflush(stdout); - if (sm == NULL) { + if (sm == nullptr) { aerr << "service: Unable to get default service manager!" << endl; return 20; } @@ -106,7 +106,7 @@ int main(int argc, char* const argv[]) if (optind < argc) { sp service = sm->checkService(String16(argv[optind])); aout << "Service " << argv[optind] << - (service == NULL ? ": not found" : ": found") << endl; + (service == nullptr ? ": not found" : ": found") << endl; } else { aerr << "service: No service specified for check" << endl; wantsUsage = true; @@ -131,7 +131,7 @@ int main(int argc, char* const argv[]) sp service = sm->checkService(String16(argv[optind++])); String16 ifName = get_interface_name(service); int32_t code = atoi(argv[optind++]); - if (service != NULL && ifName.size() > 0) { + if (service != nullptr && ifName.size() > 0) { Parcel data, reply; // the interface name is first @@ -186,28 +186,28 @@ int main(int argc, char* const argv[]) data.writeDouble(atof(argv[optind++])); } else if (strcmp(argv[optind], "null") == 0) { optind++; - data.writeStrongBinder(NULL); + data.writeStrongBinder(nullptr); } else if (strcmp(argv[optind], "intent") == 0) { - char* action = NULL; - char* dataArg = NULL; - char* type = NULL; + char* action = nullptr; + char* dataArg = nullptr; + char* type = nullptr; int launchFlags = 0; - char* component = NULL; + char* component = nullptr; int categoryCount = 0; char* categories[16]; - char* context1 = NULL; + char* context1 = nullptr; optind++; while (optind < argc) { char* key = strtok_r(argv[optind], "=", &context1); - char* value = strtok_r(NULL, "=", &context1); + char* value = strtok_r(nullptr, "=", &context1); // we have reached the end of the XXX=XXX args. - if (key == NULL) break; + if (key == nullptr) break; if (strcmp(key, "action") == 0) { @@ -231,14 +231,14 @@ int main(int argc, char* const argv[]) } else if (strcmp(key, "categories") == 0) { - char* context2 = NULL; + char* context2 = nullptr; int categoryCount = 0; categories[categoryCount] = strtok_r(value, ",", &context2); - while (categories[categoryCount] != NULL) + while (categories[categoryCount] != nullptr) { categoryCount++; - categories[categoryCount] = strtok_r(NULL, ",", &context2); + categories[categoryCount] = strtok_r(nullptr, ",", &context2); } } -- cgit v1.2.3-59-g8ed1b