diff options
author | Yan Wang <yawanng@google.com> | 2017-08-10 17:18:10 +0000 |
---|---|---|
committer | Yan Wang <yawanng@google.com> | 2017-08-10 17:18:10 +0000 |
commit | d61c2a18cb98607bf2897b6a5ed23164d9d1cb32 (patch) | |
tree | 6600d18cdd513e8affbad70c2d2301ea0eb5b29d /clang-tools-extra/clang-tidy/android/AndroidTidyModule.cpp | |
parent | 75023dbf51ec620027e592caf7925bdaed974cb0 (diff) | |
download | bcm5719-llvm-d61c2a18cb98607bf2897b6a5ed23164d9d1cb32.tar.gz bcm5719-llvm-d61c2a18cb98607bf2897b6a5ed23164d9d1cb32.zip |
[clang-tidy] Refactor the code and add a close-on-exec check on memfd_create() in Android module.
Summary:
1. Refactor the structure of the code by adding a base class for all close-on-exec checks, which implements most of the needed functions.
2. memfd_create() is better to set MFD_CLOEXEC flag to avoid file descriptor leakage.
Reviewers: alexfh, aaron.ballman, hokein
Reviewed By: alexfh, hokein
Subscribers: Eugene.Zelenko, chh, cfe-commits, srhines, mgorny, JDevlieghere, xazax.hun
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D35372
llvm-svn: 310630
Diffstat (limited to 'clang-tools-extra/clang-tidy/android/AndroidTidyModule.cpp')
-rw-r--r-- | clang-tools-extra/clang-tidy/android/AndroidTidyModule.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/android/AndroidTidyModule.cpp b/clang-tools-extra/clang-tidy/android/AndroidTidyModule.cpp index 119f3c0db8b..729047ee35e 100644 --- a/clang-tools-extra/clang-tidy/android/AndroidTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/android/AndroidTidyModule.cpp @@ -12,6 +12,7 @@ #include "../ClangTidyModuleRegistry.h" #include "CloexecCreatCheck.h" #include "CloexecFopenCheck.h" +#include "CloexecMemfdCreateCheck.h" #include "CloexecOpenCheck.h" #include "CloexecSocketCheck.h" @@ -27,6 +28,8 @@ public: void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { CheckFactories.registerCheck<CloexecCreatCheck>("android-cloexec-creat"); CheckFactories.registerCheck<CloexecFopenCheck>("android-cloexec-fopen"); + CheckFactories.registerCheck<CloexecMemfdCreateCheck>( + "android-cloexec-memfd-create"); CheckFactories.registerCheck<CloexecOpenCheck>("android-cloexec-open"); CheckFactories.registerCheck<CloexecSocketCheck>("android-cloexec-socket"); } |