Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9b14ac68 authored by Yi Kong's avatar Yi Kong
Browse files

[inputflinger] Modernize codebase by replacing NULL with nullptr

Fixes -Wzero-as-null-pointer-constant warning.

Test: m
Bug: 68236239
Change-Id: I0d06ab2a187e72bd893900355edad97caa684c7a
parent dc3b0ab2
Loading
Loading
Loading
Loading
+21 −21
Original line number Diff line number Diff line
@@ -143,9 +143,9 @@ uint32_t getAbsAxisUsage(int32_t axis, uint32_t deviceClasses) {

EventHub::Device::Device(int fd, int32_t id, const String8& path,
        const InputDeviceIdentifier& identifier) :
        next(NULL),
        next(nullptr),
        fd(fd), id(id), path(path), identifier(identifier),
        classes(0), configuration(NULL), virtualKeyMap(NULL),
        classes(0), configuration(nullptr), virtualKeyMap(nullptr),
        ffEffectPlaying(false), ffEffectId(-1), controllerNumber(0),
        timestampOverrideSec(0), timestampOverrideUsec(0), enabled(true),
        isVirtual(fd < 0) {
@@ -200,7 +200,7 @@ const int EventHub::EPOLL_MAX_EVENTS;

EventHub::EventHub(void) :
        mBuiltInKeyboardId(NO_BUILT_IN_KEYBOARD), mNextDeviceId(1), mControllerNumbers(),
        mOpeningDevices(0), mClosingDevices(0),
        mOpeningDevices(nullptr), mClosingDevices(nullptr),
        mNeedToSendFinishedDeviceScan(false),
        mNeedToReopenDevices(false), mNeedToScanDevices(true),
        mPendingEventCount(0), mPendingEventIndex(0), mPendingINotify(false) {
@@ -267,21 +267,21 @@ EventHub::~EventHub(void) {
InputDeviceIdentifier EventHub::getDeviceIdentifier(int32_t deviceId) const {
    AutoMutex _l(mLock);
    Device* device = getDeviceLocked(deviceId);
    if (device == NULL) return InputDeviceIdentifier();
    if (device == nullptr) return InputDeviceIdentifier();
    return device->identifier;
}

uint32_t EventHub::getDeviceClasses(int32_t deviceId) const {
    AutoMutex _l(mLock);
    Device* device = getDeviceLocked(deviceId);
    if (device == NULL) return 0;
    if (device == nullptr) return 0;
    return device->classes;
}

int32_t EventHub::getDeviceControllerNumber(int32_t deviceId) const {
    AutoMutex _l(mLock);
    Device* device = getDeviceLocked(deviceId);
    if (device == NULL) return 0;
    if (device == nullptr) return 0;
    return device->controllerNumber;
}

@@ -465,7 +465,7 @@ status_t EventHub::mapKey(int32_t deviceId,
    if (device) {
        // Check the key character map first.
        sp<KeyCharacterMap> kcm = device->getKeyCharacterMap();
        if (kcm != NULL) {
        if (kcm != nullptr) {
            if (!kcm->mapKey(scanCode, usageCode, outKeycode)) {
                *outFlags = 0;
                status = NO_ERROR;
@@ -481,7 +481,7 @@ status_t EventHub::mapKey(int32_t deviceId,
        }

        if (status == NO_ERROR) {
            if (kcm != NULL) {
            if (kcm != nullptr) {
                kcm->tryRemapKey(*outKeycode, metaState, outKeycode, outMetaState);
            } else {
                *outMetaState = metaState;
@@ -581,7 +581,7 @@ sp<KeyCharacterMap> EventHub::getKeyCharacterMap(int32_t deviceId) const {
    if (device) {
        return device->getKeyCharacterMap();
    }
    return NULL;
    return nullptr;
}

bool EventHub::setKeyboardLayoutOverlay(int32_t deviceId,
@@ -641,7 +641,7 @@ void EventHub::assignDescriptorLocked(InputDeviceIdentifier& identifier) {
    if (identifier.uniqueId.isEmpty()) {
        // If it didn't have a unique id check for conflicts and enforce
        // uniqueness if necessary.
        while(getDeviceByDescriptorLocked(identifier.descriptor) != NULL) {
        while(getDeviceByDescriptorLocked(identifier.descriptor) != nullptr) {
            identifier.nonce++;
            rawDescriptor = generateDescriptor(identifier);
        }
@@ -714,7 +714,7 @@ EventHub::Device* EventHub::getDeviceByDescriptorLocked(String8& descriptor) con
            return device;
        }
    }
    return NULL;
    return nullptr;
}

EventHub::Device* EventHub::getDeviceLocked(int32_t deviceId) const {
@@ -732,7 +732,7 @@ EventHub::Device* EventHub::getDeviceByPathLocked(const char* devicePath) const
            return device;
        }
    }
    return NULL;
    return nullptr;
}

size_t EventHub::getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSize) {
@@ -782,7 +782,7 @@ size_t EventHub::getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSiz
            mNeedToSendFinishedDeviceScan = true;
        }

        while (mOpeningDevices != NULL) {
        while (mOpeningDevices != nullptr) {
            Device* device = mOpeningDevices;
            ALOGV("Reporting device opened: id=%d, name=%s\n",
                 device->id, device->path.string());
@@ -1099,7 +1099,7 @@ status_t EventHub::registerDeviceForEpollLocked(Device* device) {

status_t EventHub::unregisterDeviceFromEpollLocked(Device* device) {
    if (device->hasValidFd()) {
        if (epoll_ctl(mEpollFd, EPOLL_CTL_DEL, device->fd, NULL)) {
        if (epoll_ctl(mEpollFd, EPOLL_CTL_DEL, device->fd, nullptr)) {
            ALOGW("Could not remove device fd from epoll instance.  errno=%d", errno);
            return -errno;
        }
@@ -1423,7 +1423,7 @@ void EventHub::configureFd(Device* device) {
bool EventHub::isDeviceEnabled(int32_t deviceId) {
    AutoMutex _l(mLock);
    Device* device = getDeviceLocked(deviceId);
    if (device == NULL) {
    if (device == nullptr) {
        ALOGE("Invalid device id=%" PRId32 " provided to %s", deviceId, __func__);
        return false;
    }
@@ -1433,7 +1433,7 @@ bool EventHub::isDeviceEnabled(int32_t deviceId) {
status_t EventHub::enableDevice(int32_t deviceId) {
    AutoMutex _l(mLock);
    Device* device = getDeviceLocked(deviceId);
    if (device == NULL) {
    if (device == nullptr) {
        ALOGE("Invalid device id=%" PRId32 " provided to %s", deviceId, __func__);
        return BAD_VALUE;
    }
@@ -1455,7 +1455,7 @@ status_t EventHub::enableDevice(int32_t deviceId) {
status_t EventHub::disableDevice(int32_t deviceId) {
    AutoMutex _l(mLock);
    Device* device = getDeviceLocked(deviceId);
    if (device == NULL) {
    if (device == nullptr) {
        ALOGE("Invalid device id=%" PRId32 " provided to %s", deviceId, __func__);
        return BAD_VALUE;
    }
@@ -1634,9 +1634,9 @@ void EventHub::closeDeviceLocked(Device* device) {
    device->close();

    // Unlink for opening devices list if it is present.
    Device* pred = NULL;
    Device* pred = nullptr;
    bool found = false;
    for (Device* entry = mOpeningDevices; entry != NULL; ) {
    for (Device* entry = mOpeningDevices; entry != nullptr; ) {
        if (entry == device) {
            found = true;
            break;
@@ -1712,7 +1712,7 @@ status_t EventHub::scanDirLocked(const char *dirname)
    DIR *dir;
    struct dirent *de;
    dir = opendir(dirname);
    if(dir == NULL)
    if(dir == nullptr)
        return -1;
    strcpy(devname, dirname);
    filename = devname + strlen(devname);
@@ -1773,7 +1773,7 @@ void EventHub::dump(std::string& dump) {
            dump += StringPrintf(INDENT3 "ConfigurationFile: %s\n",
                    device->configurationFile.string());
            dump += StringPrintf(INDENT3 "HaveKeyboardLayoutOverlay: %s\n",
                    toString(device->overlayKeyMap != NULL));
                    toString(device->overlayKeyMap != nullptr));
        }
    } // release lock
}
+1 −1
Original line number Diff line number Diff line
@@ -385,7 +385,7 @@ private:
        const bool isVirtual; // set if fd < 0 is passed to constructor

        const sp<KeyCharacterMap>& getKeyCharacterMap() const {
            if (combinedKeyMap != NULL) {
            if (combinedKeyMap != nullptr) {
                return combinedKeyMap;
            }
            return keyMap.keyCharacterMap;
+2 −2
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ namespace android {
// --- InputApplicationHandle ---

InputApplicationHandle::InputApplicationHandle() :
    mInfo(NULL) {
    mInfo(nullptr) {
}

InputApplicationHandle::~InputApplicationHandle() {
@@ -35,7 +35,7 @@ InputApplicationHandle::~InputApplicationHandle() {
void InputApplicationHandle::releaseInfo() {
    if (mInfo) {
        delete mInfo;
        mInfo = NULL;
        mInfo = nullptr;
    }
}

+63 −63

File changed.

Preview size limit exceeded, changes collapsed.

+7 −7
Original line number Diff line number Diff line
@@ -406,7 +406,7 @@ private:
        T* prev;

    protected:
        inline Link() : next(NULL), prev(NULL) { }
        inline Link() : next(nullptr), prev(nullptr) { }
    };

    struct InjectionState {
@@ -441,7 +441,7 @@ private:

        bool dispatchInProgress; // initially false, set to true while dispatching

        inline bool isInjected() const { return injectionState != NULL; }
        inline bool isInjected() const { return injectionState != nullptr; }

        void release();

@@ -614,7 +614,7 @@ private:
        T* tail;
        uint32_t entryCount;

        inline Queue() : head(NULL), tail(NULL), entryCount(0) {
        inline Queue() : head(nullptr), tail(nullptr), entryCount(0) {
        }

        inline bool isEmpty() const {
@@ -629,7 +629,7 @@ private:
            } else {
                head = entry;
            }
            entry->next = NULL;
            entry->next = nullptr;
            tail = entry;
        }

@@ -641,7 +641,7 @@ private:
            } else {
                tail = entry;
            }
            entry->prev = NULL;
            entry->prev = nullptr;
            head = entry;
        }

@@ -664,9 +664,9 @@ private:
            T* entry = head;
            head = entry->next;
            if (head) {
                head->prev = NULL;
                head->prev = nullptr;
            } else {
                tail = NULL;
                tail = nullptr;
            }
            return entry;
        }
Loading