Move "android-cloexec-dup" into art_clang_tidy_errors
As part of the changes done in aosp/742964, an helper method called
DupCloexec was defined in libartbase/base/file_utils.{h, cc} specifically
to provide a single entry point for all places in need to call the
dup(2) system call, replacing it with fcntl with the F_DUPFD_CLOEXEC
flag whenever possible. Hence, it should be safe to ignore the warning
triggered by clang-tidy within the DupCloexec method, and set
"android-cloexec-dup" among the clang-tidy errors to prevent it
from happening again in the future.
Bug: 213953102
Test: m tidy-art
Change-Id: Ia16b805dc37d2d842feb0636f4cb459f989ac4bd
diff --git a/build/Android.bp b/build/Android.bp
index ccc30ef..382b0a3 100644
--- a/build/Android.bp
+++ b/build/Android.bp
@@ -28,6 +28,7 @@
}
art_clang_tidy_errors = [
+ "android-cloexec-dup",
"android-cloexec-open",
"bugprone-argument-comment",
"bugprone-lambda-function-name",
@@ -46,12 +47,6 @@
"performance-unnecessary-value-param",
]
-art_clang_tidy_allowed = [
- // Many files have these warnings. Move them to art_clang_tidy_errors
- // when all files are free of these warnings.
- "android-cloexec-dup",
-]
-
art_clang_tidy_disabled = [
"-google-default-arguments",
// We have local stores that are only used for debug checks.
@@ -249,7 +244,7 @@
},
},
- tidy_checks: art_clang_tidy_errors + art_clang_tidy_allowed + art_clang_tidy_disabled,
+ tidy_checks: art_clang_tidy_errors + art_clang_tidy_disabled,
tidy_checks_as_errors: art_clang_tidy_errors,
diff --git a/libartbase/base/file_utils.cc b/libartbase/base/file_utils.cc
index ed883f8..2396289 100644
--- a/libartbase/base/file_utils.cc
+++ b/libartbase/base/file_utils.cc
@@ -735,7 +735,7 @@
#if defined(__linux__)
return fcntl(fd, F_DUPFD_CLOEXEC, 0);
#else
- return dup(fd);
+ return dup(fd); // NOLINT
#endif
}