From 362b4041f3162ef3d219d6bcebdd5170ae28a662 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Wed, 10 May 2017 13:51:36 -0700 Subject: [PATCH] adb: fix darwin build break. Fix the following build breakage: system/core/adb/client/usb_osx.cpp:433:13: error: static declaration of 'usb_cleanup' follows non-static declaration static void usb_cleanup() NO_THREAD_SAFETY_ANALYSIS { ^ system/core/adb/usb.h:48:5: note: previous declaration is here ADB_USB_INTERFACE(native::usb_handle*); Bug: http://b/38203892 Test: mma on linux, darwin Change-Id: I1c042e4d64ddcc0713f329202bc2037e590a9b4f --- adb/client/usb_dispatch.cpp | 2 ++ adb/client/usb_linux.cpp | 3 +++ adb/client/usb_osx.cpp | 4 +--- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/adb/client/usb_dispatch.cpp b/adb/client/usb_dispatch.cpp index c4eed7876..ce5773175 100644 --- a/adb/client/usb_dispatch.cpp +++ b/adb/client/usb_dispatch.cpp @@ -30,6 +30,8 @@ void usb_init() { void usb_cleanup() { if (should_use_libusb()) { libusb::usb_cleanup(); + } else { + native::usb_cleanup(); } } diff --git a/adb/client/usb_linux.cpp b/adb/client/usb_linux.cpp index f9ba7cbc2..a7df0ed51 100644 --- a/adb/client/usb_linux.cpp +++ b/adb/client/usb_linux.cpp @@ -598,4 +598,7 @@ void usb_init() { std::thread(device_poll_thread).detach(); } + +void usb_cleanup() {} + } // namespace native diff --git a/adb/client/usb_osx.cpp b/adb/client/usb_osx.cpp index e36675493..4e1480f7b 100644 --- a/adb/client/usb_osx.cpp +++ b/adb/client/usb_osx.cpp @@ -430,7 +430,7 @@ static void RunLoopThread() { VLOG(USB) << "RunLoopThread done"; } -static void usb_cleanup() NO_THREAD_SAFETY_ANALYSIS { +void usb_cleanup() NO_THREAD_SAFETY_ANALYSIS { VLOG(USB) << "usb_cleanup"; // Wait until usb operations in RunLoopThread finish, and prevent further operations. operate_device_lock.lock(); @@ -440,8 +440,6 @@ static void usb_cleanup() NO_THREAD_SAFETY_ANALYSIS { void usb_init() { static bool initialized = false; if (!initialized) { - atexit(usb_cleanup); - usb_inited_flag = false; std::thread(RunLoopThread).detach();