Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning.
Test: m
Bug: 68236239
Change-Id: I226a0599db4f7c3557e55cade7869d00bd314949
diff --git a/server/ClatdController.cpp b/server/ClatdController.cpp
index 5ab5e72..5606d4d 100644
--- a/server/ClatdController.cpp
+++ b/server/ClatdController.cpp
@@ -99,7 +99,7 @@
netIdString,
(char *) "-m",
fwmarkString,
- NULL
+ nullptr
};
if (execv(kClatdPath, args)) {
@@ -127,7 +127,7 @@
ALOGD("Stopping clatd pid=%d on %s", pid, interface);
kill(pid, SIGTERM);
- waitpid(pid, NULL, 0);
+ waitpid(pid, nullptr, 0);
mClatdPids.erase(interface);
ALOGD("clatd on %s stopped", interface);
@@ -141,7 +141,7 @@
if (pid == 0) {
return false;
}
- waitpid_status = waitpid(pid, NULL, WNOHANG);
+ waitpid_status = waitpid(pid, nullptr, WNOHANG);
if (waitpid_status != 0) {
mClatdPids.erase(interface); // child exited, don't call waitpid on it again
}
diff --git a/server/CommandListener.cpp b/server/CommandListener.cpp
index 70302d9..27b117e 100644
--- a/server/CommandListener.cpp
+++ b/server/CommandListener.cpp
@@ -66,20 +66,20 @@
}
// OEM NetIds are "oem1", "oem2", .., "oem50".
if (!strncmp(arg, "oem", 3)) {
- unsigned n = strtoul(arg + 3, NULL, 0);
+ unsigned n = strtoul(arg + 3, nullptr, 0);
if (1 <= n && n <= NUM_OEM_IDS) {
return NetworkController::MIN_OEM_ID + n;
}
return NETID_UNSET;
} else if (!strncmp(arg, "handle", 6)) {
- unsigned n = netHandleToNetId((net_handle_t)strtoull(arg + 6, NULL, 10));
+ unsigned n = netHandleToNetId((net_handle_t)strtoull(arg + 6, nullptr, 10));
if (NetworkController::MIN_OEM_ID <= n && n <= NetworkController::MAX_OEM_ID) {
return n;
}
return NETID_UNSET;
}
// strtoul() returns 0 on errors, which is fine because 0 is an invalid netId.
- return strtoul(arg, NULL, 0);
+ return strtoul(arg, nullptr, 0);
}
class LockingFrameworkCommand : public FrameworkCommand {
@@ -188,7 +188,7 @@
asprintf(&flag_s, "%s%s%s%s%s%s", updown, brdcst, loopbk, ppp, running, multi);
- char *msg = NULL;
+ char *msg = nullptr;
asprintf(&msg, "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x %s %d %s",
hwaddr[0], hwaddr[1], hwaddr[2], hwaddr[3], hwaddr[4], hwaddr[5],
addr_s, prefixLength, flag_s);
@@ -361,7 +361,7 @@
// 0 1
// ipfwd status
if (!strcmp(argv[1], "status")) {
- char *tmp = NULL;
+ char *tmp = nullptr;
asprintf(&tmp, "Forwarding %s",
((gCtls->tetherCtrl.forwardingRequestCount() > 0) ? "enabled" : "disabled"));
@@ -425,7 +425,7 @@
if (!strcmp(argv[1], "stop")) {
rc = gCtls->tetherCtrl.stopTethering();
} else if (!strcmp(argv[1], "status")) {
- char *tmp = NULL;
+ char *tmp = nullptr;
asprintf(&tmp, "Tethering services %s",
(gCtls->tetherCtrl.isTetheringStarted() ? "started" : "stopped"));
@@ -1177,7 +1177,7 @@
if (!strcmp(argv[1], "stop")) {
rc = gCtls->clatdCtrl.stopClatd(argv[2]);
} else if (!strcmp(argv[1], "status")) {
- char *tmp = NULL;
+ char *tmp = nullptr;
asprintf(&tmp, "Clatd status: %s", (gCtls->clatdCtrl.isClatdStarted(argv[2]) ?
"started" : "stopped"));
cli->sendMsg(ResponseCode::ClatdStatusResult, tmp, false);
@@ -1249,7 +1249,7 @@
}
errno = 0;
- unsigned long int uid = strtoul(argv[2], NULL, 0);
+ unsigned long int uid = strtoul(argv[2], nullptr, 0);
if (errno || uid > UID_MAX) {
cli->sendMsg(ResponseCode::CommandSyntaxError, "Invalid UID", false);
return 0;
@@ -1310,7 +1310,7 @@
if (!strcmp(argv[nextArg], "legacy")) {
++nextArg;
legacy = true;
- uid = strtoul(argv[nextArg++], NULL, 0);
+ uid = strtoul(argv[nextArg++], nullptr, 0);
}
bool add = false;
@@ -1328,7 +1328,7 @@
unsigned netId = stringToNetId(argv[nextArg++]);
const char* interface = argv[nextArg++];
const char* destination = argv[nextArg++];
- const char* nexthop = argc > nextArg ? argv[nextArg] : NULL;
+ const char* nexthop = argc > nextArg ? argv[nextArg] : nullptr;
int ret;
if (add) {
@@ -1526,7 +1526,7 @@
}
std::vector<uid_t> uids;
for (int i = 3; i < argc; ++i) {
- uids.push_back(strtoul(argv[i], NULL, 0));
+ uids.push_back(strtoul(argv[i], nullptr, 0));
}
if (!strcmp(argv[2], "allow")) {
gCtls->netCtrl.allowProtect(uids);
diff --git a/server/DnsProxyListener.cpp b/server/DnsProxyListener.cpp
index bec7c1e..e8f186c 100644
--- a/server/DnsProxyListener.cpp
+++ b/server/DnsProxyListener.cpp
@@ -95,7 +95,7 @@
return;
}
- char* msg = NULL;
+ char* msg = nullptr;
asprintf(&msg, "%s (%d)", strerror(-rval), -rval);
cli->sendMsg(ResponseCode::OperationFailed, msg, false);
free(msg);
@@ -287,13 +287,13 @@
static bool sendhostent(SocketClient *c, struct hostent *hp) {
bool success = true;
int i;
- if (hp->h_name != NULL) {
+ if (hp->h_name != nullptr) {
success &= sendLenAndData(c, strlen(hp->h_name)+1, hp->h_name);
} else {
success &= sendLenAndData(c, 0, "") == 0;
}
- for (i=0; hp->h_aliases[i] != NULL; i++) {
+ for (i=0; hp->h_aliases[i] != nullptr; i++) {
success &= sendLenAndData(c, strlen(hp->h_aliases[i])+1, hp->h_aliases[i]);
}
success &= sendLenAndData(c, 0, ""); // null to indicate we're done
@@ -304,7 +304,7 @@
buf = htonl(hp->h_length);
success &= c->sendData(&buf, sizeof(buf)) == 0;
- for (i=0; hp->h_addr_list[i] != NULL; i++) {
+ for (i=0; hp->h_addr_list[i] != nullptr; i++) {
success &= sendLenAndData(c, 16, hp->h_addr_list[i]);
}
success &= sendLenAndData(c, 0, ""); // null to indicate we're done
@@ -355,7 +355,7 @@
mNetContext.uid, mNetContext.flags);
}
- struct addrinfo* result = NULL;
+ struct addrinfo* result = nullptr;
Stopwatch s;
maybeFixupNetContext(&mNetContext);
const uid_t uid = mClient->getUid();
@@ -449,7 +449,7 @@
if (DBG) logArguments(argc, argv);
if (argc != 8) {
- char* msg = NULL;
+ char* msg = nullptr;
asprintf( &msg, "Invalid number of arguments to getaddrinfo: %i", argc);
ALOGW("%s", msg);
cli->sendMsg(ResponseCode::CommandParameterError, msg, false);
@@ -459,24 +459,24 @@
char* name = argv[1];
if (strcmp("^", name) == 0) {
- name = NULL;
+ name = nullptr;
} else {
name = strdup(name);
}
char* service = argv[2];
if (strcmp("^", service) == 0) {
- service = NULL;
+ service = nullptr;
} else {
service = strdup(service);
}
- struct addrinfo* hints = NULL;
+ struct addrinfo* hints = nullptr;
int ai_flags = atoi(argv[3]);
int ai_family = atoi(argv[4]);
int ai_socktype = atoi(argv[5]);
int ai_protocol = atoi(argv[6]);
- unsigned netId = strtoul(argv[7], NULL, 10);
+ unsigned netId = strtoul(argv[7], nullptr, 10);
const bool useLocalNameservers = checkAndClearUseLocalNameserversFlag(&netId);
const uid_t uid = cli->getUid();
@@ -526,7 +526,7 @@
if (DBG) logArguments(argc, argv);
if (argc != 4) {
- char* msg = NULL;
+ char* msg = nullptr;
asprintf(&msg, "Invalid number of arguments to gethostbyname: %i", argc);
ALOGW("%s", msg);
cli->sendMsg(ResponseCode::CommandParameterError, msg, false);
@@ -535,13 +535,13 @@
}
uid_t uid = cli->getUid();
- unsigned netId = strtoul(argv[1], NULL, 10);
+ unsigned netId = strtoul(argv[1], nullptr, 10);
const bool useLocalNameservers = checkAndClearUseLocalNameserversFlag(&netId);
char* name = argv[2];
int af = atoi(argv[3]);
if (strcmp(name, "^") == 0) {
- name = NULL;
+ name = nullptr;
} else {
name = strdup(name);
}
@@ -605,7 +605,7 @@
success = mClient->sendCode(ResponseCode::DnsProxyQueryResult) == 0;
success &= sendhostent(mClient, hp);
} else {
- success = mClient->sendBinaryMsg(ResponseCode::DnsProxyOperationFailed, NULL, 0) == 0;
+ success = mClient->sendBinaryMsg(ResponseCode::DnsProxyOperationFailed, nullptr, 0) == 0;
}
if (!success) {
@@ -618,14 +618,14 @@
if (mReportingLevel == INetdEventListener::REPORTING_LEVEL_FULL) {
if (hp != nullptr && hp->h_addrtype == AF_INET) {
in_addr** list = (in_addr**) hp->h_addr_list;
- for (int i = 0; list[i] != NULL; i++) {
+ for (int i = 0; list[i] != nullptr; i++) {
sockaddr_in sin = { .sin_family = AF_INET, .sin_addr = *list[i] };
addIpAddrWithinLimit(ip_addrs, (sockaddr*) &sin, sizeof(sin));
total_ip_addr_count++;
}
} else if (hp != nullptr && hp->h_addrtype == AF_INET6) {
in6_addr** list = (in6_addr**) hp->h_addr_list;
- for (int i = 0; list[i] != NULL; i++) {
+ for (int i = 0; list[i] != nullptr; i++) {
sockaddr_in6 sin6 = { .sin6_family = AF_INET6, .sin6_addr = *list[i] };
addIpAddrWithinLimit(ip_addrs, (sockaddr*) &sin6, sizeof(sin6));
total_ip_addr_count++;
@@ -669,7 +669,7 @@
if (DBG) logArguments(argc, argv);
if (argc != 5) {
- char* msg = NULL;
+ char* msg = nullptr;
asprintf(&msg, "Invalid number of arguments to gethostbyaddr: %i", argc);
ALOGW("%s", msg);
cli->sendMsg(ResponseCode::CommandParameterError, msg, false);
@@ -681,14 +681,14 @@
int addrLen = atoi(argv[2]);
int addrFamily = atoi(argv[3]);
uid_t uid = cli->getUid();
- unsigned netId = strtoul(argv[4], NULL, 10);
+ unsigned netId = strtoul(argv[4], nullptr, 10);
const bool useLocalNameservers = checkAndClearUseLocalNameserversFlag(&netId);
void* addr = malloc(sizeof(struct in6_addr));
errno = 0;
int result = inet_pton(addrFamily, addrStr, addr);
if (result <= 0) {
- char* msg = NULL;
+ char* msg = nullptr;
asprintf(&msg, "inet_pton(\"%s\") failed %s", addrStr, strerror(errno));
ALOGW("%s", msg);
cli->sendMsg(ResponseCode::OperationFailed, msg, false);
@@ -754,7 +754,7 @@
success = mClient->sendCode(ResponseCode::DnsProxyQueryResult) == 0;
success &= sendhostent(mClient, hp);
} else {
- success = mClient->sendBinaryMsg(ResponseCode::DnsProxyOperationFailed, NULL, 0) == 0;
+ success = mClient->sendBinaryMsg(ResponseCode::DnsProxyOperationFailed, nullptr, 0) == 0;
}
if (!success) {
diff --git a/server/FwmarkServer.cpp b/server/FwmarkServer.cpp
index 0c22f26..dcbdb5d 100644
--- a/server/FwmarkServer.cpp
+++ b/server/FwmarkServer.cpp
@@ -249,7 +249,7 @@
netdEventListener->onConnectEvent(fwmark.netId, connectInfo.error,
connectInfo.latencyMs,
(ret == 0) ? String16(addrstr) : String16(""),
- (ret == 0) ? strtoul(portstr, NULL, 10) : 0, client->getUid());
+ (ret == 0) ? strtoul(portstr, nullptr, 10) : 0, client->getUid());
}
break;
}
diff --git a/server/InterfaceControllerTest.cpp b/server/InterfaceControllerTest.cpp
index 9f5c427..78d507f 100644
--- a/server/InterfaceControllerTest.cpp
+++ b/server/InterfaceControllerTest.cpp
@@ -183,7 +183,7 @@
EXPECT_EQ(ok, ifaceNames.status());
struct ifaddrs *ifaddr, *ifa;
EXPECT_EQ(0, getifaddrs(&ifaddr));
- for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
+ for (ifa = ifaddr; ifa != nullptr; ifa = ifa->ifa_next) {
const auto val = std::find(
ifaceNames.value().begin(), ifaceNames.value().end(), ifa->ifa_name);
EXPECT_NE(ifaceNames.value().end(), val);
@@ -196,7 +196,7 @@
EXPECT_EQ(ok, ifaceMap.status());
struct ifaddrs *ifaddr, *ifa;
EXPECT_EQ(0, getifaddrs(&ifaddr));
- for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
+ for (ifa = ifaddr; ifa != nullptr; ifa = ifa->ifa_next) {
uint32_t ifaceIndex = if_nametoindex(ifa->ifa_name);
const auto ifacePair = ifaceMap.value().find(ifa->ifa_name);
EXPECT_NE(ifaceMap.value().end(), ifacePair);
diff --git a/server/IptablesBaseTest.cpp b/server/IptablesBaseTest.cpp
index c81773b..b3748cd 100644
--- a/server/IptablesBaseTest.cpp
+++ b/server/IptablesBaseTest.cpp
@@ -41,7 +41,7 @@
int IptablesBaseTest::fake_android_fork_exec(int argc, char* argv[], int *status, bool, bool) {
std::string cmd = argv[0];
for (int i = 1; i < argc; i++) {
- if (argv[i] == NULL) break;
+ if (argv[i] == nullptr) break;
cmd += " ";
cmd += argv[i];
}
@@ -63,7 +63,7 @@
FILE *IptablesBaseTest::fake_popen(const char * /* cmd */, const char *type) {
if (sPopenContents.empty() || strcmp(type, "r") != 0) {
- return NULL;
+ return nullptr;
}
std::string realCmd = StringPrintf("echo '%s'", sPopenContents.front().c_str());
diff --git a/server/MDnsSdListener.cpp b/server/MDnsSdListener.cpp
index 2f29237..4f29106 100644
--- a/server/MDnsSdListener.cpp
+++ b/server/MDnsSdListener.cpp
@@ -71,7 +71,7 @@
}
Context *context = new Context(requestId, mListener);
DNSServiceRef *ref = mMonitor->allocateServiceRef(requestId, context);
- if (ref == NULL) {
+ if (ref == nullptr) {
ALOGE("requestId %d already in use during discover call", requestId);
cli->sendMsg(ResponseCode::CommandParameterError,
"RequestId already in use during discover call", false);
@@ -140,7 +140,7 @@
}
int requestId = atoi(argv[2]);
DNSServiceRef *ref = mMonitor->lookupServiceRef(requestId);
- if (ref == NULL) {
+ if (ref == nullptr) {
if (DBG) ALOGE("%s stop used unknown requestId %d", str, requestId);
cli->sendMsg(ResponseCode::CommandParameterError, "Unknown requestId", false);
return;
@@ -164,7 +164,7 @@
Context *context = new Context(requestId, mListener);
DNSServiceRef *ref = mMonitor->allocateServiceRef(requestId, context);
port = htons(port);
- if (ref == NULL) {
+ if (ref == nullptr) {
ALOGE("requestId %d already in use during register call", requestId);
cli->sendMsg(ResponseCode::CommandParameterError,
"RequestId already in use during register call", false);
@@ -219,7 +219,7 @@
}
Context *context = new Context(requestId, mListener);
DNSServiceRef *ref = mMonitor->allocateServiceRef(requestId, context);
- if (ref == NULL) {
+ if (ref == nullptr) {
ALOGE("request Id %d already in use during resolve call", requestId);
cli->sendMsg(ResponseCode::CommandParameterError,
"RequestId already in use during resolve call", false);
@@ -285,7 +285,7 @@
if (VDBG) ALOGD("getAddrInfo(%d, %s %d, %s)", requestId, interfaceName, protocol, hostname);
Context *context = new Context(requestId, mListener);
DNSServiceRef *ref = mMonitor->allocateServiceRef(requestId, context);
- if (ref == NULL) {
+ if (ref == nullptr) {
ALOGE("request ID %d already in use during getAddrInfo call", requestId);
cli->sendMsg(ResponseCode::CommandParameterError,
"RequestId already in use during getAddrInfo call", false);
@@ -345,7 +345,7 @@
if (VDBG) ALOGD("setHostname(%d, %s)", requestId, hostname);
Context *context = new Context(requestId, mListener);
DNSServiceRef *ref = mMonitor->allocateServiceRef(requestId, context);
- if (ref == NULL) {
+ if (ref == nullptr) {
ALOGE("request Id %d already in use during setHostname call", requestId);
cli->sendMsg(ResponseCode::CommandParameterError,
"RequestId already in use during setHostname call", false);
@@ -392,7 +392,7 @@
}
const char *MDnsSdListener::Handler::iToIfaceName(int /* i */) {
- return NULL;
+ return nullptr;
}
DNSServiceFlags MDnsSdListener::Handler::iToFlags(int /* i */) {
@@ -406,7 +406,7 @@
int MDnsSdListener::Handler::runCommand(SocketClient *cli,
int argc, char **argv) {
if (argc < 2) {
- char* msg = NULL;
+ char* msg = nullptr;
asprintf( &msg, "Invalid number of arguments to mdnssd: %i", argc);
ALOGW("%s", msg);
cli->sendMsg(ResponseCode::CommandParameterError, msg, false);
@@ -425,7 +425,7 @@
int requestId = atoi(argv[2]);
char *serviceType = argv[3];
- discover(cli, NULL, serviceType, NULL, requestId, 0);
+ discover(cli, nullptr, serviceType, nullptr, requestId, 0);
} else if (strcmp(cmd, "stop-discover") == 0) {
stop(cli, argc, argv, "discover");
} else if (strcmp(cmd, "register") == 0) {
@@ -438,9 +438,9 @@
char *serviceName = argv[3];
char *serviceType = argv[4];
int port = atoi(argv[5]);
- char *interfaceName = NULL; // will use all
- char *domain = NULL; // will use default
- char *host = NULL; // will use default hostname
+ char *interfaceName = nullptr; // will use all
+ char *domain = nullptr; // will use default
+ char *host = nullptr; // will use default hostname
// TXT record length is <= 1300, see NsdServiceInfo.setAttribute
char dst[1300];
@@ -464,7 +464,7 @@
return 0;
}
int requestId = atoi(argv[2]);
- char *interfaceName = NULL; // will use all
+ char *interfaceName = nullptr; // will use all
char *serviceName = argv[3];
char *regType = argv[4];
char *domain = argv[5];
@@ -502,7 +502,7 @@
}
int requestId = atoi(argv[2]);
char *hostname = argv[3];
- char *interfaceName = NULL; // default
+ char *interfaceName = nullptr; // default
int protocol = 0; // intelligient heuristic (both v4 + v6)
getAddrInfo(cli, requestId, interfaceName, protocol, hostname);
} else if (strcmp(cmd, "stop-getaddrinfo") == 0) {
@@ -516,13 +516,13 @@
}
MDnsSdListener::Monitor::Monitor() {
- mHead = NULL;
+ mHead = nullptr;
mLiveCount = 0;
- mPollFds = NULL;
- mPollRefs = NULL;
+ mPollFds = nullptr;
+ mPollRefs = nullptr;
mPollSize = 10;
socketpair(AF_LOCAL, SOCK_STREAM, 0, mCtrlSocketPair);
- pthread_mutex_init(&mHeadMutex, NULL);
+ pthread_mutex_init(&mHeadMutex, nullptr);
const int rval = ::android::net::threadLaunch(this);
if (rval != 0) {
@@ -542,8 +542,8 @@
while (maxnaps-- > 0) {
usleep(NAP_TIME * 1000);
- if (property_get(name, value, NULL)) {
- if (desired_value == NULL || strcmp(value, desired_value) == 0) {
+ if (property_get(name, value, nullptr)) {
+ if (desired_value == nullptr || strcmp(value, desired_value) == 0) {
return 0;
}
}
@@ -571,7 +571,7 @@
int MDnsSdListener::Monitor::stopService() {
int result = 0;
pthread_mutex_lock(&mHeadMutex);
- if (mHead == NULL) {
+ if (mHead == nullptr) {
ALOGD("Stopping MDNSD");
property_set("ctl.stop", MDNS_SERVICE_NAME);
wait_for_property(MDNS_SERVICE_STATUS, "stopped", 5);
@@ -588,9 +588,9 @@
mPollFds = (struct pollfd *)calloc(sizeof(struct pollfd), mPollSize);
mPollRefs = (DNSServiceRef **)calloc(sizeof(DNSServiceRef *), mPollSize);
- LOG_ALWAYS_FATAL_IF((mPollFds == NULL), "initial calloc failed on mPollFds with a size of %d",
+ LOG_ALWAYS_FATAL_IF((mPollFds == nullptr), "initial calloc failed on mPollFds with a size of %d",
((int)sizeof(struct pollfd)) * mPollSize);
- LOG_ALWAYS_FATAL_IF((mPollRefs == NULL), "initial calloc failed on mPollRefs with a size of %d",
+ LOG_ALWAYS_FATAL_IF((mPollRefs == nullptr), "initial calloc failed on mPollRefs with a size of %d",
((int)sizeof(DNSServiceRef *)) * mPollSize);
mPollFds[0].fd = mCtrlSocketPair[0];
@@ -650,9 +650,9 @@
free(mPollRefs);
mPollFds = (struct pollfd *)calloc(sizeof(struct pollfd), mPollSize);
mPollRefs = (DNSServiceRef **)calloc(sizeof(DNSServiceRef *), mPollSize);
- LOG_ALWAYS_FATAL_IF((mPollFds == NULL), "calloc failed on mPollFds with a size of %d",
+ LOG_ALWAYS_FATAL_IF((mPollFds == nullptr), "calloc failed on mPollFds with a size of %d",
((int)sizeof(struct pollfd)) * mPollSize);
- LOG_ALWAYS_FATAL_IF((mPollRefs == NULL), "calloc failed on mPollRefs with a size of %d",
+ LOG_ALWAYS_FATAL_IF((mPollRefs == nullptr), "calloc failed on mPollRefs with a size of %d",
((int)sizeof(DNSServiceRef *)) * mPollSize);
} else {
memset(mPollFds, 0, sizeof(struct pollfd) * mPollSize);
@@ -661,7 +661,7 @@
mPollFds[0].fd = mCtrlSocketPair[0];
mPollFds[0].events = POLLIN;
if (DBG_RESCAN) ALOGD("mHead = %p", mHead);
- while (*prevPtr != NULL) {
+ while (*prevPtr != nullptr) {
if (DBG_RESCAN) ALOGD("checking %p, mReady = %d", *prevPtr, (*prevPtr)->mReady);
if ((*prevPtr)->mReady == 1) {
int fd = DNSServiceRefSockFD((*prevPtr)->mRef);
@@ -691,9 +691,9 @@
}
DNSServiceRef *MDnsSdListener::Monitor::allocateServiceRef(int id, Context *context) {
- if (lookupServiceRef(id) != NULL) {
+ if (lookupServiceRef(id) != nullptr) {
delete(context);
- return NULL;
+ return nullptr;
}
Element *e = new Element(id, context);
pthread_mutex_lock(&mHeadMutex);
@@ -706,7 +706,7 @@
DNSServiceRef *MDnsSdListener::Monitor::lookupServiceRef(int id) {
pthread_mutex_lock(&mHeadMutex);
Element *cur = mHead;
- while (cur != NULL) {
+ while (cur != nullptr) {
if (cur->mId == id) {
DNSServiceRef *result = &(cur->mRef);
pthread_mutex_unlock(&mHeadMutex);
@@ -715,14 +715,14 @@
cur = cur->mNext;
}
pthread_mutex_unlock(&mHeadMutex);
- return NULL;
+ return nullptr;
}
void MDnsSdListener::Monitor::startMonitoring(int id) {
if (VDBG) ALOGD("startMonitoring %d", id);
pthread_mutex_lock(&mHeadMutex);
Element *cur = mHead;
- while (cur != NULL) {
+ while (cur != nullptr) {
if (cur->mId == id) {
if (DBG_RESCAN) ALOGD("marking %p as ready to be added", cur);
mLiveCount++;
@@ -742,14 +742,14 @@
pthread_mutex_lock(&mHeadMutex);
Element **prevPtr = &mHead;
Element *cur;
- while (*prevPtr != NULL) {
+ while (*prevPtr != nullptr) {
cur = *prevPtr;
if (cur->mId == id) {
if (DBG_RESCAN) ALOGD("marking %p as ready to be removed", cur);
mLiveCount--;
if (cur->mReady == 1) {
cur->mReady = -1; // tell poll thread to delete
- cur->mRef = NULL; // do not process further results
+ cur->mRef = nullptr; // do not process further results
write(mCtrlSocketPair[1], RESCAN, 1); // trigger a rescan for a fresh poll
if (VDBG) ALOGD("triggering rescan");
} else {
diff --git a/server/MDnsSdListener.h b/server/MDnsSdListener.h
index 8cd596a..bdf5d0c 100644
--- a/server/MDnsSdListener.h
+++ b/server/MDnsSdListener.h
@@ -90,7 +90,7 @@
Context *mContext;
int mReady;
Element(int id, Context *context)
- : mId(id), mNext(NULL), mContext(context), mReady(0) {}
+ : mId(id), mNext(nullptr), mContext(context), mReady(0) {}
virtual ~Element() { delete(mContext); }
};
Element *mHead;
diff --git a/server/NetdConstants.cpp b/server/NetdConstants.cpp
index 2f0500f..0754275 100644
--- a/server/NetdConstants.cpp
+++ b/server/NetdConstants.cpp
@@ -111,7 +111,7 @@
addrinfo hints = {
.ai_flags = AI_NUMERICHOST,
};
- int ret = getaddrinfo(addressString.c_str(), NULL, &hints, &res);
+ int ret = getaddrinfo(addressString.c_str(), nullptr, &hints, &res);
if (ret || !res) {
return -EINVAL; // getaddrinfo return values are not errno values.
}
@@ -161,7 +161,7 @@
sigemptyset(&mask);
sigaddset(&mask, SIGPIPE);
- if (sigprocmask(SIG_BLOCK, &mask, NULL) != 0)
+ if (sigprocmask(SIG_BLOCK, &mask, nullptr) != 0)
ALOGW("WARNING: SIGPIPE not blocked\n");
}
diff --git a/server/NetdNativeService.cpp b/server/NetdNativeService.cpp
index 99c4452..12c78ef 100644
--- a/server/NetdNativeService.cpp
+++ b/server/NetdNativeService.cpp
@@ -70,7 +70,7 @@
#define ENFORCE_DEBUGGABLE() { \
char value[PROPERTY_VALUE_MAX + 1]; \
- if (property_get("ro.debuggable", value, NULL) != 1 \
+ if (property_get("ro.debuggable", value, nullptr) != 1 \
|| value[0] != '1') { \
return binder::Status::fromExceptionCode( \
binder::Status::EX_SECURITY, \
diff --git a/server/NetlinkCommands.cpp b/server/NetlinkCommands.cpp
index 4e940d4..473cac0 100644
--- a/server/NetlinkCommands.cpp
+++ b/server/NetlinkCommands.cpp
@@ -185,7 +185,7 @@
.rtm_family = static_cast<uint8_t>(family),
};
iovec iov[] = {
- { NULL, 0 },
+ { nullptr, 0 },
{ &rule, sizeof(rule) },
};
uint16_t flags = NETLINK_DUMP_FLAGS;
diff --git a/server/NetlinkHandler.cpp b/server/NetlinkHandler.cpp
index 0b84c8c..85fbe17 100644
--- a/server/NetlinkHandler.cpp
+++ b/server/NetlinkHandler.cpp
@@ -59,7 +59,7 @@
if (ifIndex == nullptr) {
return 0;
}
- long ifaceIndex = strtol(ifIndex, NULL, 10);
+ long ifaceIndex = strtol(ifIndex, nullptr, 10);
// strtol returns 0 on error, which is fine because 0 is not a valid ifindex.
if (errno == ERANGE && (ifaceIndex == LONG_MAX || ifaceIndex == LONG_MIN)) {
return 0;
@@ -220,10 +220,10 @@
bool isActive,
const char *timestamp,
const char *uid) {
- if (timestamp == NULL)
+ if (timestamp == nullptr)
notify(ResponseCode::InterfaceClassActivity,
"IfaceClass %s %s", isActive ? "active" : "idle", name);
- else if (uid != NULL && isActive)
+ else if (uid != nullptr && isActive)
notify(ResponseCode::InterfaceClassActivity,
"IfaceClass active %s %s %s", name, timestamp, uid);
else
diff --git a/server/NetlinkManager.cpp b/server/NetlinkManager.cpp
index 0f34842..e8c7491 100644
--- a/server/NetlinkManager.cpp
+++ b/server/NetlinkManager.cpp
@@ -48,7 +48,7 @@
const int NetlinkManager::NETFILTER_STRICT_GROUP = 2;
const int NetlinkManager::NFLOG_WAKEUP_GROUP = 3;
-NetlinkManager *NetlinkManager::sInstance = NULL;
+NetlinkManager *NetlinkManager::sInstance = nullptr;
NetlinkManager *NetlinkManager::Instance() {
if (!sInstance)
@@ -57,7 +57,7 @@
}
NetlinkManager::NetlinkManager() {
- mBroadcaster = NULL;
+ mBroadcaster = nullptr;
}
NetlinkManager::~NetlinkManager() {
@@ -78,7 +78,7 @@
if ((*sock = socket(PF_NETLINK, SOCK_DGRAM | SOCK_CLOEXEC, netlinkFamily)) < 0) {
ALOGE("Unable to create netlink socket: %s", strerror(errno));
- return NULL;
+ return nullptr;
}
// When running in a net/user namespace, SO_RCVBUFFORCE will fail because
@@ -88,33 +88,33 @@
setsockopt(*sock, SOL_SOCKET, SO_RCVBUF, &sz, sizeof(sz)) < 0) {
ALOGE("Unable to set uevent socket SO_RCVBUF option: %s", strerror(errno));
close(*sock);
- return NULL;
+ return nullptr;
}
if (setsockopt(*sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)) < 0) {
SLOGE("Unable to set uevent socket SO_PASSCRED option: %s", strerror(errno));
close(*sock);
- return NULL;
+ return nullptr;
}
if (bind(*sock, (struct sockaddr *) &nladdr, sizeof(nladdr)) < 0) {
ALOGE("Unable to bind netlink socket: %s", strerror(errno));
close(*sock);
- return NULL;
+ return nullptr;
}
if (configNflog) {
if (android_nflog_send_config_cmd(*sock, 0, NFULNL_CFG_CMD_PF_UNBIND, AF_INET) < 0) {
ALOGE("Failed NFULNL_CFG_CMD_PF_UNBIND: %s", strerror(errno));
- return NULL;
+ return nullptr;
}
if (android_nflog_send_config_cmd(*sock, 0, NFULNL_CFG_CMD_PF_BIND, AF_INET) < 0) {
ALOGE("Failed NFULNL_CFG_CMD_PF_BIND: %s", strerror(errno));
- return NULL;
+ return nullptr;
}
if (android_nflog_send_config_cmd(*sock, 0, NFULNL_CFG_CMD_BIND, AF_UNSPEC) < 0) {
ALOGE("Failed NFULNL_CFG_CMD_BIND: %s", strerror(errno));
- return NULL;
+ return nullptr;
}
}
@@ -122,7 +122,7 @@
if (handler->start()) {
ALOGE("Unable to start NetlinkHandler: %s", strerror(errno));
close(*sock);
- return NULL;
+ return nullptr;
}
return handler;
@@ -130,7 +130,7 @@
int NetlinkManager::start() {
if ((mUeventHandler = setupSocket(&mUeventSock, NETLINK_KOBJECT_UEVENT,
- 0xffffffff, NetlinkListener::NETLINK_FORMAT_ASCII, false)) == NULL) {
+ 0xffffffff, NetlinkListener::NETLINK_FORMAT_ASCII, false)) == nullptr) {
return -1;
}
@@ -140,18 +140,18 @@
RTMGRP_IPV6_IFADDR |
RTMGRP_IPV6_ROUTE |
(1 << (RTNLGRP_ND_USEROPT - 1)),
- NetlinkListener::NETLINK_FORMAT_BINARY, false)) == NULL) {
+ NetlinkListener::NETLINK_FORMAT_BINARY, false)) == nullptr) {
return -1;
}
if ((mQuotaHandler = setupSocket(&mQuotaSock, NETLINK_NFLOG,
- NFLOG_QUOTA_GROUP, NetlinkListener::NETLINK_FORMAT_BINARY, false)) == NULL) {
+ NFLOG_QUOTA_GROUP, NetlinkListener::NETLINK_FORMAT_BINARY, false)) == nullptr) {
ALOGW("Unable to open qlog quota socket, check if xt_quota2 can send via UeventHandler");
// TODO: return -1 once the emulator gets a new kernel.
}
if ((mStrictHandler = setupSocket(&mStrictSock, NETLINK_NETFILTER,
- 0, NetlinkListener::NETLINK_FORMAT_BINARY_UNICAST, true)) == NULL) {
+ 0, NetlinkListener::NETLINK_FORMAT_BINARY_UNICAST, true)) == nullptr) {
ALOGE("Unable to open strict socket");
// TODO: return -1 once the emulator gets a new kernel.
}
@@ -168,7 +168,7 @@
}
delete mUeventHandler;
- mUeventHandler = NULL;
+ mUeventHandler = nullptr;
close(mUeventSock);
mUeventSock = -1;
@@ -179,7 +179,7 @@
}
delete mRouteHandler;
- mRouteHandler = NULL;
+ mRouteHandler = nullptr;
close(mRouteSock);
mRouteSock = -1;
@@ -191,7 +191,7 @@
}
delete mQuotaHandler;
- mQuotaHandler = NULL;
+ mQuotaHandler = nullptr;
close(mQuotaSock);
mQuotaSock = -1;
@@ -204,7 +204,7 @@
}
delete mStrictHandler;
- mStrictHandler = NULL;
+ mStrictHandler = nullptr;
close(mStrictSock);
mStrictSock = -1;
diff --git a/server/NetworkController.cpp b/server/NetworkController.cpp
index 7e22ad2..b722c76 100644
--- a/server/NetworkController.cpp
+++ b/server/NetworkController.cpp
@@ -387,7 +387,7 @@
}
int NetworkController::createPhysicalOemNetwork(Permission permission, unsigned *pNetId) {
- if (pNetId == NULL) {
+ if (pNetId == nullptr) {
return -EINVAL;
}
@@ -731,7 +731,7 @@
Network* NetworkController::getNetworkLocked(unsigned netId) const {
auto iter = mNetworks.find(netId);
- return iter == mNetworks.end() ? NULL : iter->second;
+ return iter == mNetworks.end() ? nullptr : iter->second;
}
VirtualNetwork* NetworkController::getVirtualNetworkForUserLocked(uid_t uid) const {
@@ -743,7 +743,7 @@
}
}
}
- return NULL;
+ return nullptr;
}
Permission NetworkController::getPermissionForUserLocked(uid_t uid) const {
diff --git a/server/PppController.cpp b/server/PppController.cpp
index 19b50cb..80a36e9 100644
--- a/server/PppController.cpp
+++ b/server/PppController.cpp
@@ -93,7 +93,7 @@
// TODO: Deal with pppd bailing out after 99999 seconds of being started
// but not getting a connection
if (execl("/system/bin/pppd", "/system/bin/pppd", "-detach", dev, "115200",
- lr, "ms-dns", d1, "ms-dns", d2, "lcp-max-configure", "99999", (char *) NULL)) {
+ lr, "ms-dns", d1, "ms-dns", d2, "lcp-max-configure", "99999", (char *) nullptr)) {
ALOGE("execl failed (%s)", strerror(errno));
}
free(lr);
@@ -116,7 +116,7 @@
ALOGD("Stopping PPPD services on port %s", tty);
kill(mPid, SIGTERM);
- waitpid(mPid, NULL, 0);
+ waitpid(mPid, nullptr, 0);
mPid = 0;
ALOGD("PPPD services on port %s stopped", tty);
return 0;
diff --git a/server/Process.cpp b/server/Process.cpp
index f5f1a3d..1890620 100644
--- a/server/Process.cpp
+++ b/server/Process.cpp
@@ -83,7 +83,7 @@
sigemptyset(&mask);
sigaddset(&mask, SIGPIPE);
- if (sigprocmask(SIG_BLOCK, &mask, NULL) != 0) {
+ if (sigprocmask(SIG_BLOCK, &mask, nullptr) != 0) {
ALOGW("WARNING: SIGPIPE not blocked\n");
}
}
diff --git a/server/ResolverController.cpp b/server/ResolverController.cpp
index 24f26bb..c6ac659 100644
--- a/server/ResolverController.cpp
+++ b/server/ResolverController.cpp
@@ -63,7 +63,7 @@
std::string addrToString(const sockaddr_storage* addr) {
char out[INET6_ADDRSTRLEN] = {0};
getnameinfo((const sockaddr*)addr, sizeof(sockaddr_storage), out,
- INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST);
+ INET6_ADDRSTRLEN, nullptr, 0, NI_NUMERICHOST);
return std::string(out);
}
@@ -402,7 +402,7 @@
}
int ResolverController::clearDnsServers(unsigned netId) {
- _resolv_set_nameservers_for_net(netId, NULL, 0, "", NULL);
+ _resolv_set_nameservers_for_net(netId, nullptr, 0, "", nullptr);
if (DBG) {
ALOGD("clearDnsServers netId = %u\n", netId);
}
diff --git a/server/RouteController.cpp b/server/RouteController.cpp
index cdf3c80..16947af 100644
--- a/server/RouteController.cpp
+++ b/server/RouteController.cpp
@@ -92,8 +92,8 @@
const uint32_t FWMARK_NONE = 0;
const uint32_t MASK_NONE = 0;
const char* const IIF_LOOPBACK = "lo";
-const char* const IIF_NONE = NULL;
-const char* const OIF_NONE = NULL;
+const char* const IIF_NONE = nullptr;
+const char* const OIF_NONE = nullptr;
const bool ACTION_ADD = true;
const bool ACTION_DEL = false;
const bool MODIFY_NON_UID_BASED_RULES = true;
@@ -279,7 +279,7 @@
struct fib_rule_uid_range uidRange = { uidStart, uidEnd };
iovec iov[] = {
- { NULL, 0 },
+ { nullptr, 0 },
{ &rule, sizeof(rule) },
{ &FRATTR_PRIORITY, sizeof(FRATTR_PRIORITY) },
{ &priority, sizeof(priority) },
@@ -365,11 +365,11 @@
// the table number. But it's an error to specify an interface ("dev ...") or a nexthop for
// unreachable routes, so nuke them. (IPv6 allows them to be specified; IPv4 doesn't.)
interface = OIF_NONE;
- nexthop = NULL;
+ nexthop = nullptr;
} else if (nexthop && !strcmp(nexthop, "throw")) {
type = RTN_THROW;
interface = OIF_NONE;
- nexthop = NULL;
+ nexthop = nullptr;
} else {
// If an interface was specified, find the ifindex.
if (interface != OIF_NONE) {
@@ -402,7 +402,7 @@
rtattr rtaGateway = { U16_RTA_LENGTH(rawLength), RTA_GATEWAY };
iovec iov[] = {
- { NULL, 0 },
+ { nullptr, 0 },
{ &route, sizeof(route) },
{ &RTATTR_TABLE, sizeof(RTATTR_TABLE) },
{ &table, sizeof(table) },
@@ -686,11 +686,11 @@
return ret;
}
- if ((ret = modifyIpRoute(RTM_NEWROUTE, table, interface, "0.0.0.0/0", NULL))) {
+ if ((ret = modifyIpRoute(RTM_NEWROUTE, table, interface, "0.0.0.0/0", nullptr))) {
return ret;
}
- if ((ret = modifyIpRoute(RTM_NEWROUTE, table, interface, "::/0", NULL))) {
+ if ((ret = modifyIpRoute(RTM_NEWROUTE, table, interface, "::/0", nullptr))) {
return ret;
}
diff --git a/server/RouteControllerTest.cpp b/server/RouteControllerTest.cpp
index b6e648a..20b3618 100644
--- a/server/RouteControllerTest.cpp
+++ b/server/RouteControllerTest.cpp
@@ -79,18 +79,18 @@
static_assert(table2 < RouteController::ROUTE_TABLE_OFFSET_FROM_INDEX,
"Test table2 number too large");
- EXPECT_EQ(0, modifyIpRoute(RTM_NEWROUTE, table1, "lo", "192.0.2.2/32", NULL));
- EXPECT_EQ(0, modifyIpRoute(RTM_NEWROUTE, table1, "lo", "192.0.2.3/32", NULL));
- EXPECT_EQ(0, modifyIpRoute(RTM_NEWROUTE, table2, "lo", "192.0.2.4/32", NULL));
+ EXPECT_EQ(0, modifyIpRoute(RTM_NEWROUTE, table1, "lo", "192.0.2.2/32", nullptr));
+ EXPECT_EQ(0, modifyIpRoute(RTM_NEWROUTE, table1, "lo", "192.0.2.3/32", nullptr));
+ EXPECT_EQ(0, modifyIpRoute(RTM_NEWROUTE, table2, "lo", "192.0.2.4/32", nullptr));
EXPECT_EQ(0, flushRoutes(table1));
EXPECT_EQ(-ESRCH,
- modifyIpRoute(RTM_DELROUTE, table1, "lo", "192.0.2.2/32", NULL));
+ modifyIpRoute(RTM_DELROUTE, table1, "lo", "192.0.2.2/32", nullptr));
EXPECT_EQ(-ESRCH,
- modifyIpRoute(RTM_DELROUTE, table1, "lo", "192.0.2.3/32", NULL));
+ modifyIpRoute(RTM_DELROUTE, table1, "lo", "192.0.2.3/32", nullptr));
EXPECT_EQ(0,
- modifyIpRoute(RTM_DELROUTE, table2, "lo", "192.0.2.4/32", NULL));
+ modifyIpRoute(RTM_DELROUTE, table2, "lo", "192.0.2.4/32", nullptr));
}
TEST_F(RouteControllerTest, TestModifyIncomingPacketMark) {
diff --git a/server/SockDiagTest.cpp b/server/SockDiagTest.cpp
index a263fea..312f2c8 100644
--- a/server/SockDiagTest.cpp
+++ b/server/SockDiagTest.cpp
@@ -215,8 +215,8 @@
inet_diag_msg makeDiagMessage(const char* srcstr, const char* dststr) {
addrinfo hints = { .ai_flags = AI_NUMERICHOST }, *src, *dst;
- EXPECT_EQ(0, getaddrinfo(srcstr, NULL, &hints, &src));
- EXPECT_EQ(0, getaddrinfo(dststr, NULL, &hints, &dst));
+ EXPECT_EQ(0, getaddrinfo(srcstr, nullptr, &hints, &src));
+ EXPECT_EQ(0, getaddrinfo(dststr, nullptr, &hints, &dst));
EXPECT_EQ(src->ai_addr->sa_family, dst->ai_addr->sa_family);
inet_diag_msg msg = makeDiagMessage(src->ai_addr->sa_family, src->ai_addr, dst->ai_addr);
freeaddrinfo(src);
diff --git a/server/TetherController.cpp b/server/TetherController.cpp
index dbda38a..857ac99 100644
--- a/server/TetherController.cpp
+++ b/server/TetherController.cpp
@@ -286,7 +286,7 @@
ALOGD("Stopping tethering services");
kill(mDaemonPid, SIGTERM);
- waitpid(mDaemonPid, NULL, 0);
+ waitpid(mDaemonPid, nullptr, 0);
mDaemonPid = 0;
close(mDaemonFd);
mDaemonFd = -1;
@@ -320,7 +320,7 @@
ALOGD("setDnsForwarders(0x%x %d = '%s')", fwmark.intValue, i, servers[i]);
addrinfo *res, hints = { .ai_flags = AI_NUMERICHOST };
- int ret = getaddrinfo(servers[i], NULL, &hints, &res);
+ int ret = getaddrinfo(servers[i], nullptr, &hints, &res);
freeaddrinfo(res);
if (ret) {
ALOGE("Failed to parse DNS server '%s'", servers[i]);
diff --git a/server/XfrmController.cpp b/server/XfrmController.cpp
index e7e74da..b8d4e07 100644
--- a/server/XfrmController.cpp
+++ b/server/XfrmController.cpp
@@ -164,7 +164,7 @@
void logIov(const std::vector<iovec>& iov) {
for (const iovec& row : iov) {
- logHex(0, reinterpret_cast<char*>(row.iov_base), row.iov_len);
+ logHex(nullptr, reinterpret_cast<char*>(row.iov_base), row.iov_len);
}
}
@@ -408,7 +408,7 @@
netdutils::Status XfrmController::flushSaDb(const XfrmSocket& s) {
struct xfrm_usersa_flush flushUserSa = {.proto = IPSEC_PROTO_ANY};
- std::vector<iovec> iov = {{NULL, 0}, // reserved for the eventual addition of a NLMSG_HDR
+ std::vector<iovec> iov = {{nullptr, 0}, // reserved for the eventual addition of a NLMSG_HDR
{&flushUserSa, sizeof(flushUserSa)}, // xfrm_usersa_flush structure
{kPadBytes, NLMSG_ALIGN(sizeof(flushUserSa)) - sizeof(flushUserSa)}};
@@ -416,7 +416,7 @@
}
netdutils::Status XfrmController::flushPolicyDb(const XfrmSocket& s) {
- std::vector<iovec> iov = {{NULL, 0}}; // reserved for the eventual addition of a NLMSG_HDR
+ std::vector<iovec> iov = {{nullptr, 0}}; // reserved for the eventual addition of a NLMSG_HDR
return s.sendMessage(XFRM_MSG_FLUSHPOLICY, NETLINK_REQUEST_FLAGS, 0, &iov);
}
@@ -736,7 +736,7 @@
// Kernel will delete the security policy on this socket for both direction
// if optval is set to NULL and optlen is set to 0.
netdutils::Status status =
- getSyscallInstance().setsockopt(Fd(socket), sockLayer, sockOpt, NULL, 0);
+ getSyscallInstance().setsockopt(Fd(socket), sockLayer, sockOpt, nullptr, 0);
if (!isOk(status)) {
ALOGE("Error removing socket option for XFRM! (%s)", toString(status).c_str());
}
@@ -837,7 +837,7 @@
};
std::vector<iovec> iov = {
- {NULL, 0}, // reserved for the eventual addition of a NLMSG_HDR
+ {nullptr, 0}, // reserved for the eventual addition of a NLMSG_HDR
{&usersa, 0}, // main usersa_info struct
{kPadBytes, 0}, // up to NLMSG_ALIGNTO pad bytes of padding
{&crypt, 0}, // adjust size if crypt algo is present
@@ -1002,7 +1002,7 @@
enum { NLMSG_HDR, USERSAID, USERSAID_PAD, MARK, MARK_PAD };
std::vector<iovec> iov = {
- {NULL, 0}, // reserved for the eventual addition of a NLMSG_HDR
+ {nullptr, 0}, // reserved for the eventual addition of a NLMSG_HDR
{&said, 0}, // main usersa_info struct
{kPadBytes, 0}, // up to NLMSG_ALIGNTO pad bytes of padding
{&xfrmmark, 0}, // adjust size if xfrm mark is present
@@ -1027,7 +1027,7 @@
enum { NLMSG_HDR, USERSAID, USERSAID_PAD };
std::vector<iovec> iov = {
- {NULL, 0}, // reserved for the eventual addition of a NLMSG_HDR
+ {nullptr, 0}, // reserved for the eventual addition of a NLMSG_HDR
{&spiInfo, 0}, // main userspi_info struct
{kPadBytes, 0}, // up to NLMSG_ALIGNTO pad bytes of padding
};
@@ -1086,7 +1086,7 @@
};
std::vector<iovec> iov = {
- {NULL, 0}, // reserved for the eventual addition of a NLMSG_HDR
+ {nullptr, 0}, // reserved for the eventual addition of a NLMSG_HDR
{&userpolicy, 0}, // main xfrm_userpolicy_info struct
{kPadBytes, 0}, // up to NLMSG_ALIGNTO pad bytes of padding
{&usertmpl, 0}, // adjust size if xfrm_user_tmpl struct is present
@@ -1123,7 +1123,7 @@
};
std::vector<iovec> iov = {
- {NULL, 0}, // reserved for the eventual addition of a NLMSG_HDR
+ {nullptr, 0}, // reserved for the eventual addition of a NLMSG_HDR
{&policyid, 0}, // main xfrm_userpolicy_id struct
{kPadBytes, 0}, // up to NLMSG_ALIGNTO pad bytes of padding
{&xfrmmark, 0}, // adjust size if xfrm mark is present
@@ -1309,7 +1309,7 @@
&iflaLinkInfo);
iovec iov[] = {
- {NULL, 0},
+ {nullptr, 0},
{&ifInfoMsg, sizeof(ifInfoMsg)},
{&iflaIfName, sizeof(iflaIfName)},
@@ -1379,7 +1379,7 @@
size_t iflaIfNamePad = fillNlAttr(IFLA_IFNAME, iflaIfNameLength, &iflaIfName);
iovec iov[] = {
- {NULL, 0},
+ {nullptr, 0},
{&ifInfoMsg, sizeof(ifInfoMsg)},
{&iflaIfName, sizeof(iflaIfName)},
diff --git a/server/dns/DnsTlsSocket.cpp b/server/dns/DnsTlsSocket.cpp
index ca1cdc9..8e25b1f 100644
--- a/server/dns/DnsTlsSocket.cpp
+++ b/server/dns/DnsTlsSocket.cpp
@@ -108,7 +108,7 @@
}
bool getSPKIDigest(const X509* cert, std::vector<uint8_t>* out) {
- int spki_len = i2d_X509_PUBKEY(X509_get_X509_PUBKEY(cert), NULL);
+ int spki_len = i2d_X509_PUBKEY(X509_get_X509_PUBKEY(cert), nullptr);
unsigned char spki[spki_len];
unsigned char* temp = spki;
if (spki_len != i2d_X509_PUBKEY(X509_get_X509_PUBKEY(cert), &temp)) {
@@ -117,7 +117,7 @@
}
out->resize(SHA256_SIZE);
unsigned int digest_len = 0;
- int ret = EVP_Digest(spki, spki_len, out->data(), &digest_len, EVP_sha256(), NULL);
+ int ret = EVP_Digest(spki, spki_len, out->data(), &digest_len, EVP_sha256(), nullptr);
if (ret != 1) {
ALOGW("Server cert digest extraction failed");
return false;
diff --git a/server/ndc.cpp b/server/ndc.cpp
index c86e53e..836e802 100644
--- a/server/ndc.cpp
+++ b/server/ndc.cpp
@@ -76,7 +76,7 @@
} else {
final_cmd = strdup("");
}
- if (final_cmd == NULL) {
+ if (final_cmd == nullptr) {
int res = errno;
perror("strdup failed");
return res;