summaryrefslogtreecommitdiff
path: root/cmds/idmap2
diff options
context:
space:
mode:
author Yi Kong <yikong@google.com> 2019-08-15 13:27:46 -0700
committer Yi Kong <yikong@google.com> 2019-08-15 15:27:33 -0700
commitf61e2167d5352b63eb34a086cdcb0dfec485bdf0 (patch)
treea417ebd00b8852ec9fafbd49932a793a8569a6ad /cmds/idmap2
parentfba8f5688841429ef2277c44d0b1e07e01451507 (diff)
Fix android-cloexec-pipe clang-tidy warning
The upcoming clang-tidy update finds a new instance of android-cloexec-pipe warning: FileUtilsTests.cpp:72:13: error: prefer pipe2() with O_CLOEXEC to avoid leaking file descriptors to child processes ASSERT_EQ(pipe(pipefd), 0); ^~~~~~~~~~~~ pipe2(pipefd, O_CLOEXEC) Apply the suggested fix by clang-tidy. Test: build Bug: 131328001 Change-Id: Iee772b5c3ed5e2af481e479dab19030f8419290a
Diffstat (limited to 'cmds/idmap2')
-rw-r--r--cmds/idmap2/tests/FileUtilsTests.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/cmds/idmap2/tests/FileUtilsTests.cpp b/cmds/idmap2/tests/FileUtilsTests.cpp
index f4a306e41e32..f55acee029dc 100644
--- a/cmds/idmap2/tests/FileUtilsTests.cpp
+++ b/cmds/idmap2/tests/FileUtilsTests.cpp
@@ -15,6 +15,7 @@
*/
#include <dirent.h>
+#include <fcntl.h>
#include <set>
#include <string>
@@ -69,7 +70,7 @@ TEST(FileUtilsTests, FindFilesFindApkFilesRecursive) {
TEST(FileUtilsTests, ReadFile) {
int pipefd[2];
- ASSERT_EQ(pipe(pipefd), 0);
+ ASSERT_EQ(pipe2(pipefd, O_CLOEXEC), 0);
ASSERT_EQ(write(pipefd[1], "foobar", 6), 6);
close(pipefd[1]);