summaryrefslogtreecommitdiff
path: root/adb/adb_utils_test.cpp
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2019-04-18 16:39:30 -0700
committerJosh Gao <jmgao@google.com>2019-04-24 12:59:42 -0700
commit93d63c010ae24ff58acb70216bfcb93e3c73019a (patch)
tree808e8d5767b36c7eda9a87b09a215333b5d78d7a /adb/adb_utils_test.cpp
parent499601b94fa36759648542039d3df25e901ebb77 (diff)
Add a way to turn off unique_fd's operator int.
unique_fd's implicit conversion to int has led to tons of problems (see all of the overloads for close, fdopen, fdopendir, etc.). Add a switch that can turn it off, and reduce the ridiculous amount of work to fix up callers by introducing a borrowed_fd type that can be constructed from either int or unique_fd. Test: treehugger Change-Id: If77cf5cbcaddacdaec5919a15b3520fb68f51a62
Diffstat (limited to 'adb/adb_utils_test.cpp')
-rw-r--r--adb/adb_utils_test.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/adb/adb_utils_test.cpp b/adb/adb_utils_test.cpp
index bd676c2deb..cdca3aa321 100644
--- a/adb/adb_utils_test.cpp
+++ b/adb/adb_utils_test.cpp
@@ -149,13 +149,13 @@ TEST(adb_utils, mkdirs) {
TEST(adb_utils, set_file_block_mode) {
unique_fd fd(adb_open("/dev/null", O_RDWR | O_APPEND));
ASSERT_GE(fd, 0);
- int flags = fcntl(fd, F_GETFL, 0);
+ int flags = fcntl(fd.get(), F_GETFL, 0);
ASSERT_EQ(O_RDWR | O_APPEND, (flags & (O_RDWR | O_APPEND)));
ASSERT_TRUE(set_file_block_mode(fd, false));
- int new_flags = fcntl(fd, F_GETFL, 0);
+ int new_flags = fcntl(fd.get(), F_GETFL, 0);
ASSERT_EQ(flags | O_NONBLOCK, new_flags);
ASSERT_TRUE(set_file_block_mode(fd, true));
- new_flags = fcntl(fd, F_GETFL, 0);
+ new_flags = fcntl(fd.get(), F_GETFL, 0);
ASSERT_EQ(flags, new_flags);
}
#endif