diff options
| author | 2018-07-17 14:13:29 -0700 | |
|---|---|---|
| committer | 2018-07-17 14:15:04 -0700 | |
| commit | 8f313e3e61e5707c08bc62870d68f3d81e050216 (patch) | |
| tree | 12136ef5730b981666470724b3a2ef55d7a8c8a0 | |
| parent | dc3b0ab2efb5e37df35720b7f6ffc14c4670e067 (diff) | |
[sensorservice] Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning.
Test: m
Bug: 68236239
Change-Id: I9938306410e9773243b2b9c5e2fc4afdb48b9810
| -rw-r--r-- | services/sensorservice/BatteryService.cpp | 2 | ||||
| -rw-r--r-- | services/sensorservice/RotationVectorSensor.cpp | 2 | ||||
| -rw-r--r-- | services/sensorservice/SensorDevice.cpp | 2 | ||||
| -rw-r--r-- | services/sensorservice/SensorEventConnection.cpp | 8 | ||||
| -rw-r--r-- | services/sensorservice/SensorEventConnection.h | 2 | ||||
| -rw-r--r-- | services/sensorservice/SensorRecord.cpp | 2 | ||||
| -rw-r--r-- | services/sensorservice/SensorRegistrationInfo.h | 2 | ||||
| -rw-r--r-- | services/sensorservice/SensorService.cpp | 32 | ||||
| -rw-r--r-- | services/sensorservice/hidl/EventQueue.cpp | 2 | ||||
| -rw-r--r-- | services/sensorservice/hidl/SensorManager.cpp | 2 |
10 files changed, 28 insertions, 28 deletions
diff --git a/services/sensorservice/BatteryService.cpp b/services/sensorservice/BatteryService.cpp index d8e5b290d0..14f9a12553 100644 --- a/services/sensorservice/BatteryService.cpp +++ b/services/sensorservice/BatteryService.cpp @@ -94,7 +94,7 @@ void BatteryService::cleanupImpl(uid_t uid) { bool BatteryService::checkService() { if (mBatteryStatService == nullptr) { const sp<IServiceManager> sm(defaultServiceManager()); - if (sm != NULL) { + if (sm != nullptr) { const String16 name("batterystats"); mBatteryStatService = interface_cast<IBatteryStats>(sm->getService(name)); } diff --git a/services/sensorservice/RotationVectorSensor.cpp b/services/sensorservice/RotationVectorSensor.cpp index 7b00f4d98d..f2ea02eb00 100644 --- a/services/sensorservice/RotationVectorSensor.cpp +++ b/services/sensorservice/RotationVectorSensor.cpp @@ -94,7 +94,7 @@ const char* RotationVectorSensor::getSensorName() const { return "GeoMag Rotation Vector Sensor"; default: assert(0); - return NULL; + return nullptr; } } diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp index 115a983bc4..ae3f42f7bc 100644 --- a/services/sensorservice/SensorDevice.cpp +++ b/services/sensorservice/SensorDevice.cpp @@ -208,7 +208,7 @@ ssize_t SensorDevice::poll(sensors_event_t* buffer, size_t count) { if(numHidlTransportErrors > 0) { ALOGE("Saw %d Hidl transport failures", numHidlTransportErrors); - HidlTransportErrorLog errLog(time(NULL), numHidlTransportErrors); + HidlTransportErrorLog errLog(time(nullptr), numHidlTransportErrors); mHidlTransportErrors.add(errLog); mTotalHidlTransportErrors++; } diff --git a/services/sensorservice/SensorEventConnection.cpp b/services/sensorservice/SensorEventConnection.cpp index f4131d4764..0fb4ac6c11 100644 --- a/services/sensorservice/SensorEventConnection.cpp +++ b/services/sensorservice/SensorEventConnection.cpp @@ -31,7 +31,7 @@ SensorService::SensorEventConnection::SensorEventConnection( const sp<SensorService>& service, uid_t uid, String8 packageName, bool isDataInjectionMode, const String16& opPackageName, bool hasSensorAccess) : mService(service), mUid(uid), mWakeLockRefCount(0), mHasLooperCallbacks(false), - mDead(false), mDataInjectionMode(isDataInjectionMode), mEventCache(NULL), + mDead(false), mDataInjectionMode(isDataInjectionMode), mEventCache(nullptr), mCacheSize(0), mMaxCacheSize(0), mPackageName(packageName), mOpPackageName(opPackageName), mDestroyed(false), mHasSensorAccess(hasSensorAccess) { mChannel = new BitTube(mService->mSocketBufferSize); @@ -55,7 +55,7 @@ void SensorService::SensorEventConnection::destroy() { } mService->cleanupConnection(this); - if (mEventCache != NULL) { + if (mEventCache != nullptr) { delete[] mEventCache; } mDestroyed = true; @@ -200,7 +200,7 @@ void SensorService::SensorEventConnection::updateLooperRegistrationLocked( // Add the file descriptor to the Looper for receiving acknowledegments if the app has // registered for wake-up sensors OR for sending events in the cache. - int ret = looper->addFd(mChannel->getSendFd(), 0, looper_flags, this, NULL); + int ret = looper->addFd(mChannel->getSendFd(), 0, looper_flags, this, nullptr); if (ret == 1) { ALOGD_IF(DEBUG_CONNECTIONS, "%p addFd fd=%d", this, mChannel->getSendFd()); mHasLooperCallbacks = true; @@ -371,7 +371,7 @@ status_t SensorService::SensorEventConnection::sendEvents( --mTotalAcksNeeded; #endif } - if (mEventCache == NULL) { + if (mEventCache == nullptr) { mMaxCacheSize = computeMaxCacheSizeLocked(); mEventCache = new sensors_event_t[mMaxCacheSize]; mCacheSize = 0; diff --git a/services/sensorservice/SensorEventConnection.h b/services/sensorservice/SensorEventConnection.h index 032721ea39..40c21ff585 100644 --- a/services/sensorservice/SensorEventConnection.h +++ b/services/sensorservice/SensorEventConnection.h @@ -53,7 +53,7 @@ public: bool hasSensorAccess); status_t sendEvents(sensors_event_t const* buffer, size_t count, sensors_event_t* scratch, - wp<const SensorEventConnection> const * mapFlushEventsToConnections = NULL); + wp<const SensorEventConnection> const * mapFlushEventsToConnections = nullptr); bool hasSensor(int32_t handle) const; bool hasAnySensor() const; bool hasOneShotSensors() const; diff --git a/services/sensorservice/SensorRecord.cpp b/services/sensorservice/SensorRecord.cpp index 53fb9de230..7c4c6a2046 100644 --- a/services/sensorservice/SensorRecord.cpp +++ b/services/sensorservice/SensorRecord.cpp @@ -71,7 +71,7 @@ wp<const SensorService::SensorEventConnection> if (mPendingFlushConnections.size() > 0) { return mPendingFlushConnections[0]; } - return NULL; + return nullptr; } void SensorService::SensorRecord::clearAllPendingFlushConnections() { diff --git a/services/sensorservice/SensorRegistrationInfo.h b/services/sensorservice/SensorRegistrationInfo.h index bba83727d9..5411515d49 100644 --- a/services/sensorservice/SensorRegistrationInfo.h +++ b/services/sensorservice/SensorRegistrationInfo.h @@ -47,7 +47,7 @@ public: mPid = (thread != nullptr) ? thread->getCallingPid() : -1; mUid = (thread != nullptr) ? thread->getCallingUid() : -1; - time_t rawtime = time(NULL); + time_t rawtime = time(nullptr); struct tm * timeinfo = localtime(&rawtime); mHour = static_cast<int8_t>(timeinfo->tm_hour); mMin = static_cast<int8_t>(timeinfo->tm_min); diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp index 8e9e7fdf7c..372b6095ba 100644 --- a/services/sensorservice/SensorService.cpp +++ b/services/sensorservice/SensorService.cpp @@ -250,7 +250,7 @@ void SensorService::onFirstRef() { // it to maxSystemSocketBufferSize if necessary. FILE *fp = fopen("/proc/sys/net/core/wmem_max", "r"); char line[128]; - if (fp != NULL && fgets(line, sizeof(line), fp) != NULL) { + if (fp != nullptr && fgets(line, sizeof(line), fp) != nullptr) { line[sizeof(line) - 1] = '\0'; size_t maxSystemSocketBufferSize; sscanf(line, "%zu", &maxSystemSocketBufferSize); @@ -295,7 +295,7 @@ void SensorService::setSensorAccess(uid_t uid, bool hasAccess) { { Mutex::Autolock _l(mLock); for (size_t i = 0 ; i < activeConnections.size(); i++) { - if (activeConnections[i] != 0 && activeConnections[i]->getUid() == uid) { + if (activeConnections[i] != nullptr && activeConnections[i]->getUid() == uid) { activeConnections[i]->setSensorAccess(hasAccess); } } @@ -475,7 +475,7 @@ status_t SensorService::dump(int fd, const Vector<String16>& args) { result.appendFormat("%zd active connections\n", mActiveConnections.size()); for (size_t i=0 ; i < mActiveConnections.size() ; i++) { sp<SensorEventConnection> connection(mActiveConnections[i].promote()); - if (connection != 0) { + if (connection != nullptr) { result.appendFormat("Connection Number: %zu \n", i); connection->dump(result); } @@ -722,11 +722,11 @@ bool SensorService::threadLoop() { // on the hardware sensor. mapFlushEventsToConnections[i] will be the // SensorEventConnection mapped to the corresponding flush_complete_event in // mSensorEventBuffer[i] if such a mapping exists (NULL otherwise). - mMapFlushEventsToConnections[i] = NULL; + mMapFlushEventsToConnections[i] = nullptr; if (mSensorEventBuffer[i].type == SENSOR_TYPE_META_DATA) { const int sensor_handle = mSensorEventBuffer[i].meta_data.sensor; SensorRecord* rec = mActiveSensors.valueFor(sensor_handle); - if (rec != NULL) { + if (rec != nullptr) { mMapFlushEventsToConnections[i] = rec->getFirstPendingFlushConnection(); rec->removeFirstPendingFlushConnection(); } @@ -770,7 +770,7 @@ bool SensorService::threadLoop() { size_t numConnections = activeConnections.size(); for (size_t i=0 ; i < numConnections; ++i) { - if (activeConnections[i] != NULL) { + if (activeConnections[i] != nullptr) { activeConnections[i]->removeSensor(handle); } } @@ -783,7 +783,7 @@ bool SensorService::threadLoop() { bool needsWakeLock = false; size_t numConnections = activeConnections.size(); for (size_t i=0 ; i < numConnections; ++i) { - if (activeConnections[i] != 0) { + if (activeConnections[i] != nullptr) { activeConnections[i]->sendEvents(mSensorEventBuffer, count, mSensorEventScratch, mMapFlushEventsToConnections); needsWakeLock |= activeConnections[i]->needsWakeLock(); @@ -816,7 +816,7 @@ void SensorService::resetAllWakeLockRefCounts() { { Mutex::Autolock _l(mLock); for (size_t i=0 ; i < activeConnections.size(); ++i) { - if (activeConnections[i] != 0) { + if (activeConnections[i] != nullptr) { activeConnections[i]->resetWakeLockRefCount(); } } @@ -1021,15 +1021,15 @@ sp<ISensorEventConnection> SensorService::createSensorEventConnection(const Stri int requestedMode, const String16& opPackageName) { // Only 2 modes supported for a SensorEventConnection ... NORMAL and DATA_INJECTION. if (requestedMode != NORMAL && requestedMode != DATA_INJECTION) { - return NULL; + return nullptr; } Mutex::Autolock _l(mLock); // To create a client in DATA_INJECTION mode to inject data, SensorService should already be // operating in DI mode. if (requestedMode == DATA_INJECTION) { - if (mCurrentOperatingMode != DATA_INJECTION) return NULL; - if (!isWhiteListedPackage(packageName)) return NULL; + if (mCurrentOperatingMode != DATA_INJECTION) return nullptr; + if (!isWhiteListedPackage(packageName)) return nullptr; } uid_t uid = IPCThreadState::self()->getCallingUid(); @@ -1325,7 +1325,7 @@ status_t SensorService::enable(const sp<SensorEventConnection>& connection, } SensorRecord* rec = mActiveSensors.valueFor(handle); - if (rec == 0) { + if (rec == nullptr) { rec = new SensorRecord(connection); mActiveSensors.add(handle, rec); if (sensor->isVirtual()) { @@ -1352,7 +1352,7 @@ status_t SensorService::enable(const sp<SensorEventConnection>& connection, if (isWakeUpSensorEvent(event) && !mWakeLockAcquired) { setWakeLockAcquiredLocked(true); } - connection->sendEvents(&event, 1, NULL); + connection->sendEvents(&event, 1, nullptr); if (!connection->needsWakeLock() && mWakeLockAcquired) { checkWakeLockStateLocked(); } @@ -1534,7 +1534,7 @@ status_t SensorService::flushSensor(const sp<SensorEventConnection>& connection, status_t err_flush = sensor->flush(connection.get(), handle); if (err_flush == NO_ERROR) { SensorRecord* rec = mActiveSensors.valueFor(handle); - if (rec != NULL) rec->addPendingFlushConnection(connection); + if (rec != nullptr) rec->addPendingFlushConnection(connection); } err = (err_flush != NO_ERROR) ? err_flush : err; } @@ -1592,7 +1592,7 @@ void SensorService::checkWakeLockStateLocked() { bool releaseLock = true; for (size_t i=0 ; i<mActiveConnections.size() ; i++) { sp<SensorEventConnection> connection(mActiveConnections[i].promote()); - if (connection != 0) { + if (connection != nullptr) { if (connection->needsWakeLock()) { releaseLock = false; break; @@ -1617,7 +1617,7 @@ void SensorService::populateActiveConnections( Mutex::Autolock _l(mLock); for (size_t i=0 ; i < mActiveConnections.size(); ++i) { sp<SensorEventConnection> connection(mActiveConnections[i].promote()); - if (connection != 0) { + if (connection != nullptr) { activeConnections->add(connection); } } diff --git a/services/sensorservice/hidl/EventQueue.cpp b/services/sensorservice/hidl/EventQueue.cpp index ff200660c1..b781744553 100644 --- a/services/sensorservice/hidl/EventQueue.cpp +++ b/services/sensorservice/hidl/EventQueue.cpp @@ -64,7 +64,7 @@ EventQueue::EventQueue( mInternalQueue(internalQueue) { mLooper->addFd(internalQueue->getFd(), ALOOPER_POLL_CALLBACK, ALOOPER_EVENT_INPUT, - new EventQueueLooperCallback(internalQueue, callback), NULL /* data */); + new EventQueueLooperCallback(internalQueue, callback), nullptr /* data */); } void EventQueue::onLastStrongRef(const void *id) { diff --git a/services/sensorservice/hidl/SensorManager.cpp b/services/sensorservice/hidl/SensorManager.cpp index fee6da1e60..938060063f 100644 --- a/services/sensorservice/hidl/SensorManager.cpp +++ b/services/sensorservice/hidl/SensorManager.cpp @@ -157,7 +157,7 @@ sp<Looper> SensorManager::getLooper() { JavaVMAttachArgs args{ .version = JNI_VERSION_1_2, .name = POLL_THREAD_NAME, - .group = NULL + .group = nullptr }; JNIEnv* env; if (javaVm->AttachCurrentThread(&env, &args) != JNI_OK) { |