Loading cmds/atrace/atrace.cpp +26 −26 Original line number Original line Diff line number Diff line Loading @@ -230,8 +230,8 @@ static int g_traceBufferSizeKB = 2048; static bool g_compress = false; static bool g_compress = false; static bool g_nohup = false; static bool g_nohup = false; static int g_initialSleepSecs = 0; static int g_initialSleepSecs = 0; static const char* g_categoriesFile = NULL; static const char* g_categoriesFile = nullptr; static const char* g_kernelTraceFuncs = NULL; static const char* g_kernelTraceFuncs = nullptr; static const char* g_debugAppCmdLine = ""; static const char* g_debugAppCmdLine = ""; static const char* g_outputFile = nullptr; static const char* g_outputFile = nullptr; Loading Loading @@ -407,7 +407,7 @@ static bool isCategorySupported(const TracingCategory& category) for (int i = 0; i < MAX_SYS_FILES; i++) { for (int i = 0; i < MAX_SYS_FILES; i++) { const char* path = category.sysfiles[i].path; const char* path = category.sysfiles[i].path; bool req = category.sysfiles[i].required == REQ; bool req = category.sysfiles[i].required == REQ; if (path != NULL) { if (path != nullptr) { if (req) { if (req) { if (!fileIsWritable(path)) { if (!fileIsWritable(path)) { return false; return false; Loading @@ -432,7 +432,7 @@ static bool isCategorySupportedForRoot(const TracingCategory& category) for (int i = 0; i < MAX_SYS_FILES; i++) { for (int i = 0; i < MAX_SYS_FILES; i++) { const char* path = category.sysfiles[i].path; const char* path = category.sysfiles[i].path; bool req = category.sysfiles[i].required == REQ; bool req = category.sysfiles[i].required == REQ; if (path != NULL) { if (path != nullptr) { if (req) { if (req) { if (!fileExists(path)) { if (!fileExists(path)) { return false; return false; Loading Loading @@ -548,10 +548,10 @@ static bool pokeBinderServices() Vector<String16> services = sm->listServices(); Vector<String16> services = sm->listServices(); for (size_t i = 0; i < services.size(); i++) { for (size_t i = 0; i < services.size(); i++) { sp<IBinder> obj = sm->checkService(services[i]); sp<IBinder> obj = sm->checkService(services[i]); if (obj != NULL) { if (obj != nullptr) { Parcel data; Parcel data; if (obj->transact(IBinder::SYSPROPS_TRANSACTION, data, if (obj->transact(IBinder::SYSPROPS_TRANSACTION, data, NULL, 0) != OK) { nullptr, 0) != OK) { if (false) { if (false) { // XXX: For some reason this fails on tablets trying to // XXX: For some reason this fails on tablets trying to // poke the "phone" service. It's not clear whether some // poke the "phone" service. It's not clear whether some Loading Loading @@ -641,9 +641,9 @@ static bool setAppCmdlineProperty(char* cmdline) { { int i = 0; int i = 0; char* start = cmdline; char* start = cmdline; while (start != NULL) { while (start != nullptr) { char* end = strchr(start, ','); char* end = strchr(start, ','); if (end != NULL) { if (end != nullptr) { *end = '\0'; *end = '\0'; end++; end++; } } Loading Loading @@ -673,7 +673,7 @@ static bool disableKernelTraceEvents() { const TracingCategory &c = k_categories[i]; const TracingCategory &c = k_categories[i]; for (int j = 0; j < MAX_SYS_FILES; j++) { for (int j = 0; j < MAX_SYS_FILES; j++) { const char* path = c.sysfiles[j].path; const char* path = c.sysfiles[j].path; if (path != NULL && fileIsWritable(path)) { if (path != nullptr && fileIsWritable(path)) { ok &= setKernelOptionEnable(path, false); ok &= setKernelOptionEnable(path, false); } } } } Loading Loading @@ -709,7 +709,7 @@ static bool verifyKernelTraceFuncs(const char* funcs) ok = false; ok = false; } } } } func = strtok(NULL, ","); func = strtok(nullptr, ","); } } free(myFuncs); free(myFuncs); return ok; return ok; Loading @@ -720,7 +720,7 @@ static bool setKernelTraceFuncs(const char* funcs) { { bool ok = true; bool ok = true; if (funcs == NULL || funcs[0] == '\0') { if (funcs == nullptr || funcs[0] == '\0') { // Disable kernel function tracing. // Disable kernel function tracing. if (fileIsWritable(k_currentTracerPath)) { if (fileIsWritable(k_currentTracerPath)) { ok &= writeStr(k_currentTracerPath, "nop"); ok &= writeStr(k_currentTracerPath, "nop"); Loading @@ -742,7 +742,7 @@ static bool setKernelTraceFuncs(const char* funcs) char* func = strtok(myFuncs, ","); char* func = strtok(myFuncs, ","); while (func) { while (func) { ok &= appendStr(k_ftraceFilterPath, func); ok &= appendStr(k_ftraceFilterPath, func); func = strtok(NULL, ","); func = strtok(nullptr, ","); } } free(myFuncs); free(myFuncs); Loading Loading @@ -784,7 +784,7 @@ static bool setCategoriesEnableFromFile(const char* categories_file) if (!categories_file) { if (!categories_file) { return true; return true; } } Tokenizer* tokenizer = NULL; Tokenizer* tokenizer = nullptr; if (Tokenizer::open(String8(categories_file), &tokenizer) != NO_ERROR) { if (Tokenizer::open(String8(categories_file), &tokenizer) != NO_ERROR) { return false; return false; } } Loading Loading @@ -886,7 +886,7 @@ static bool setUpKernelTracing() for (int j = 0; j < MAX_SYS_FILES; j++) { for (int j = 0; j < MAX_SYS_FILES; j++) { const char* path = c.sysfiles[j].path; const char* path = c.sysfiles[j].path; bool required = c.sysfiles[j].required == REQ; bool required = c.sysfiles[j].required == REQ; if (path != NULL) { if (path != nullptr) { if (fileIsWritable(path)) { if (fileIsWritable(path)) { ok &= setKernelOptionEnable(path, true); ok &= setKernelOptionEnable(path, true); } else if (required) { } else if (required) { Loading @@ -911,7 +911,7 @@ static void cleanUpKernelTracing() setTraceOverwriteEnable(true); setTraceOverwriteEnable(true); setTraceBufferSizeKB(1); setTraceBufferSizeKB(1); setPrintTgidEnableIfPresent(false); setPrintTgidEnableIfPresent(false); setKernelTraceFuncs(NULL); setKernelTraceFuncs(nullptr); setUserInitiatedTraceProperty(false); setUserInitiatedTraceProperty(false); } } Loading Loading @@ -1069,10 +1069,10 @@ static void registerSigHandler() sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sa.sa_flags = 0; sa.sa_handler = handleSignal; sa.sa_handler = handleSignal; sigaction(SIGHUP, &sa, NULL); sigaction(SIGHUP, &sa, nullptr); sigaction(SIGINT, &sa, NULL); sigaction(SIGINT, &sa, nullptr); sigaction(SIGQUIT, &sa, NULL); sigaction(SIGQUIT, &sa, nullptr); sigaction(SIGTERM, &sa, NULL); sigaction(SIGTERM, &sa, nullptr); } } static void listSupportedCategories() static void listSupportedCategories() Loading Loading @@ -1162,13 +1162,13 @@ int main(int argc, char **argv) int ret; int ret; int option_index = 0; int option_index = 0; static struct option long_options[] = { static struct option long_options[] = { {"async_start", no_argument, 0, 0 }, {"async_start", no_argument, nullptr, 0 }, {"async_stop", no_argument, 0, 0 }, {"async_stop", no_argument, nullptr, 0 }, {"async_dump", no_argument, 0, 0 }, {"async_dump", no_argument, nullptr, 0 }, {"only_userspace", no_argument, 0, 0 }, {"only_userspace", no_argument, nullptr, 0 }, {"list_categories", no_argument, 0, 0 }, {"list_categories", no_argument, nullptr, 0 }, {"stream", no_argument, 0, 0 }, {"stream", no_argument, nullptr, 0 }, { 0, 0, 0, 0 } {nullptr, 0, nullptr, 0 } }; }; ret = getopt_long(argc, argv, "a:b:cf:k:ns:t:zo:", ret = getopt_long(argc, argv, "a:b:cf:k:ns:t:zo:", Loading cmds/dumpstate/dumpstate.cpp +6 −6 Original line number Original line Diff line number Diff line Loading @@ -90,7 +90,7 @@ using android::os::dumpstate::PropertiesHelper; /* read before root is shed */ /* read before root is shed */ static char cmdline_buf[16384] = "(unknown)"; 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 // TODO: variables and functions below should be part of dumpstate object Loading Loading @@ -295,7 +295,7 @@ static void dump_dev_files(const char *title, const char *driverpath, const char char path[PATH_MAX]; char path[PATH_MAX]; d = opendir(driverpath); d = opendir(driverpath); if (d == NULL) { if (d == nullptr) { return; return; } } Loading Loading @@ -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) { static int dump_stat_from_fd(const char *title __unused, const char *path, int fd) { unsigned long long fields[__STAT_NUMBER_FIELD]; unsigned long long fields[__STAT_NUMBER_FIELD]; bool z; bool z; char *cp, *buffer = NULL; char *cp, *buffer = nullptr; size_t i = 0; size_t i = 0; FILE *fp = fdopen(dup(fd), "rb"); FILE *fp = fdopen(dup(fd), "rb"); getline(&buffer, &i, fp); getline(&buffer, &i, fp); Loading Loading @@ -1686,7 +1686,7 @@ static std::string SHA256_file_hash(const std::string& filepath) { | O_CLOEXEC | O_NOFOLLOW))); | O_CLOEXEC | O_NOFOLLOW))); if (fd == -1) { if (fd == -1) { MYLOGE("open(%s): %s\n", filepath.c_str(), strerror(errno)); MYLOGE("open(%s): %s\n", filepath.c_str(), strerror(errno)); return NULL; return nullptr; } } SHA256_CTX ctx; SHA256_CTX ctx; Loading @@ -1699,7 +1699,7 @@ static std::string SHA256_file_hash(const std::string& filepath) { break; break; } else if (bytes_read == -1) { } else if (bytes_read == -1) { MYLOGE("read(%s): %s\n", filepath.c_str(), strerror(errno)); MYLOGE("read(%s): %s\n", filepath.c_str(), strerror(errno)); return NULL; return nullptr; } } SHA256_Update(&ctx, buffer.data(), bytes_read); SHA256_Update(&ctx, buffer.data(), bytes_read); Loading Loading @@ -1748,7 +1748,7 @@ int run_main(int argc, char* argv[]) { int do_add_date = 0; int do_add_date = 0; int do_zip_file = 0; int do_zip_file = 0; int do_vibrate = 1; int do_vibrate = 1; char* use_outfile = 0; char* use_outfile = nullptr; int use_socket = 0; int use_socket = 0; int use_control_socket = 0; int use_control_socket = 0; int do_fb = 0; int do_fb = 0; Loading cmds/dumpstate/utils.cpp +6 −6 Original line number Original line Diff line number Diff line Loading @@ -525,13 +525,13 @@ void do_dmesg() { if (PropertiesHelper::IsDryRun()) return; if (PropertiesHelper::IsDryRun()) return; /* Get size of kernel buffer */ /* Get size of kernel buffer */ int size = klogctl(KLOG_SIZE_BUFFER, NULL, 0); int size = klogctl(KLOG_SIZE_BUFFER, nullptr, 0); if (size <= 0) { if (size <= 0) { printf("Unexpected klogctl return value: %d\n\n", size); printf("Unexpected klogctl return value: %d\n\n", size); return; return; } } char *buf = (char *) malloc(size + 1); char *buf = (char *) malloc(size + 1); if (buf == NULL) { if (buf == nullptr) { printf("memory allocation failed\n\n"); printf("memory allocation failed\n\n"); return; return; } } Loading Loading @@ -598,7 +598,7 @@ int dump_files(const std::string& title, const char* dir, bool (*skip)(const cha DurationReporter duration_reporter(title); DurationReporter duration_reporter(title); DIR *dirp; DIR *dirp; struct dirent *d; struct dirent *d; char *newpath = NULL; char *newpath = nullptr; const char *slash = "/"; const char *slash = "/"; int retval = 0; int retval = 0; Loading @@ -611,7 +611,7 @@ int dump_files(const std::string& title, const char* dir, bool (*skip)(const cha ++slash; ++slash; } } dirp = opendir(dir); dirp = opendir(dir); if (dirp == NULL) { if (dirp == nullptr) { retval = -errno; retval = -errno; MYLOGE("%s: %s\n", dir, strerror(errno)); MYLOGE("%s: %s\n", dir, strerror(errno)); return retval; return retval; Loading @@ -620,7 +620,7 @@ int dump_files(const std::string& title, const char* dir, bool (*skip)(const cha if (!dump_from_fd) { if (!dump_from_fd) { dump_from_fd = dump_file_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] == '.') if ((d->d_name[0] == '.') && (((d->d_name[1] == '.') && (d->d_name[2] == '\0')) && (((d->d_name[1] == '.') && (d->d_name[2] == '\0')) || (d->d_name[1] == '\0'))) { || (d->d_name[1] == '\0'))) { Loading Loading @@ -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)); printf("*** %s: %s\n", newpath, strerror(errno)); continue; continue; } } (*dump_from_fd)(NULL, newpath, fd.get()); (*dump_from_fd)(nullptr, newpath, fd.get()); } } closedir(dirp); closedir(dirp); if (!title.empty()) { if (!title.empty()) { Loading cmds/flatland/GLHelper.cpp +15 −15 Original line number Original line Diff line number Diff line Loading @@ -29,7 +29,7 @@ GLHelper::GLHelper() : mContext(EGL_NO_CONTEXT), mContext(EGL_NO_CONTEXT), mDummySurface(EGL_NO_SURFACE), mDummySurface(EGL_NO_SURFACE), mConfig(0), mConfig(0), mShaderPrograms(NULL), mShaderPrograms(nullptr), mDitherTexture(0) { mDitherTexture(0) { } } Loading Loading @@ -101,12 +101,12 @@ bool GLHelper::setUp(const ShaderDesc* shaderDescs, size_t numShaders) { } } void GLHelper::tearDown() { void GLHelper::tearDown() { if (mShaderPrograms != NULL) { if (mShaderPrograms != nullptr) { delete[] mShaderPrograms; delete[] mShaderPrograms; mShaderPrograms = NULL; mShaderPrograms = nullptr; } } if (mSurfaceComposerClient != NULL) { if (mSurfaceComposerClient != nullptr) { mSurfaceComposerClient->dispose(); mSurfaceComposerClient->dispose(); mSurfaceComposerClient.clear(); mSurfaceComposerClient.clear(); } } Loading Loading @@ -210,7 +210,7 @@ bool GLHelper::createNamedSurfaceTexture(GLuint name, uint32_t w, uint32_t h, glc->setConsumerUsageBits(GRALLOC_USAGE_HW_COMPOSER); glc->setConsumerUsageBits(GRALLOC_USAGE_HW_COMPOSER); sp<ANativeWindow> anw = new Surface(producer); 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) { if (s == EGL_NO_SURFACE) { fprintf(stderr, "eglCreateWindowSurface error: %#x\n", eglGetError()); fprintf(stderr, "eglCreateWindowSurface error: %#x\n", eglGetError()); return false; return false; Loading @@ -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) { bool GLHelper::computeWindowScale(uint32_t w, uint32_t h, float* scale) { sp<IBinder> dpy = mSurfaceComposerClient->getBuiltInDisplay(0); sp<IBinder> dpy = mSurfaceComposerClient->getBuiltInDisplay(0); if (dpy == NULL) { if (dpy == nullptr) { fprintf(stderr, "SurfaceComposer::getBuiltInDisplay failed.\n"); fprintf(stderr, "SurfaceComposer::getBuiltInDisplay failed.\n"); return false; return false; } } Loading @@ -247,7 +247,7 @@ bool GLHelper::createWindowSurface(uint32_t w, uint32_t h, bool result; bool result; status_t err; status_t err; if (mSurfaceComposerClient == NULL) { if (mSurfaceComposerClient == nullptr) { mSurfaceComposerClient = new SurfaceComposerClient; mSurfaceComposerClient = new SurfaceComposerClient; } } err = mSurfaceComposerClient->initCheck(); err = mSurfaceComposerClient->initCheck(); Loading @@ -258,7 +258,7 @@ bool GLHelper::createWindowSurface(uint32_t w, uint32_t h, sp<SurfaceControl> sc = mSurfaceComposerClient->createSurface( sp<SurfaceControl> sc = mSurfaceComposerClient->createSurface( String8("Benchmark"), w, h, PIXEL_FORMAT_RGBA_8888, 0); 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"); fprintf(stderr, "Failed to create SurfaceControl.\n"); return false; return false; } } Loading @@ -275,7 +275,7 @@ bool GLHelper::createWindowSurface(uint32_t w, uint32_t h, .apply(); .apply(); sp<ANativeWindow> anw = sc->getSurface(); 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) { if (s == EGL_NO_SURFACE) { fprintf(stderr, "eglCreateWindowSurface error: %#x\n", eglGetError()); fprintf(stderr, "eglCreateWindowSurface error: %#x\n", eglGetError()); return false; return false; Loading @@ -294,7 +294,7 @@ static bool compileShader(GLenum shaderType, const char* src, return false; return false; } } glShaderSource(shader, 1, &src, NULL); glShaderSource(shader, 1, &src, nullptr); glCompileShader(shader); glCompileShader(shader); GLint compiled = 0; GLint compiled = 0; Loading @@ -305,7 +305,7 @@ static bool compileShader(GLenum shaderType, const char* src, if (infoLen) { if (infoLen) { char* buf = new char[infoLen]; char* buf = new char[infoLen]; if (buf) { if (buf) { glGetShaderInfoLog(shader, infoLen, NULL, buf); glGetShaderInfoLog(shader, infoLen, nullptr, buf); fprintf(stderr, "Shader compile log:\n%s\n", buf); fprintf(stderr, "Shader compile log:\n%s\n", buf); delete[] buf; delete[] buf; } } Loading @@ -318,21 +318,21 @@ static bool compileShader(GLenum shaderType, const char* src, } } static void printShaderSource(const char* const* 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]); fprintf(stderr, "%3zu: %s\n", i+1, src[i]); } } } } static const char* makeShaderString(const char* const* src) { static const char* makeShaderString(const char* const* src) { size_t len = 0; 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. // The +1 is for the '\n' that will be added. len += strlen(src[i]) + 1; len += strlen(src[i]) + 1; } } char* result = new char[len+1]; char* result = new char[len+1]; char* end = result; 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]); strcpy(end, src[i]); end += strlen(src[i]); end += strlen(src[i]); *end = '\n'; *end = '\n'; Loading Loading @@ -376,7 +376,7 @@ static bool linkShaderProgram(GLuint vs, GLuint fs, GLuint* outPgm) { if (bufLength) { if (bufLength) { char* buf = new char[bufLength]; char* buf = new char[bufLength]; if (buf) { if (buf) { glGetProgramInfoLog(program, bufLength, NULL, buf); glGetProgramInfoLog(program, bufLength, nullptr, buf); fprintf(stderr, "Program link log:\n%s\n", buf); fprintf(stderr, "Program link log:\n%s\n", buf); delete[] buf; delete[] buf; } } Loading cmds/flatland/Main.cpp +10 −10 Original line number Original line Diff line number Diff line Loading @@ -284,7 +284,7 @@ class Layer { public: public: Layer() : Layer() : mGLHelper(NULL), mGLHelper(nullptr), mSurface(EGL_NO_SURFACE) { mSurface(EGL_NO_SURFACE) { } } Loading Loading @@ -316,23 +316,23 @@ public: } } void tearDown() { void tearDown() { if (mComposer != NULL) { if (mComposer != nullptr) { mComposer->tearDown(); mComposer->tearDown(); delete mComposer; delete mComposer; mComposer = NULL; mComposer = nullptr; } } if (mRenderer != NULL) { if (mRenderer != nullptr) { mRenderer->tearDown(); mRenderer->tearDown(); delete mRenderer; delete mRenderer; mRenderer = NULL; mRenderer = nullptr; } } if (mSurface != EGL_NO_SURFACE) { if (mSurface != EGL_NO_SURFACE) { mGLHelper->destroySurface(&mSurface); mGLHelper->destroySurface(&mSurface); mGLConsumer->abandon(); mGLConsumer->abandon(); } } mGLHelper = NULL; mGLHelper = nullptr; mGLConsumer.clear(); mGLConsumer.clear(); } } Loading Loading @@ -377,7 +377,7 @@ public: mDesc(desc), mDesc(desc), mInstance(instance), mInstance(instance), mNumLayers(countLayers(desc)), mNumLayers(countLayers(desc)), mGLHelper(NULL), mGLHelper(nullptr), mSurface(EGL_NO_SURFACE), mSurface(EGL_NO_SURFACE), mWindowSurface(EGL_NO_SURFACE) { mWindowSurface(EGL_NO_SURFACE) { } } Loading Loading @@ -443,7 +443,7 @@ public: mLayers[i].tearDown(); mLayers[i].tearDown(); } } if (mGLHelper != NULL) { if (mGLHelper != nullptr) { if (mWindowSurface != EGL_NO_SURFACE) { if (mWindowSurface != EGL_NO_SURFACE) { mGLHelper->destroySurface(&mWindowSurface); mGLHelper->destroySurface(&mWindowSurface); } } Loading @@ -453,7 +453,7 @@ public: mSurfaceControl.clear(); mSurfaceControl.clear(); mGLHelper->tearDown(); mGLHelper->tearDown(); delete mGLHelper; delete mGLHelper; mGLHelper = NULL; mGLHelper = nullptr; } } } } Loading Loading @@ -553,7 +553,7 @@ private: static size_t countLayers(const BenchmarkDesc& desc) { static size_t countLayers(const BenchmarkDesc& desc) { size_t i; size_t i; for (i = 0; i < MAX_NUM_LAYERS; i++) { for (i = 0; i < MAX_NUM_LAYERS; i++) { if (desc.layers[i].rendererFactory == NULL) { if (desc.layers[i].rendererFactory == nullptr) { break; break; } } } } Loading Loading
cmds/atrace/atrace.cpp +26 −26 Original line number Original line Diff line number Diff line Loading @@ -230,8 +230,8 @@ static int g_traceBufferSizeKB = 2048; static bool g_compress = false; static bool g_compress = false; static bool g_nohup = false; static bool g_nohup = false; static int g_initialSleepSecs = 0; static int g_initialSleepSecs = 0; static const char* g_categoriesFile = NULL; static const char* g_categoriesFile = nullptr; static const char* g_kernelTraceFuncs = NULL; static const char* g_kernelTraceFuncs = nullptr; static const char* g_debugAppCmdLine = ""; static const char* g_debugAppCmdLine = ""; static const char* g_outputFile = nullptr; static const char* g_outputFile = nullptr; Loading Loading @@ -407,7 +407,7 @@ static bool isCategorySupported(const TracingCategory& category) for (int i = 0; i < MAX_SYS_FILES; i++) { for (int i = 0; i < MAX_SYS_FILES; i++) { const char* path = category.sysfiles[i].path; const char* path = category.sysfiles[i].path; bool req = category.sysfiles[i].required == REQ; bool req = category.sysfiles[i].required == REQ; if (path != NULL) { if (path != nullptr) { if (req) { if (req) { if (!fileIsWritable(path)) { if (!fileIsWritable(path)) { return false; return false; Loading @@ -432,7 +432,7 @@ static bool isCategorySupportedForRoot(const TracingCategory& category) for (int i = 0; i < MAX_SYS_FILES; i++) { for (int i = 0; i < MAX_SYS_FILES; i++) { const char* path = category.sysfiles[i].path; const char* path = category.sysfiles[i].path; bool req = category.sysfiles[i].required == REQ; bool req = category.sysfiles[i].required == REQ; if (path != NULL) { if (path != nullptr) { if (req) { if (req) { if (!fileExists(path)) { if (!fileExists(path)) { return false; return false; Loading Loading @@ -548,10 +548,10 @@ static bool pokeBinderServices() Vector<String16> services = sm->listServices(); Vector<String16> services = sm->listServices(); for (size_t i = 0; i < services.size(); i++) { for (size_t i = 0; i < services.size(); i++) { sp<IBinder> obj = sm->checkService(services[i]); sp<IBinder> obj = sm->checkService(services[i]); if (obj != NULL) { if (obj != nullptr) { Parcel data; Parcel data; if (obj->transact(IBinder::SYSPROPS_TRANSACTION, data, if (obj->transact(IBinder::SYSPROPS_TRANSACTION, data, NULL, 0) != OK) { nullptr, 0) != OK) { if (false) { if (false) { // XXX: For some reason this fails on tablets trying to // XXX: For some reason this fails on tablets trying to // poke the "phone" service. It's not clear whether some // poke the "phone" service. It's not clear whether some Loading Loading @@ -641,9 +641,9 @@ static bool setAppCmdlineProperty(char* cmdline) { { int i = 0; int i = 0; char* start = cmdline; char* start = cmdline; while (start != NULL) { while (start != nullptr) { char* end = strchr(start, ','); char* end = strchr(start, ','); if (end != NULL) { if (end != nullptr) { *end = '\0'; *end = '\0'; end++; end++; } } Loading Loading @@ -673,7 +673,7 @@ static bool disableKernelTraceEvents() { const TracingCategory &c = k_categories[i]; const TracingCategory &c = k_categories[i]; for (int j = 0; j < MAX_SYS_FILES; j++) { for (int j = 0; j < MAX_SYS_FILES; j++) { const char* path = c.sysfiles[j].path; const char* path = c.sysfiles[j].path; if (path != NULL && fileIsWritable(path)) { if (path != nullptr && fileIsWritable(path)) { ok &= setKernelOptionEnable(path, false); ok &= setKernelOptionEnable(path, false); } } } } Loading Loading @@ -709,7 +709,7 @@ static bool verifyKernelTraceFuncs(const char* funcs) ok = false; ok = false; } } } } func = strtok(NULL, ","); func = strtok(nullptr, ","); } } free(myFuncs); free(myFuncs); return ok; return ok; Loading @@ -720,7 +720,7 @@ static bool setKernelTraceFuncs(const char* funcs) { { bool ok = true; bool ok = true; if (funcs == NULL || funcs[0] == '\0') { if (funcs == nullptr || funcs[0] == '\0') { // Disable kernel function tracing. // Disable kernel function tracing. if (fileIsWritable(k_currentTracerPath)) { if (fileIsWritable(k_currentTracerPath)) { ok &= writeStr(k_currentTracerPath, "nop"); ok &= writeStr(k_currentTracerPath, "nop"); Loading @@ -742,7 +742,7 @@ static bool setKernelTraceFuncs(const char* funcs) char* func = strtok(myFuncs, ","); char* func = strtok(myFuncs, ","); while (func) { while (func) { ok &= appendStr(k_ftraceFilterPath, func); ok &= appendStr(k_ftraceFilterPath, func); func = strtok(NULL, ","); func = strtok(nullptr, ","); } } free(myFuncs); free(myFuncs); Loading Loading @@ -784,7 +784,7 @@ static bool setCategoriesEnableFromFile(const char* categories_file) if (!categories_file) { if (!categories_file) { return true; return true; } } Tokenizer* tokenizer = NULL; Tokenizer* tokenizer = nullptr; if (Tokenizer::open(String8(categories_file), &tokenizer) != NO_ERROR) { if (Tokenizer::open(String8(categories_file), &tokenizer) != NO_ERROR) { return false; return false; } } Loading Loading @@ -886,7 +886,7 @@ static bool setUpKernelTracing() for (int j = 0; j < MAX_SYS_FILES; j++) { for (int j = 0; j < MAX_SYS_FILES; j++) { const char* path = c.sysfiles[j].path; const char* path = c.sysfiles[j].path; bool required = c.sysfiles[j].required == REQ; bool required = c.sysfiles[j].required == REQ; if (path != NULL) { if (path != nullptr) { if (fileIsWritable(path)) { if (fileIsWritable(path)) { ok &= setKernelOptionEnable(path, true); ok &= setKernelOptionEnable(path, true); } else if (required) { } else if (required) { Loading @@ -911,7 +911,7 @@ static void cleanUpKernelTracing() setTraceOverwriteEnable(true); setTraceOverwriteEnable(true); setTraceBufferSizeKB(1); setTraceBufferSizeKB(1); setPrintTgidEnableIfPresent(false); setPrintTgidEnableIfPresent(false); setKernelTraceFuncs(NULL); setKernelTraceFuncs(nullptr); setUserInitiatedTraceProperty(false); setUserInitiatedTraceProperty(false); } } Loading Loading @@ -1069,10 +1069,10 @@ static void registerSigHandler() sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sa.sa_flags = 0; sa.sa_handler = handleSignal; sa.sa_handler = handleSignal; sigaction(SIGHUP, &sa, NULL); sigaction(SIGHUP, &sa, nullptr); sigaction(SIGINT, &sa, NULL); sigaction(SIGINT, &sa, nullptr); sigaction(SIGQUIT, &sa, NULL); sigaction(SIGQUIT, &sa, nullptr); sigaction(SIGTERM, &sa, NULL); sigaction(SIGTERM, &sa, nullptr); } } static void listSupportedCategories() static void listSupportedCategories() Loading Loading @@ -1162,13 +1162,13 @@ int main(int argc, char **argv) int ret; int ret; int option_index = 0; int option_index = 0; static struct option long_options[] = { static struct option long_options[] = { {"async_start", no_argument, 0, 0 }, {"async_start", no_argument, nullptr, 0 }, {"async_stop", no_argument, 0, 0 }, {"async_stop", no_argument, nullptr, 0 }, {"async_dump", no_argument, 0, 0 }, {"async_dump", no_argument, nullptr, 0 }, {"only_userspace", no_argument, 0, 0 }, {"only_userspace", no_argument, nullptr, 0 }, {"list_categories", no_argument, 0, 0 }, {"list_categories", no_argument, nullptr, 0 }, {"stream", no_argument, 0, 0 }, {"stream", no_argument, nullptr, 0 }, { 0, 0, 0, 0 } {nullptr, 0, nullptr, 0 } }; }; ret = getopt_long(argc, argv, "a:b:cf:k:ns:t:zo:", ret = getopt_long(argc, argv, "a:b:cf:k:ns:t:zo:", Loading
cmds/dumpstate/dumpstate.cpp +6 −6 Original line number Original line Diff line number Diff line Loading @@ -90,7 +90,7 @@ using android::os::dumpstate::PropertiesHelper; /* read before root is shed */ /* read before root is shed */ static char cmdline_buf[16384] = "(unknown)"; 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 // TODO: variables and functions below should be part of dumpstate object Loading Loading @@ -295,7 +295,7 @@ static void dump_dev_files(const char *title, const char *driverpath, const char char path[PATH_MAX]; char path[PATH_MAX]; d = opendir(driverpath); d = opendir(driverpath); if (d == NULL) { if (d == nullptr) { return; return; } } Loading Loading @@ -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) { static int dump_stat_from_fd(const char *title __unused, const char *path, int fd) { unsigned long long fields[__STAT_NUMBER_FIELD]; unsigned long long fields[__STAT_NUMBER_FIELD]; bool z; bool z; char *cp, *buffer = NULL; char *cp, *buffer = nullptr; size_t i = 0; size_t i = 0; FILE *fp = fdopen(dup(fd), "rb"); FILE *fp = fdopen(dup(fd), "rb"); getline(&buffer, &i, fp); getline(&buffer, &i, fp); Loading Loading @@ -1686,7 +1686,7 @@ static std::string SHA256_file_hash(const std::string& filepath) { | O_CLOEXEC | O_NOFOLLOW))); | O_CLOEXEC | O_NOFOLLOW))); if (fd == -1) { if (fd == -1) { MYLOGE("open(%s): %s\n", filepath.c_str(), strerror(errno)); MYLOGE("open(%s): %s\n", filepath.c_str(), strerror(errno)); return NULL; return nullptr; } } SHA256_CTX ctx; SHA256_CTX ctx; Loading @@ -1699,7 +1699,7 @@ static std::string SHA256_file_hash(const std::string& filepath) { break; break; } else if (bytes_read == -1) { } else if (bytes_read == -1) { MYLOGE("read(%s): %s\n", filepath.c_str(), strerror(errno)); MYLOGE("read(%s): %s\n", filepath.c_str(), strerror(errno)); return NULL; return nullptr; } } SHA256_Update(&ctx, buffer.data(), bytes_read); SHA256_Update(&ctx, buffer.data(), bytes_read); Loading Loading @@ -1748,7 +1748,7 @@ int run_main(int argc, char* argv[]) { int do_add_date = 0; int do_add_date = 0; int do_zip_file = 0; int do_zip_file = 0; int do_vibrate = 1; int do_vibrate = 1; char* use_outfile = 0; char* use_outfile = nullptr; int use_socket = 0; int use_socket = 0; int use_control_socket = 0; int use_control_socket = 0; int do_fb = 0; int do_fb = 0; Loading
cmds/dumpstate/utils.cpp +6 −6 Original line number Original line Diff line number Diff line Loading @@ -525,13 +525,13 @@ void do_dmesg() { if (PropertiesHelper::IsDryRun()) return; if (PropertiesHelper::IsDryRun()) return; /* Get size of kernel buffer */ /* Get size of kernel buffer */ int size = klogctl(KLOG_SIZE_BUFFER, NULL, 0); int size = klogctl(KLOG_SIZE_BUFFER, nullptr, 0); if (size <= 0) { if (size <= 0) { printf("Unexpected klogctl return value: %d\n\n", size); printf("Unexpected klogctl return value: %d\n\n", size); return; return; } } char *buf = (char *) malloc(size + 1); char *buf = (char *) malloc(size + 1); if (buf == NULL) { if (buf == nullptr) { printf("memory allocation failed\n\n"); printf("memory allocation failed\n\n"); return; return; } } Loading Loading @@ -598,7 +598,7 @@ int dump_files(const std::string& title, const char* dir, bool (*skip)(const cha DurationReporter duration_reporter(title); DurationReporter duration_reporter(title); DIR *dirp; DIR *dirp; struct dirent *d; struct dirent *d; char *newpath = NULL; char *newpath = nullptr; const char *slash = "/"; const char *slash = "/"; int retval = 0; int retval = 0; Loading @@ -611,7 +611,7 @@ int dump_files(const std::string& title, const char* dir, bool (*skip)(const cha ++slash; ++slash; } } dirp = opendir(dir); dirp = opendir(dir); if (dirp == NULL) { if (dirp == nullptr) { retval = -errno; retval = -errno; MYLOGE("%s: %s\n", dir, strerror(errno)); MYLOGE("%s: %s\n", dir, strerror(errno)); return retval; return retval; Loading @@ -620,7 +620,7 @@ int dump_files(const std::string& title, const char* dir, bool (*skip)(const cha if (!dump_from_fd) { if (!dump_from_fd) { dump_from_fd = dump_file_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] == '.') if ((d->d_name[0] == '.') && (((d->d_name[1] == '.') && (d->d_name[2] == '\0')) && (((d->d_name[1] == '.') && (d->d_name[2] == '\0')) || (d->d_name[1] == '\0'))) { || (d->d_name[1] == '\0'))) { Loading Loading @@ -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)); printf("*** %s: %s\n", newpath, strerror(errno)); continue; continue; } } (*dump_from_fd)(NULL, newpath, fd.get()); (*dump_from_fd)(nullptr, newpath, fd.get()); } } closedir(dirp); closedir(dirp); if (!title.empty()) { if (!title.empty()) { Loading
cmds/flatland/GLHelper.cpp +15 −15 Original line number Original line Diff line number Diff line Loading @@ -29,7 +29,7 @@ GLHelper::GLHelper() : mContext(EGL_NO_CONTEXT), mContext(EGL_NO_CONTEXT), mDummySurface(EGL_NO_SURFACE), mDummySurface(EGL_NO_SURFACE), mConfig(0), mConfig(0), mShaderPrograms(NULL), mShaderPrograms(nullptr), mDitherTexture(0) { mDitherTexture(0) { } } Loading Loading @@ -101,12 +101,12 @@ bool GLHelper::setUp(const ShaderDesc* shaderDescs, size_t numShaders) { } } void GLHelper::tearDown() { void GLHelper::tearDown() { if (mShaderPrograms != NULL) { if (mShaderPrograms != nullptr) { delete[] mShaderPrograms; delete[] mShaderPrograms; mShaderPrograms = NULL; mShaderPrograms = nullptr; } } if (mSurfaceComposerClient != NULL) { if (mSurfaceComposerClient != nullptr) { mSurfaceComposerClient->dispose(); mSurfaceComposerClient->dispose(); mSurfaceComposerClient.clear(); mSurfaceComposerClient.clear(); } } Loading Loading @@ -210,7 +210,7 @@ bool GLHelper::createNamedSurfaceTexture(GLuint name, uint32_t w, uint32_t h, glc->setConsumerUsageBits(GRALLOC_USAGE_HW_COMPOSER); glc->setConsumerUsageBits(GRALLOC_USAGE_HW_COMPOSER); sp<ANativeWindow> anw = new Surface(producer); 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) { if (s == EGL_NO_SURFACE) { fprintf(stderr, "eglCreateWindowSurface error: %#x\n", eglGetError()); fprintf(stderr, "eglCreateWindowSurface error: %#x\n", eglGetError()); return false; return false; Loading @@ -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) { bool GLHelper::computeWindowScale(uint32_t w, uint32_t h, float* scale) { sp<IBinder> dpy = mSurfaceComposerClient->getBuiltInDisplay(0); sp<IBinder> dpy = mSurfaceComposerClient->getBuiltInDisplay(0); if (dpy == NULL) { if (dpy == nullptr) { fprintf(stderr, "SurfaceComposer::getBuiltInDisplay failed.\n"); fprintf(stderr, "SurfaceComposer::getBuiltInDisplay failed.\n"); return false; return false; } } Loading @@ -247,7 +247,7 @@ bool GLHelper::createWindowSurface(uint32_t w, uint32_t h, bool result; bool result; status_t err; status_t err; if (mSurfaceComposerClient == NULL) { if (mSurfaceComposerClient == nullptr) { mSurfaceComposerClient = new SurfaceComposerClient; mSurfaceComposerClient = new SurfaceComposerClient; } } err = mSurfaceComposerClient->initCheck(); err = mSurfaceComposerClient->initCheck(); Loading @@ -258,7 +258,7 @@ bool GLHelper::createWindowSurface(uint32_t w, uint32_t h, sp<SurfaceControl> sc = mSurfaceComposerClient->createSurface( sp<SurfaceControl> sc = mSurfaceComposerClient->createSurface( String8("Benchmark"), w, h, PIXEL_FORMAT_RGBA_8888, 0); 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"); fprintf(stderr, "Failed to create SurfaceControl.\n"); return false; return false; } } Loading @@ -275,7 +275,7 @@ bool GLHelper::createWindowSurface(uint32_t w, uint32_t h, .apply(); .apply(); sp<ANativeWindow> anw = sc->getSurface(); 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) { if (s == EGL_NO_SURFACE) { fprintf(stderr, "eglCreateWindowSurface error: %#x\n", eglGetError()); fprintf(stderr, "eglCreateWindowSurface error: %#x\n", eglGetError()); return false; return false; Loading @@ -294,7 +294,7 @@ static bool compileShader(GLenum shaderType, const char* src, return false; return false; } } glShaderSource(shader, 1, &src, NULL); glShaderSource(shader, 1, &src, nullptr); glCompileShader(shader); glCompileShader(shader); GLint compiled = 0; GLint compiled = 0; Loading @@ -305,7 +305,7 @@ static bool compileShader(GLenum shaderType, const char* src, if (infoLen) { if (infoLen) { char* buf = new char[infoLen]; char* buf = new char[infoLen]; if (buf) { if (buf) { glGetShaderInfoLog(shader, infoLen, NULL, buf); glGetShaderInfoLog(shader, infoLen, nullptr, buf); fprintf(stderr, "Shader compile log:\n%s\n", buf); fprintf(stderr, "Shader compile log:\n%s\n", buf); delete[] buf; delete[] buf; } } Loading @@ -318,21 +318,21 @@ static bool compileShader(GLenum shaderType, const char* src, } } static void printShaderSource(const char* const* 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]); fprintf(stderr, "%3zu: %s\n", i+1, src[i]); } } } } static const char* makeShaderString(const char* const* src) { static const char* makeShaderString(const char* const* src) { size_t len = 0; 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. // The +1 is for the '\n' that will be added. len += strlen(src[i]) + 1; len += strlen(src[i]) + 1; } } char* result = new char[len+1]; char* result = new char[len+1]; char* end = result; 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]); strcpy(end, src[i]); end += strlen(src[i]); end += strlen(src[i]); *end = '\n'; *end = '\n'; Loading Loading @@ -376,7 +376,7 @@ static bool linkShaderProgram(GLuint vs, GLuint fs, GLuint* outPgm) { if (bufLength) { if (bufLength) { char* buf = new char[bufLength]; char* buf = new char[bufLength]; if (buf) { if (buf) { glGetProgramInfoLog(program, bufLength, NULL, buf); glGetProgramInfoLog(program, bufLength, nullptr, buf); fprintf(stderr, "Program link log:\n%s\n", buf); fprintf(stderr, "Program link log:\n%s\n", buf); delete[] buf; delete[] buf; } } Loading
cmds/flatland/Main.cpp +10 −10 Original line number Original line Diff line number Diff line Loading @@ -284,7 +284,7 @@ class Layer { public: public: Layer() : Layer() : mGLHelper(NULL), mGLHelper(nullptr), mSurface(EGL_NO_SURFACE) { mSurface(EGL_NO_SURFACE) { } } Loading Loading @@ -316,23 +316,23 @@ public: } } void tearDown() { void tearDown() { if (mComposer != NULL) { if (mComposer != nullptr) { mComposer->tearDown(); mComposer->tearDown(); delete mComposer; delete mComposer; mComposer = NULL; mComposer = nullptr; } } if (mRenderer != NULL) { if (mRenderer != nullptr) { mRenderer->tearDown(); mRenderer->tearDown(); delete mRenderer; delete mRenderer; mRenderer = NULL; mRenderer = nullptr; } } if (mSurface != EGL_NO_SURFACE) { if (mSurface != EGL_NO_SURFACE) { mGLHelper->destroySurface(&mSurface); mGLHelper->destroySurface(&mSurface); mGLConsumer->abandon(); mGLConsumer->abandon(); } } mGLHelper = NULL; mGLHelper = nullptr; mGLConsumer.clear(); mGLConsumer.clear(); } } Loading Loading @@ -377,7 +377,7 @@ public: mDesc(desc), mDesc(desc), mInstance(instance), mInstance(instance), mNumLayers(countLayers(desc)), mNumLayers(countLayers(desc)), mGLHelper(NULL), mGLHelper(nullptr), mSurface(EGL_NO_SURFACE), mSurface(EGL_NO_SURFACE), mWindowSurface(EGL_NO_SURFACE) { mWindowSurface(EGL_NO_SURFACE) { } } Loading Loading @@ -443,7 +443,7 @@ public: mLayers[i].tearDown(); mLayers[i].tearDown(); } } if (mGLHelper != NULL) { if (mGLHelper != nullptr) { if (mWindowSurface != EGL_NO_SURFACE) { if (mWindowSurface != EGL_NO_SURFACE) { mGLHelper->destroySurface(&mWindowSurface); mGLHelper->destroySurface(&mWindowSurface); } } Loading @@ -453,7 +453,7 @@ public: mSurfaceControl.clear(); mSurfaceControl.clear(); mGLHelper->tearDown(); mGLHelper->tearDown(); delete mGLHelper; delete mGLHelper; mGLHelper = NULL; mGLHelper = nullptr; } } } } Loading Loading @@ -553,7 +553,7 @@ private: static size_t countLayers(const BenchmarkDesc& desc) { static size_t countLayers(const BenchmarkDesc& desc) { size_t i; size_t i; for (i = 0; i < MAX_NUM_LAYERS; i++) { for (i = 0; i < MAX_NUM_LAYERS; i++) { if (desc.layers[i].rendererFactory == NULL) { if (desc.layers[i].rendererFactory == nullptr) { break; break; } } } } Loading