From e7e01f7921945b3edde031823d9715cc953d01dc Mon Sep 17 00:00:00 2001 From: RikkaW Date: Thu, 25 Oct 2018 14:11:17 +0800 Subject: [PATCH] solve some Clang-Tidy check problem --- riru-core/jni/main/init.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/riru-core/jni/main/init.cpp b/riru-core/jni/main/init.cpp index e292a713..286eb889 100644 --- a/riru-core/jni/main/init.cpp +++ b/riru-core/jni/main/init.cpp @@ -40,7 +40,7 @@ void init(JNIEnv *jniEnv); std::vector *get_modules() { - static std::vector *modules = new std::vector(); + static auto *modules = new std::vector(); return modules; } @@ -71,13 +71,13 @@ void load_modules() { continue; } - handle = dlopen(path, RTLD_LAZY | RTLD_LOCAL); + handle = dlopen(path, RTLD_NOW | RTLD_GLOBAL); if (!handle) { PLOGE("dlopen %s", path); continue; } - module *module = new struct module(); + auto *module = new struct module(); module->handle = handle; module->name = strdup(entry->d_name); module->onModuleLoaded = dlsym(handle, "onModuleLoaded"); @@ -154,11 +154,11 @@ void con() { } } -static JNINativeMethod gMethods[] = {{NULL, NULL, NULL}, - {NULL, NULL, NULL}}; +static JNINativeMethod gMethods[] = {{nullptr, nullptr, nullptr}, + {nullptr, nullptr, nullptr}}; -void *_nativeForkAndSpecialize = NULL; -void *_nativeForkSystemServer = NULL; +void *_nativeForkAndSpecialize = nullptr; +void *_nativeForkSystemServer = nullptr; JNINativeMethod *search_method(int endian, std::vector> addresses, const char *name, size_t len) { @@ -179,18 +179,18 @@ JNINativeMethod *search_method(int endian, std::vector> i * 8); - JNINativeMethod *method = NULL; + JNINativeMethod *method = nullptr; for (auto address : addresses) { void *res = memsearch(address.first, address.second, data, size); if (res) { @@ -207,7 +207,7 @@ JNINativeMethod *search_method(int endian, std::vector> addresses; - int fd = open("/proc/self/maps", O_RDONLY); + int fd = open("/proc/self/maps", O_RDONLY | O_CLOEXEC); if (fd == -1) { LOGE("open /proc/self/maps failed."); return; @@ -255,7 +255,7 @@ void init(JNIEnv *jniEnv) { continue; if (strcmp(ANDROID_RUNTIME_LIBRARY, filename) == 0) { - addresses.push_back(std::pair(start, end)); + addresses.emplace_back(start, end); LOGD("%lx %lx %s %s", start, end, flags, filename); } }