summaryrefslogtreecommitdiff
path: root/adb/daemon/file_sync_service.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/daemon/file_sync_service.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/daemon/file_sync_service.cpp')
-rw-r--r--adb/daemon/file_sync_service.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/adb/daemon/file_sync_service.cpp b/adb/daemon/file_sync_service.cpp
index e82a51f2b..9d5015119 100644
--- a/adb/daemon/file_sync_service.cpp
+++ b/adb/daemon/file_sync_service.cpp
@@ -235,8 +235,8 @@ static bool handle_send_file(int s, const char* path, uint32_t* timestamp, uid_t
unique_fd fd(adb_open_mode(path, O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC, mode));
- if (posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL | POSIX_FADV_NOREUSE | POSIX_FADV_WILLNEED) <
- 0) {
+ if (posix_fadvise(fd.get(), 0, 0,
+ POSIX_FADV_SEQUENTIAL | POSIX_FADV_NOREUSE | POSIX_FADV_WILLNEED) < 0) {
D("[ Failed to fadvise: %d ]", errno);
}
@@ -464,8 +464,9 @@ static bool do_recv(int s, const char* path, std::vector<char>& buffer) {
return false;
}
- if (posix_fadvise(fd.get(), 0, 0, POSIX_FADV_SEQUENTIAL | POSIX_FADV_NOREUSE) < 0) {
- D("[ Failed to fadvise: %d ]", errno);
+ int rc = posix_fadvise(fd.get(), 0, 0, POSIX_FADV_SEQUENTIAL | POSIX_FADV_NOREUSE);
+ if (rc != 0) {
+ D("[ Failed to fadvise: %d ]", rc);
}
syncmsg msg;