diff options
Diffstat (limited to 'adb/client/usb_windows.cpp')
-rw-r--r-- | adb/client/usb_windows.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/adb/client/usb_windows.cpp b/adb/client/usb_windows.cpp index 9e00a5d6c..ee7f8024f 100644 --- a/adb/client/usb_windows.cpp +++ b/adb/client/usb_windows.cpp @@ -415,6 +415,7 @@ int usb_read(usb_handle *handle, void* data, int len) { unsigned long time_out = 0; unsigned long read = 0; int err = 0; + int orig_len = len; D("usb_read %d", len); if (NULL == handle) { @@ -423,9 +424,8 @@ int usb_read(usb_handle *handle, void* data, int len) { goto fail; } - while (len > 0) { - if (!AdbReadEndpointSync(handle->adb_read_pipe, data, len, &read, - time_out)) { + while (len == orig_len) { + if (!AdbReadEndpointSync(handle->adb_read_pipe, data, len, &read, time_out)) { D("AdbReadEndpointSync failed: %s", android::base::SystemErrorCodeToString(GetLastError()).c_str()); err = EIO; @@ -433,11 +433,11 @@ int usb_read(usb_handle *handle, void* data, int len) { } D("usb_read got: %ld, expected: %d", read, len); - data = (char *)data + read; + data = (char*)data + read; len -= read; } - return 0; + return orig_len - len; fail: // Any failure should cause us to kick the device instead of leaving it a |