Fix modernize-use-nullptr clang-tidy issues
This CL also includes a few exceptions to the android-cloexec-open
check in profile_assistant_test.cc, which are required to make
clang-tidy run without any errors.
Bug: 213953102
Test: m tidy-art
Change-Id: I4d99b51a2d2c1837ef350d44965d386738b74065
diff --git a/build/Android.bp b/build/Android.bp
index 434a658..c0323b4 100644
--- a/build/Android.bp
+++ b/build/Android.bp
@@ -36,6 +36,7 @@
"bugprone-virtual-near-miss",
"misc-unused-using-decls",
"modernize-use-bool-literals",
+ "modernize-use-nullptr",
"performance-faster-string-find",
"performance-for-range-copy",
"performance-implicit-conversion-in-loop",
@@ -49,7 +50,6 @@
// when all files are free of these warnings.
"android-cloexec-dup",
"bugprone-unused-return-value",
- "modernize-use-nullptr",
"modernize-use-using", // TODO: move to art_clang_tidy_errors after b/236243696 is done
]
diff --git a/profman/profile_assistant_test.cc b/profman/profile_assistant_test.cc
index 01b385a..4fc8143 100644
--- a/profman/profile_assistant_test.cc
+++ b/profman/profile_assistant_test.cc
@@ -1840,6 +1840,7 @@
// Run profman and pass the dex file with --apk-fd.
android::base::unique_fd apk_fd(
+ // NOLINTNEXTLINE - Profman needs file to be opened after fork() and exec()
open(GetTestDexFileName("ProfileTestMultiDex").c_str(), O_RDONLY));
ASSERT_GE(apk_fd.get(), 0);
@@ -1882,6 +1883,7 @@
// Run profman and pass the dex file with --apk-fd.
android::base::unique_fd apk_fd(
+ // NOLINTNEXTLINE - Profman needs file to be opened after fork() and exec()
open(GetTestDexFileName("ProfileTestMultiDex").c_str(), O_RDONLY));
ASSERT_GE(apk_fd.get(), 0);
@@ -1919,6 +1921,7 @@
// Run profman and pass the dex file with --apk-fd.
android::base::unique_fd apk_fd(
+ // NOLINTNEXTLINE - Profman needs file to be opened after fork() and exec()
open(GetTestDexFileName("ProfileTestMultiDex").c_str(), O_RDONLY));
ASSERT_GE(apk_fd.get(), 0);
@@ -1957,6 +1960,7 @@
// Run profman and pass the real dex file with --apk-fd.
android::base::unique_fd apk_fd(
+ // NOLINTNEXTLINE - Profman needs file to be opened after fork() and exec()
open(GetTestDexFileName("ProfileTestMultiDex").c_str(), O_RDONLY));
ASSERT_GE(apk_fd.get(), 0);
@@ -2003,7 +2007,8 @@
// Run profman and pass the dex file with --apk-fd.
android::base::unique_fd apk_fd(
- open(GetTestDexFileName("ProfileTestMultiDex").c_str(), O_RDONLY)); // NOLINT
+ // NOLINTNEXTLINE - Profman needs file to be opened after fork() and exec()
+ open(GetTestDexFileName("ProfileTestMultiDex").c_str(), O_RDONLY));
ASSERT_GE(apk_fd.get(), 0);
std::string profman_cmd = GetProfmanCmd();
@@ -2050,6 +2055,7 @@
// Run profman and pass the real dex file with --apk-fd. It won't match any entry in the profile.
android::base::unique_fd apk_fd(
+ // NOLINTNEXTLINE - Profman needs file to be opened after fork() and exec()
open(GetTestDexFileName("ProfileTestMultiDex").c_str(), O_RDONLY));
ASSERT_GE(apk_fd.get(), 0);
@@ -2171,7 +2177,8 @@
// Run profman and pass the dex file with --apk-fd.
android::base::unique_fd apk_fd(
- open(GetTestDexFileName("ProfileTestMultiDex").c_str(), O_RDONLY)); // NOLINT
+ // NOLINTNEXTLINE - Profman needs file to be opened after fork() and exec()
+ open(GetTestDexFileName("ProfileTestMultiDex").c_str(), O_RDONLY));
ASSERT_GE(apk_fd.get(), 0);
std::string profman_cmd = GetProfmanCmd();
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 94c539f..0c146d5 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -4000,7 +4000,7 @@
// (PC shall be known thanks to the runtime frame for throwing SIOOBE).
// Note that JIT does not emit that intrinic implementation.
const void* pc = reinterpret_cast<const void*>(GetCurrentQuickFramePc());
- if (pc != 0u && Runtime::Current()->GetHeap()->IsInBootImageOatFile(pc)) {
+ if (pc != nullptr && Runtime::Current()->GetHeap()->IsInBootImageOatFile(pc)) {
return;
}
}