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

Commit 15f7302e authored by Yi Kong's avatar Yi Kong Committed by android-build-merger
Browse files

Merge "[cmds] Modernize codebase by replacing NULL with nullptr" am: ad0f33ea

am: 9ead54be

Change-Id: I904dccb993749ad1e7b79f5b6d66369d3ea7224b
parents 49eaa48a 9ead54be
Loading
Loading
Loading
Loading
+26 −26
Original line number Diff line number Diff line
@@ -230,8 +230,8 @@ static int g_traceBufferSizeKB = 2048;
static bool g_compress = false;
static bool g_nohup = false;
static int g_initialSleepSecs = 0;
static const char* g_categoriesFile = NULL;
static const char* g_kernelTraceFuncs = NULL;
static const char* g_categoriesFile = nullptr;
static const char* g_kernelTraceFuncs = nullptr;
static const char* g_debugAppCmdLine = "";
static const char* g_outputFile = nullptr;

@@ -407,7 +407,7 @@ static bool isCategorySupported(const TracingCategory& category)
    for (int i = 0; i < MAX_SYS_FILES; i++) {
        const char* path = category.sysfiles[i].path;
        bool req = category.sysfiles[i].required == REQ;
        if (path != NULL) {
        if (path != nullptr) {
            if (req) {
                if (!fileIsWritable(path)) {
                    return false;
@@ -432,7 +432,7 @@ static bool isCategorySupportedForRoot(const TracingCategory& category)
    for (int i = 0; i < MAX_SYS_FILES; i++) {
        const char* path = category.sysfiles[i].path;
        bool req = category.sysfiles[i].required == REQ;
        if (path != NULL) {
        if (path != nullptr) {
            if (req) {
                if (!fileExists(path)) {
                    return false;
@@ -548,10 +548,10 @@ static bool pokeBinderServices()
    Vector<String16> services = sm->listServices();
    for (size_t i = 0; i < services.size(); i++) {
        sp<IBinder> obj = sm->checkService(services[i]);
        if (obj != NULL) {
        if (obj != nullptr) {
            Parcel data;
            if (obj->transact(IBinder::SYSPROPS_TRANSACTION, data,
                    NULL, 0) != OK) {
                    nullptr, 0) != OK) {
                if (false) {
                    // XXX: For some reason this fails on tablets trying to
                    // poke the "phone" service.  It's not clear whether some
@@ -641,9 +641,9 @@ static bool setAppCmdlineProperty(char* cmdline)
{
    int i = 0;
    char* start = cmdline;
    while (start != NULL) {
    while (start != nullptr) {
        char* end = strchr(start, ',');
        if (end != NULL) {
        if (end != nullptr) {
            *end = '\0';
            end++;
        }
@@ -673,7 +673,7 @@ static bool disableKernelTraceEvents() {
        const TracingCategory &c = k_categories[i];
        for (int j = 0; j < MAX_SYS_FILES; j++) {
            const char* path = c.sysfiles[j].path;
            if (path != NULL && fileIsWritable(path)) {
            if (path != nullptr && fileIsWritable(path)) {
                ok &= setKernelOptionEnable(path, false);
            }
        }
@@ -709,7 +709,7 @@ static bool verifyKernelTraceFuncs(const char* funcs)
                ok = false;
            }
        }
        func = strtok(NULL, ",");
        func = strtok(nullptr, ",");
    }
    free(myFuncs);
    return ok;
@@ -720,7 +720,7 @@ static bool setKernelTraceFuncs(const char* funcs)
{
    bool ok = true;

    if (funcs == NULL || funcs[0] == '\0') {
    if (funcs == nullptr || funcs[0] == '\0') {
        // Disable kernel function tracing.
        if (fileIsWritable(k_currentTracerPath)) {
            ok &= writeStr(k_currentTracerPath, "nop");
@@ -742,7 +742,7 @@ static bool setKernelTraceFuncs(const char* funcs)
        char* func = strtok(myFuncs, ",");
        while (func) {
            ok &= appendStr(k_ftraceFilterPath, func);
            func = strtok(NULL, ",");
            func = strtok(nullptr, ",");
        }
        free(myFuncs);

@@ -784,7 +784,7 @@ static bool setCategoriesEnableFromFile(const char* categories_file)
    if (!categories_file) {
        return true;
    }
    Tokenizer* tokenizer = NULL;
    Tokenizer* tokenizer = nullptr;
    if (Tokenizer::open(String8(categories_file), &tokenizer) != NO_ERROR) {
        return false;
    }
@@ -886,7 +886,7 @@ static bool setUpKernelTracing()
            for (int j = 0; j < MAX_SYS_FILES; j++) {
                const char* path = c.sysfiles[j].path;
                bool required = c.sysfiles[j].required == REQ;
                if (path != NULL) {
                if (path != nullptr) {
                    if (fileIsWritable(path)) {
                        ok &= setKernelOptionEnable(path, true);
                    } else if (required) {
@@ -911,7 +911,7 @@ static void cleanUpKernelTracing()
    setTraceOverwriteEnable(true);
    setTraceBufferSizeKB(1);
    setPrintTgidEnableIfPresent(false);
    setKernelTraceFuncs(NULL);
    setKernelTraceFuncs(nullptr);
    setUserInitiatedTraceProperty(false);
}

@@ -1069,10 +1069,10 @@ static void registerSigHandler()
    sigemptyset(&sa.sa_mask);
    sa.sa_flags = 0;
    sa.sa_handler = handleSignal;
    sigaction(SIGHUP, &sa, NULL);
    sigaction(SIGINT, &sa, NULL);
    sigaction(SIGQUIT, &sa, NULL);
    sigaction(SIGTERM, &sa, NULL);
    sigaction(SIGHUP, &sa, nullptr);
    sigaction(SIGINT, &sa, nullptr);
    sigaction(SIGQUIT, &sa, nullptr);
    sigaction(SIGTERM, &sa, nullptr);
}

static void listSupportedCategories()
@@ -1162,13 +1162,13 @@ int main(int argc, char **argv)
        int ret;
        int option_index = 0;
        static struct option long_options[] = {
            {"async_start",       no_argument, 0,  0 },
            {"async_stop",        no_argument, 0,  0 },
            {"async_dump",        no_argument, 0,  0 },
            {"only_userspace",    no_argument, 0,  0 },
            {"list_categories",   no_argument, 0,  0 },
            {"stream",            no_argument, 0,  0 },
            {           0,                  0, 0,  0 }
            {"async_start",       no_argument, nullptr,  0 },
            {"async_stop",        no_argument, nullptr,  0 },
            {"async_dump",        no_argument, nullptr,  0 },
            {"only_userspace",    no_argument, nullptr,  0 },
            {"list_categories",   no_argument, nullptr,  0 },
            {"stream",            no_argument, nullptr,  0 },
            {nullptr,                       0, nullptr,  0 }
        };

        ret = getopt_long(argc, argv, "a:b:cf:k:ns:t:zo:",
+6 −6
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ using android::os::dumpstate::PropertiesHelper;

/* read before root is shed */
static char cmdline_buf[16384] = "(unknown)";
static const char *dump_traces_path = NULL;
static const char *dump_traces_path = nullptr;

// TODO: variables and functions below should be part of dumpstate object

@@ -295,7 +295,7 @@ static void dump_dev_files(const char *title, const char *driverpath, const char
    char path[PATH_MAX];

    d = opendir(driverpath);
    if (d == NULL) {
    if (d == nullptr) {
        return;
    }

@@ -587,7 +587,7 @@ unsigned long worst_write_perf = 20000; /* in KB/s */
static int dump_stat_from_fd(const char *title __unused, const char *path, int fd) {
    unsigned long long fields[__STAT_NUMBER_FIELD];
    bool z;
    char *cp, *buffer = NULL;
    char *cp, *buffer = nullptr;
    size_t i = 0;
    FILE *fp = fdopen(dup(fd), "rb");
    getline(&buffer, &i, fp);
@@ -1686,7 +1686,7 @@ static std::string SHA256_file_hash(const std::string& filepath) {
            | O_CLOEXEC | O_NOFOLLOW)));
    if (fd == -1) {
        MYLOGE("open(%s): %s\n", filepath.c_str(), strerror(errno));
        return NULL;
        return nullptr;
    }

    SHA256_CTX ctx;
@@ -1699,7 +1699,7 @@ static std::string SHA256_file_hash(const std::string& filepath) {
            break;
        } else if (bytes_read == -1) {
            MYLOGE("read(%s): %s\n", filepath.c_str(), strerror(errno));
            return NULL;
            return nullptr;
        }

        SHA256_Update(&ctx, buffer.data(), bytes_read);
@@ -1748,7 +1748,7 @@ int run_main(int argc, char* argv[]) {
    int do_add_date = 0;
    int do_zip_file = 0;
    int do_vibrate = 1;
    char* use_outfile = 0;
    char* use_outfile = nullptr;
    int use_socket = 0;
    int use_control_socket = 0;
    int do_fb = 0;
+6 −6
Original line number Diff line number Diff line
@@ -525,13 +525,13 @@ void do_dmesg() {
    if (PropertiesHelper::IsDryRun()) return;

    /* Get size of kernel buffer */
    int size = klogctl(KLOG_SIZE_BUFFER, NULL, 0);
    int size = klogctl(KLOG_SIZE_BUFFER, nullptr, 0);
    if (size <= 0) {
        printf("Unexpected klogctl return value: %d\n\n", size);
        return;
    }
    char *buf = (char *) malloc(size + 1);
    if (buf == NULL) {
    if (buf == nullptr) {
        printf("memory allocation failed\n\n");
        return;
    }
@@ -598,7 +598,7 @@ int dump_files(const std::string& title, const char* dir, bool (*skip)(const cha
    DurationReporter duration_reporter(title);
    DIR *dirp;
    struct dirent *d;
    char *newpath = NULL;
    char *newpath = nullptr;
    const char *slash = "/";
    int retval = 0;

@@ -611,7 +611,7 @@ int dump_files(const std::string& title, const char* dir, bool (*skip)(const cha
        ++slash;
    }
    dirp = opendir(dir);
    if (dirp == NULL) {
    if (dirp == nullptr) {
        retval = -errno;
        MYLOGE("%s: %s\n", dir, strerror(errno));
        return retval;
@@ -620,7 +620,7 @@ int dump_files(const std::string& title, const char* dir, bool (*skip)(const cha
    if (!dump_from_fd) {
        dump_from_fd = dump_file_from_fd;
    }
    for (; ((d = readdir(dirp))); free(newpath), newpath = NULL) {
    for (; ((d = readdir(dirp))); free(newpath), newpath = nullptr) {
        if ((d->d_name[0] == '.')
         && (((d->d_name[1] == '.') && (d->d_name[2] == '\0'))
          || (d->d_name[1] == '\0'))) {
@@ -648,7 +648,7 @@ int dump_files(const std::string& title, const char* dir, bool (*skip)(const cha
            printf("*** %s: %s\n", newpath, strerror(errno));
            continue;
        }
        (*dump_from_fd)(NULL, newpath, fd.get());
        (*dump_from_fd)(nullptr, newpath, fd.get());
    }
    closedir(dirp);
    if (!title.empty()) {
+15 −15
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ GLHelper::GLHelper() :
    mContext(EGL_NO_CONTEXT),
    mDummySurface(EGL_NO_SURFACE),
    mConfig(0),
    mShaderPrograms(NULL),
    mShaderPrograms(nullptr),
    mDitherTexture(0) {
}

@@ -101,12 +101,12 @@ bool GLHelper::setUp(const ShaderDesc* shaderDescs, size_t numShaders) {
}

void GLHelper::tearDown() {
    if (mShaderPrograms != NULL) {
    if (mShaderPrograms != nullptr) {
        delete[] mShaderPrograms;
        mShaderPrograms = NULL;
        mShaderPrograms = nullptr;
    }

    if (mSurfaceComposerClient != NULL) {
    if (mSurfaceComposerClient != nullptr) {
        mSurfaceComposerClient->dispose();
        mSurfaceComposerClient.clear();
    }
@@ -210,7 +210,7 @@ bool GLHelper::createNamedSurfaceTexture(GLuint name, uint32_t w, uint32_t h,
    glc->setConsumerUsageBits(GRALLOC_USAGE_HW_COMPOSER);

    sp<ANativeWindow> anw = new Surface(producer);
    EGLSurface s = eglCreateWindowSurface(mDisplay, mConfig, anw.get(), NULL);
    EGLSurface s = eglCreateWindowSurface(mDisplay, mConfig, anw.get(), nullptr);
    if (s == EGL_NO_SURFACE) {
        fprintf(stderr, "eglCreateWindowSurface error: %#x\n", eglGetError());
        return false;
@@ -223,7 +223,7 @@ bool GLHelper::createNamedSurfaceTexture(GLuint name, uint32_t w, uint32_t h,

bool GLHelper::computeWindowScale(uint32_t w, uint32_t h, float* scale) {
    sp<IBinder> dpy = mSurfaceComposerClient->getBuiltInDisplay(0);
    if (dpy == NULL) {
    if (dpy == nullptr) {
        fprintf(stderr, "SurfaceComposer::getBuiltInDisplay failed.\n");
        return false;
    }
@@ -247,7 +247,7 @@ bool GLHelper::createWindowSurface(uint32_t w, uint32_t h,
    bool result;
    status_t err;

    if (mSurfaceComposerClient == NULL) {
    if (mSurfaceComposerClient == nullptr) {
        mSurfaceComposerClient = new SurfaceComposerClient;
    }
    err = mSurfaceComposerClient->initCheck();
@@ -258,7 +258,7 @@ bool GLHelper::createWindowSurface(uint32_t w, uint32_t h,

    sp<SurfaceControl> sc = mSurfaceComposerClient->createSurface(
            String8("Benchmark"), w, h, PIXEL_FORMAT_RGBA_8888, 0);
    if (sc == NULL || !sc->isValid()) {
    if (sc == nullptr || !sc->isValid()) {
        fprintf(stderr, "Failed to create SurfaceControl.\n");
        return false;
    }
@@ -275,7 +275,7 @@ bool GLHelper::createWindowSurface(uint32_t w, uint32_t h,
            .apply();

    sp<ANativeWindow> anw = sc->getSurface();
    EGLSurface s = eglCreateWindowSurface(mDisplay, mConfig, anw.get(), NULL);
    EGLSurface s = eglCreateWindowSurface(mDisplay, mConfig, anw.get(), nullptr);
    if (s == EGL_NO_SURFACE) {
        fprintf(stderr, "eglCreateWindowSurface error: %#x\n", eglGetError());
        return false;
@@ -294,7 +294,7 @@ static bool compileShader(GLenum shaderType, const char* src,
        return false;
    }

    glShaderSource(shader, 1, &src, NULL);
    glShaderSource(shader, 1, &src, nullptr);
    glCompileShader(shader);

    GLint compiled = 0;
@@ -305,7 +305,7 @@ static bool compileShader(GLenum shaderType, const char* src,
        if (infoLen) {
            char* buf = new char[infoLen];
            if (buf) {
                glGetShaderInfoLog(shader, infoLen, NULL, buf);
                glGetShaderInfoLog(shader, infoLen, nullptr, buf);
                fprintf(stderr, "Shader compile log:\n%s\n", buf);
                delete[] buf;
            }
@@ -318,21 +318,21 @@ static bool compileShader(GLenum shaderType, const char* src,
}

static void printShaderSource(const char* const* src) {
    for (size_t i = 0; i < MAX_SHADER_LINES && src[i] != NULL; i++) {
    for (size_t i = 0; i < MAX_SHADER_LINES && src[i] != nullptr; i++) {
        fprintf(stderr, "%3zu: %s\n", i+1, src[i]);
    }
}

static const char* makeShaderString(const char* const* src) {
    size_t len = 0;
    for (size_t i = 0; i < MAX_SHADER_LINES && src[i] != NULL; i++) {
    for (size_t i = 0; i < MAX_SHADER_LINES && src[i] != nullptr; i++) {
        // The +1 is for the '\n' that will be added.
        len += strlen(src[i]) + 1;
    }

    char* result = new char[len+1];
    char* end = result;
    for (size_t i = 0; i < MAX_SHADER_LINES && src[i] != NULL; i++) {
    for (size_t i = 0; i < MAX_SHADER_LINES && src[i] != nullptr; i++) {
        strcpy(end, src[i]);
        end += strlen(src[i]);
        *end = '\n';
@@ -376,7 +376,7 @@ static bool linkShaderProgram(GLuint vs, GLuint fs, GLuint* outPgm) {
        if (bufLength) {
            char* buf = new char[bufLength];
            if (buf) {
                glGetProgramInfoLog(program, bufLength, NULL, buf);
                glGetProgramInfoLog(program, bufLength, nullptr, buf);
                fprintf(stderr, "Program link log:\n%s\n", buf);
                delete[] buf;
            }
+10 −10
Original line number Diff line number Diff line
@@ -284,7 +284,7 @@ class Layer {
public:

    Layer() :
        mGLHelper(NULL),
        mGLHelper(nullptr),
        mSurface(EGL_NO_SURFACE) {
    }

@@ -316,23 +316,23 @@ public:
    }

    void tearDown() {
        if (mComposer != NULL) {
        if (mComposer != nullptr) {
            mComposer->tearDown();
            delete mComposer;
            mComposer = NULL;
            mComposer = nullptr;
        }

        if (mRenderer != NULL) {
        if (mRenderer != nullptr) {
            mRenderer->tearDown();
            delete mRenderer;
            mRenderer = NULL;
            mRenderer = nullptr;
        }

        if (mSurface != EGL_NO_SURFACE) {
            mGLHelper->destroySurface(&mSurface);
            mGLConsumer->abandon();
        }
        mGLHelper = NULL;
        mGLHelper = nullptr;
        mGLConsumer.clear();
    }

@@ -377,7 +377,7 @@ public:
        mDesc(desc),
        mInstance(instance),
        mNumLayers(countLayers(desc)),
        mGLHelper(NULL),
        mGLHelper(nullptr),
        mSurface(EGL_NO_SURFACE),
        mWindowSurface(EGL_NO_SURFACE) {
    }
@@ -443,7 +443,7 @@ public:
            mLayers[i].tearDown();
        }

        if (mGLHelper != NULL) {
        if (mGLHelper != nullptr) {
            if (mWindowSurface != EGL_NO_SURFACE) {
                mGLHelper->destroySurface(&mWindowSurface);
            }
@@ -453,7 +453,7 @@ public:
            mSurfaceControl.clear();
            mGLHelper->tearDown();
            delete mGLHelper;
            mGLHelper = NULL;
            mGLHelper = nullptr;
        }
    }

@@ -553,7 +553,7 @@ private:
    static size_t countLayers(const BenchmarkDesc& desc) {
        size_t i;
        for (i = 0; i < MAX_NUM_LAYERS; i++) {
            if (desc.layers[i].rendererFactory == NULL) {
            if (desc.layers[i].rendererFactory == nullptr) {
                break;
            }
        }
Loading