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

Commit ab3203f3 authored by Yi Kong's avatar Yi Kong Committed by Gerrit Code Review
Browse files

Merge "[libutils] Modernize codebase by replacing NULL with nullptr"

parents 17a02a33 e1731a4f
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ class Backtrace {
  // Tracing a thread in a different process is not supported.
  // If map is NULL, then create the map and manage it internally.
  // If map is not NULL, the map is still owned by the caller.
  static Backtrace* Create(pid_t pid, pid_t tid, BacktraceMap* map = NULL);
  static Backtrace* Create(pid_t pid, pid_t tid, BacktraceMap* map = nullptr);

  // Create an offline Backtrace object that can be used to do an unwind without a process
  // that is still running. By default, information is only cached in the map
@@ -145,7 +145,7 @@ class Backtrace {
  virtual ~Backtrace();

  // Get the current stack trace and store in the backtrace_ structure.
  virtual bool Unwind(size_t num_ignore_frames, void* context = NULL) = 0;
  virtual bool Unwind(size_t num_ignore_frames, void* context = nullptr) = 0;

  static bool Unwind(unwindstack::Regs* regs, BacktraceMap* back_map,
                     std::vector<backtrace_frame_data_t>* frames, size_t num_ignore_frames,
@@ -160,7 +160,7 @@ class Backtrace {
  // If the string is empty, then no valid function name was found,
  // or the pc is not in any valid map.
  virtual std::string GetFunctionName(uint64_t pc, uint64_t* offset,
                                      const backtrace_map_t* map = NULL);
                                      const backtrace_map_t* map = nullptr);

  // Fill in the map data associated with the given pc.
  virtual void FillInMap(uint64_t pc, backtrace_map_t* map);
@@ -185,7 +185,7 @@ class Backtrace {

  const backtrace_frame_data_t* GetFrame(size_t frame_num) {
    if (frame_num >= frames_.size()) {
      return NULL;
      return nullptr;
    }
    return &frames_[frame_num];
  }
+12 −12
Original line number Diff line number Diff line
@@ -48,10 +48,10 @@ using namespace android;

// Constructor.  Create an empty object.
FileMap::FileMap(void)
    : mFileName(NULL),
      mBasePtr(NULL),
    : mFileName(nullptr),
      mBasePtr(nullptr),
      mBaseLength(0),
      mDataPtr(NULL),
      mDataPtr(nullptr),
      mDataLength(0)
#if defined(__MINGW32__)
      ,
@@ -69,9 +69,9 @@ FileMap::FileMap(FileMap&& other)
      , mFileHandle(other.mFileHandle), mFileMapping(other.mFileMapping)
#endif
{
    other.mFileName = NULL;
    other.mBasePtr = NULL;
    other.mDataPtr = NULL;
    other.mFileName = nullptr;
    other.mBasePtr = nullptr;
    other.mDataPtr = nullptr;
#if defined(__MINGW32__)
    other.mFileHandle = INVALID_HANDLE_VALUE;
    other.mFileMapping = NULL;
@@ -86,9 +86,9 @@ FileMap& FileMap::operator=(FileMap&& other) {
    mDataOffset = other.mDataOffset;
    mDataPtr = other.mDataPtr;
    mDataLength = other.mDataLength;
    other.mFileName = NULL;
    other.mBasePtr = NULL;
    other.mDataPtr = NULL;
    other.mFileName = nullptr;
    other.mBasePtr = nullptr;
    other.mDataPtr = nullptr;
#if defined(__MINGW32__)
    mFileHandle = other.mFileHandle;
    mFileMapping = other.mFileMapping;
@@ -101,7 +101,7 @@ FileMap& FileMap::operator=(FileMap&& other) {
// Destructor.
FileMap::~FileMap(void)
{
    if (mFileName != NULL) {
    if (mFileName != nullptr) {
        free(mFileName);
    }
#if defined(__MINGW32__)
@@ -196,7 +196,7 @@ bool FileMap::create(const char* origFileName, int fd, off64_t offset, size_t le
    if (!readOnly)
        prot |= PROT_WRITE;

    ptr = mmap(NULL, adjLength, prot, flags, fd, adjOffset);
    ptr = mmap(nullptr, adjLength, prot, flags, fd, adjOffset);
    if (ptr == MAP_FAILED) {
        ALOGE("mmap(%lld,%zu) failed: %s\n",
            (long long)adjOffset, adjLength, strerror(errno));
@@ -205,7 +205,7 @@ bool FileMap::create(const char* origFileName, int fd, off64_t offset, size_t le
    mBasePtr = ptr;
#endif // !defined(__MINGW32__)

    mFileName = origFileName != NULL ? strdup(origFileName) : NULL;
    mFileName = origFileName != nullptr ? strdup(origFileName) : nullptr;
    mBaseLength = adjLength;
    mDataOffset = offset;
    mDataPtr = (char*) mBasePtr + adjust;
+13 −13
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ WeakMessageHandler::~WeakMessageHandler() {

void WeakMessageHandler::handleMessage(const Message& message) {
    sp<MessageHandler> handler = mHandler.promote();
    if (handler != NULL) {
    if (handler != nullptr) {
        handler->handleMessage(message);
    }
}
@@ -87,7 +87,7 @@ void Looper::initTLSKey() {

void Looper::threadDestructor(void *st) {
    Looper* const self = static_cast<Looper*>(st);
    if (self != NULL) {
    if (self != nullptr) {
        self->decStrong((void*)threadDestructor);
    }
}
@@ -95,13 +95,13 @@ void Looper::threadDestructor(void *st) {
void Looper::setForThread(const sp<Looper>& looper) {
    sp<Looper> old = getForThread(); // also has side-effect of initializing TLS

    if (looper != NULL) {
    if (looper != nullptr) {
        looper->incStrong((void*)threadDestructor);
    }

    pthread_setspecific(gTLSKey, looper.get());

    if (old != NULL) {
    if (old != nullptr) {
        old->decStrong((void*)threadDestructor);
    }
}
@@ -116,7 +116,7 @@ sp<Looper> Looper::getForThread() {
sp<Looper> Looper::prepare(int opts) {
    bool allowNonCallbacks = opts & PREPARE_ALLOW_NON_CALLBACKS;
    sp<Looper> looper = Looper::getForThread();
    if (looper == NULL) {
    if (looper == nullptr) {
        looper = new Looper(allowNonCallbacks);
        Looper::setForThread(looper);
    }
@@ -190,9 +190,9 @@ int Looper::pollOnce(int timeoutMillis, int* outFd, int* outEvents, void** outDa
                        "fd=%d, events=0x%x, data=%p",
                        this, ident, fd, events, data);
#endif
                if (outFd != NULL) *outFd = fd;
                if (outEvents != NULL) *outEvents = events;
                if (outData != NULL) *outData = data;
                if (outFd != nullptr) *outFd = fd;
                if (outEvents != nullptr) *outEvents = events;
                if (outData != nullptr) *outData = data;
                return ident;
            }
        }
@@ -201,9 +201,9 @@ int Looper::pollOnce(int timeoutMillis, int* outFd, int* outEvents, void** outDa
#if DEBUG_POLL_AND_WAKE
            ALOGD("%p ~ pollOnce - returning result %d", this, result);
#endif
            if (outFd != NULL) *outFd = 0;
            if (outEvents != NULL) *outEvents = 0;
            if (outData != NULL) *outData = NULL;
            if (outFd != nullptr) *outFd = 0;
            if (outEvents != nullptr) *outEvents = 0;
            if (outData != nullptr) *outData = nullptr;
            return result;
        }

@@ -427,7 +427,7 @@ void Looper::pushResponse(int events, const Request& request) {
}

int Looper::addFd(int fd, int ident, int events, Looper_callbackFunc callback, void* data) {
    return addFd(fd, ident, events, callback ? new SimpleLooperCallback(callback) : NULL, data);
    return addFd(fd, ident, events, callback ? new SimpleLooperCallback(callback) : nullptr, data);
}

int Looper::addFd(int fd, int ident, int events, const sp<LooperCallback>& callback, void* data) {
@@ -542,7 +542,7 @@ int Looper::removeFd(int fd, int seq) {
        // updating the epoll set so that we avoid accidentally leaking callbacks.
        mRequests.removeItemsAt(requestIndex);

        int epollResult = epoll_ctl(mEpollFd, EPOLL_CTL_DEL, fd, NULL);
        int epollResult = epoll_ctl(mEpollFd, EPOLL_CTL_DEL, fd, nullptr);
        if (epollResult < 0) {
            if (seq != -1 && (errno == EBADF || errno == ENOENT)) {
                // Tolerate EBADF or ENOENT when the sequence number is known because it
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@
namespace android {

sp<NativeHandle> NativeHandle::create(native_handle_t* handle, bool ownsHandle) {
    return handle ? new NativeHandle(handle, ownsHandle) : NULL;
    return handle ? new NativeHandle(handle, ownsHandle) : nullptr;
}

NativeHandle::NativeHandle(native_handle_t* handle, bool ownsHandle)
+5 −5
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ LogPrinter::LogPrinter(const char* logtag,
}

void LogPrinter::printLine(const char* string) {
    if (string == NULL) {
    if (string == nullptr) {
        ALOGW("%s: NULL string passed in", __FUNCTION__);
        return;
    }
@@ -107,7 +107,7 @@ FdPrinter::FdPrinter(int fd, unsigned int indent, const char* prefix) :
}

void FdPrinter::printLine(const char* string) {
    if (string == NULL) {
    if (string == nullptr) {
        ALOGW("%s: NULL string passed in", __FUNCTION__);
        return;
    } else if (mFd < 0) {
@@ -127,16 +127,16 @@ String8Printer::String8Printer(String8* target, const char* prefix) :
        mTarget(target),
        mPrefix(prefix ?: "") {

    if (target == NULL) {
    if (target == nullptr) {
        ALOGW("%s: Target string was NULL", __FUNCTION__);
    }
}

void String8Printer::printLine(const char* string) {
    if (string == NULL) {
    if (string == nullptr) {
        ALOGW("%s: NULL string passed in", __FUNCTION__);
        return;
    } else if (mTarget == NULL) {
    } else if (mTarget == nullptr) {
        ALOGW("%s: Target string was NULL", __FUNCTION__);
        return;
    }
Loading