diff options
| author | 2018-07-17 12:53:47 -0700 | |
|---|---|---|
| committer | 2018-07-17 12:53:47 -0700 | |
| commit | 5bed83befcbc7f1a86015254a624c948d5a819b8 (patch) | |
| tree | a612741df3edbf626c01cb381c342a6864244457 | |
| parent | 836800931c463cfa105b0e454028dc884b899309 (diff) | |
[input] Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning.
Test: m
Bug: 68236239
Change-Id: I8882234efd2a0b3ef27472d3f5d4e9c69c6e7b37
| -rw-r--r-- | include/input/InputEventLabels.h | 12 | ||||
| -rw-r--r-- | include/input/VelocityTracker.h | 2 | ||||
| -rw-r--r-- | libs/input/InputDevice.cpp | 2 | ||||
| -rw-r--r-- | libs/input/InputTransport.cpp | 8 | ||||
| -rw-r--r-- | libs/input/KeyCharacterMap.cpp | 28 | ||||
| -rw-r--r-- | libs/input/KeyLayoutMap.cpp | 2 | ||||
| -rw-r--r-- | libs/input/VelocityTracker.cpp | 6 | ||||
| -rw-r--r-- | libs/input/VirtualKeyMap.cpp | 2 | ||||
| -rw-r--r-- | libs/input/tests/InputPublisherAndConsumer_test.cpp | 8 |
9 files changed, 35 insertions, 35 deletions
diff --git a/include/input/InputEventLabels.h b/include/input/InputEventLabels.h index 4b33a96adf..6d072a3ea5 100644 --- a/include/input/InputEventLabels.h +++ b/include/input/InputEventLabels.h @@ -326,7 +326,7 @@ static const InputEventLabel KEYCODES[] = { DEFINE_KEYCODE(ALL_APPS), DEFINE_KEYCODE(REFRESH), - { NULL, 0 } + { nullptr, 0 } }; static const InputEventLabel AXES[] = { @@ -375,7 +375,7 @@ static const InputEventLabel AXES[] = { // NOTE: If you add a new axis here you must also add it to several other files. // Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list. - { NULL, 0 } + { nullptr, 0 } }; static const InputEventLabel LEDS[] = { @@ -396,7 +396,7 @@ static const InputEventLabel LEDS[] = { DEFINE_LED(CONTROLLER_4), // NOTE: If you add new LEDs here, you must also add them to Input.h - { NULL, 0 } + { nullptr, 0 } }; static const InputEventLabel FLAGS[] = { @@ -404,7 +404,7 @@ static const InputEventLabel FLAGS[] = { DEFINE_FLAG(FUNCTION), DEFINE_FLAG(GESTURE), - { NULL, 0 } + { nullptr, 0 } }; static int lookupValueByLabel(const char* literal, const InputEventLabel *list) { @@ -424,7 +424,7 @@ static const char* lookupLabelByValue(int value, const InputEventLabel* list) { } list++; } - return NULL; + return nullptr; } static inline int32_t getKeyCodeByLabel(const char* label) { @@ -435,7 +435,7 @@ static inline const char* getLabelByKeyCode(int32_t keyCode) { if (keyCode >= 0 && keyCode < static_cast<int32_t>(size(KEYCODES))) { return KEYCODES[keyCode].literal; } - return NULL; + return nullptr; } static inline uint32_t getKeyFlagByLabel(const char* label) { diff --git a/include/input/VelocityTracker.h b/include/input/VelocityTracker.h index ffa1614b55..727865a933 100644 --- a/include/input/VelocityTracker.h +++ b/include/input/VelocityTracker.h @@ -63,7 +63,7 @@ public: // Creates a velocity tracker using the specified strategy. // If strategy is NULL, uses the default strategy for the platform. - VelocityTracker(const char* strategy = NULL); + VelocityTracker(const char* strategy = nullptr); ~VelocityTracker(); diff --git a/libs/input/InputDevice.cpp b/libs/input/InputDevice.cpp index 4287abeb7d..5d27bf687d 100644 --- a/libs/input/InputDevice.cpp +++ b/libs/input/InputDevice.cpp @@ -175,7 +175,7 @@ const InputDeviceInfo::MotionRange* InputDeviceInfo::getMotionRange( return ⦥ } } - return NULL; + return nullptr; } void InputDeviceInfo::addSource(uint32_t source) { diff --git a/libs/input/InputTransport.cpp b/libs/input/InputTransport.cpp index d192f63c56..770d48397e 100644 --- a/libs/input/InputTransport.cpp +++ b/libs/input/InputTransport.cpp @@ -226,7 +226,7 @@ status_t InputChannel::receiveMessage(InputMessage* msg) { sp<InputChannel> InputChannel::dup() const { int fd = ::dup(getFd()); - return fd >= 0 ? new InputChannel(getName(), fd) : NULL; + return fd >= 0 ? new InputChannel(getName(), fd) : nullptr; } @@ -388,7 +388,7 @@ InputConsumer::~InputConsumer() { bool InputConsumer::isTouchResamplingEnabled() { char value[PROPERTY_VALUE_MAX]; - int length = property_get("ro.input.noresample", value, NULL); + int length = property_get("ro.input.noresample", value, nullptr); if (length > 0) { if (!strcmp("1", value)) { return false; @@ -409,7 +409,7 @@ status_t InputConsumer::consume(InputEventFactoryInterface* factory, #endif *outSeq = 0; - *outEvent = NULL; + *outEvent = nullptr; // Fetch the next input message. // Loop until an event can be returned or no additional events are received. @@ -544,7 +544,7 @@ status_t InputConsumer::consumeBatch(InputEventFactoryInterface* factory, const InputMessage* next; if (batch.samples.isEmpty()) { mBatches.removeAt(i); - next = NULL; + next = nullptr; } else { next = &batch.samples.itemAt(0); } diff --git a/libs/input/KeyCharacterMap.cpp b/libs/input/KeyCharacterMap.cpp index b561b605b4..26747bdbbc 100644 --- a/libs/input/KeyCharacterMap.cpp +++ b/libs/input/KeyCharacterMap.cpp @@ -164,10 +164,10 @@ status_t KeyCharacterMap::load(Tokenizer* tokenizer, sp<KeyCharacterMap> KeyCharacterMap::combine(const sp<KeyCharacterMap>& base, const sp<KeyCharacterMap>& overlay) { - if (overlay == NULL) { + if (overlay == nullptr) { return base; } - if (base == NULL) { + if (base == nullptr) { return overlay; } @@ -468,7 +468,7 @@ bool KeyCharacterMap::findKey(char16_t ch, int32_t* outKeyCode, int32_t* outMeta // Try to find the most general behavior that maps to this character. // For example, the base key behavior will usually be last in the list. - const Behavior* found = NULL; + const Behavior* found = nullptr; for (const Behavior* behavior = key->firstBehavior; behavior; behavior = behavior->next) { if (behavior->character == ch) { found = behavior; @@ -605,11 +605,11 @@ sp<KeyCharacterMap> KeyCharacterMap::readFromParcel(Parcel* parcel) { map->mType = parcel->readInt32(); size_t numKeys = parcel->readInt32(); if (parcel->errorCheck()) { - return NULL; + return nullptr; } if (numKeys > MAX_KEYS) { ALOGE("Too many keys in KeyCharacterMap (%zu > %d)", numKeys, MAX_KEYS); - return NULL; + return nullptr; } for (size_t i = 0; i < numKeys; i++) { @@ -617,7 +617,7 @@ sp<KeyCharacterMap> KeyCharacterMap::readFromParcel(Parcel* parcel) { char16_t label = parcel->readInt32(); char16_t number = parcel->readInt32(); if (parcel->errorCheck()) { - return NULL; + return nullptr; } Key* key = new Key(); @@ -625,14 +625,14 @@ sp<KeyCharacterMap> KeyCharacterMap::readFromParcel(Parcel* parcel) { key->number = number; map->mKeys.add(keyCode, key); - Behavior* lastBehavior = NULL; + Behavior* lastBehavior = nullptr; while (parcel->readInt32()) { int32_t metaState = parcel->readInt32(); char16_t character = parcel->readInt32(); int32_t fallbackKeyCode = parcel->readInt32(); int32_t replacementKeyCode = parcel->readInt32(); if (parcel->errorCheck()) { - return NULL; + return nullptr; } Behavior* behavior = new Behavior(); @@ -649,7 +649,7 @@ sp<KeyCharacterMap> KeyCharacterMap::readFromParcel(Parcel* parcel) { } if (parcel->errorCheck()) { - return NULL; + return nullptr; } } return map; @@ -666,7 +666,7 @@ void KeyCharacterMap::writeToParcel(Parcel* parcel) const { parcel->writeInt32(keyCode); parcel->writeInt32(key->label); parcel->writeInt32(key->number); - for (const Behavior* behavior = key->firstBehavior; behavior != NULL; + for (const Behavior* behavior = key->firstBehavior; behavior != nullptr; behavior = behavior->next) { parcel->writeInt32(1); parcel->writeInt32(behavior->metaState); @@ -683,12 +683,12 @@ void KeyCharacterMap::writeToParcel(Parcel* parcel) const { // --- KeyCharacterMap::Key --- KeyCharacterMap::Key::Key() : - label(0), number(0), firstBehavior(NULL) { + label(0), number(0), firstBehavior(nullptr) { } KeyCharacterMap::Key::Key(const Key& other) : label(other.label), number(other.number), - firstBehavior(other.firstBehavior ? new Behavior(*other.firstBehavior) : NULL) { + firstBehavior(other.firstBehavior ? new Behavior(*other.firstBehavior) : nullptr) { } KeyCharacterMap::Key::~Key() { @@ -704,11 +704,11 @@ KeyCharacterMap::Key::~Key() { // --- KeyCharacterMap::Behavior --- KeyCharacterMap::Behavior::Behavior() : - next(NULL), metaState(0), character(0), fallbackKeyCode(0), replacementKeyCode(0) { + next(nullptr), metaState(0), character(0), fallbackKeyCode(0), replacementKeyCode(0) { } KeyCharacterMap::Behavior::Behavior(const Behavior& other) : - next(other.next ? new Behavior(*other.next) : NULL), + next(other.next ? new Behavior(*other.next) : nullptr), metaState(other.metaState), character(other.character), fallbackKeyCode(other.fallbackKeyCode), replacementKeyCode(other.replacementKeyCode) { diff --git a/libs/input/KeyLayoutMap.cpp b/libs/input/KeyLayoutMap.cpp index 2b2f13e4c7..c440078666 100644 --- a/libs/input/KeyLayoutMap.cpp +++ b/libs/input/KeyLayoutMap.cpp @@ -117,7 +117,7 @@ const KeyLayoutMap::Key* KeyLayoutMap::getKey(int32_t scanCode, int32_t usageCod return &mKeysByScanCode.valueAt(index); } } - return NULL; + return nullptr; } status_t KeyLayoutMap::findScanCodesForKey(int32_t keyCode, Vector<int32_t>* outScanCodes) const { diff --git a/libs/input/VelocityTracker.cpp b/libs/input/VelocityTracker.cpp index 496158b9cd..118f3aacd9 100644 --- a/libs/input/VelocityTracker.cpp +++ b/libs/input/VelocityTracker.cpp @@ -115,7 +115,7 @@ VelocityTracker::VelocityTracker(const char* strategy) : // Allow the default strategy to be overridden using a system property for debugging. if (!strategy) { - int length = property_get("persist.input.velocitytracker.strategy", value, NULL); + int length = property_get("persist.input.velocitytracker.strategy", value, nullptr); if (length > 0) { strategy = value; } else { @@ -139,7 +139,7 @@ VelocityTracker::~VelocityTracker() { bool VelocityTracker::configureStrategy(const char* strategy) { mStrategy = createStrategy(strategy); - return mStrategy != NULL; + return mStrategy != nullptr; } VelocityTrackerStrategy* VelocityTracker::createStrategy(const char* strategy) { @@ -204,7 +204,7 @@ VelocityTrackerStrategy* VelocityTracker::createStrategy(const char* strategy) { // time to adjust to changes in direction. return new LegacyVelocityTrackerStrategy(); } - return NULL; + return nullptr; } void VelocityTracker::clear() { diff --git a/libs/input/VirtualKeyMap.cpp b/libs/input/VirtualKeyMap.cpp index 28ea7177cf..993297319e 100644 --- a/libs/input/VirtualKeyMap.cpp +++ b/libs/input/VirtualKeyMap.cpp @@ -47,7 +47,7 @@ VirtualKeyMap::~VirtualKeyMap() { } status_t VirtualKeyMap::load(const String8& filename, VirtualKeyMap** outMap) { - *outMap = NULL; + *outMap = nullptr; Tokenizer* tokenizer; status_t status = Tokenizer::open(filename, &tokenizer); diff --git a/libs/input/tests/InputPublisherAndConsumer_test.cpp b/libs/input/tests/InputPublisherAndConsumer_test.cpp index 13617bfd9b..0788c89b2a 100644 --- a/libs/input/tests/InputPublisherAndConsumer_test.cpp +++ b/libs/input/tests/InputPublisherAndConsumer_test.cpp @@ -46,12 +46,12 @@ protected: virtual void TearDown() { if (mPublisher) { delete mPublisher; - mPublisher = NULL; + mPublisher = nullptr; } if (mConsumer) { delete mConsumer; - mConsumer = NULL; + mConsumer = nullptr; } serverChannel.clear(); @@ -94,7 +94,7 @@ void InputPublisherAndConsumerTest::PublishAndConsumeKeyEvent() { ASSERT_EQ(OK, status) << "consumer consume should return OK"; - ASSERT_TRUE(event != NULL) + ASSERT_TRUE(event != nullptr) << "consumer should have returned non-NULL event"; ASSERT_EQ(AINPUT_EVENT_TYPE_KEY, event->getType()) << "consumer should have returned a key event"; @@ -180,7 +180,7 @@ void InputPublisherAndConsumerTest::PublishAndConsumeMotionEvent() { ASSERT_EQ(OK, status) << "consumer consume should return OK"; - ASSERT_TRUE(event != NULL) + ASSERT_TRUE(event != nullptr) << "consumer should have returned non-NULL event"; ASSERT_EQ(AINPUT_EVENT_TYPE_MOTION, event->getType()) << "consumer should have returned a motion event"; |