diff --git a/adb/commandline.cpp b/adb/commandline.cpp index e1e21ed78..b92757f61 100644 --- a/adb/commandline.cpp +++ b/adb/commandline.cpp @@ -276,10 +276,7 @@ static void read_status_line(int fd, char* buf, size_t count) count--; while (count > 0) { int len = adb_read(fd, buf, count); - if (len == 0) { - break; - } else if (len < 0) { - if (errno == EINTR) continue; + if (len <= 0) { break; } @@ -332,11 +329,7 @@ static void copy_to_file(int inFd, int outFd) { break; } if (len < 0) { - if (errno == EINTR) { - D("copy_to_file() : EINTR, retrying\n"); - continue; - } - D("copy_to_file() : error %d\n", errno); + D("copy_to_file(): read failed: %s\n", strerror(errno)); break; } if (outFd == STDOUT_FILENO) { @@ -386,12 +379,8 @@ static void *stdin_read_thread(void *x) D("stdin_read_thread(): pre unix_read(fdi=%d,...)\n", fdi); r = unix_read(fdi, buf, 1024); D("stdin_read_thread(): post unix_read(fdi=%d,...)\n", fdi); - if(r == 0) break; - if(r < 0) { - if(errno == EINTR) continue; - break; - } - for(n = 0; n < r; n++){ + if (r <= 0) break; + for (n = 0; n < r; n++){ switch(buf[n]) { case '\n': state = 1; diff --git a/adb/fdevent.cpp b/adb/fdevent.cpp index e722d660a..d25bbfb52 100644 --- a/adb/fdevent.cpp +++ b/adb/fdevent.cpp @@ -205,8 +205,8 @@ static void fdevent_process() n = epoll_wait(epoll_fd, events, 256, -1); - if(n < 0) { - if(errno == EINTR) return; + if (n < 0) { + if (errno == EINTR) return; perror("epoll_wait"); exit(1); } diff --git a/adb/file_sync_client.cpp b/adb/file_sync_client.cpp index ab11619fb..e70d550db 100644 --- a/adb/file_sync_client.cpp +++ b/adb/file_sync_client.cpp @@ -203,13 +203,8 @@ static int write_data_file(SyncConnection& sc, const char* path, syncsendbuf* sb sbuf->id = ID_DATA; while (true) { int ret = adb_read(lfd, sbuf->data, sc.max); - if (!ret) - break; - - if (ret < 0) { - if(errno == EINTR) - continue; - fprintf(stderr, "cannot read '%s': %s\n", path, strerror(errno)); + if (ret <= 0) { + if (ret < 0) fprintf(stderr, "cannot read '%s': %s\n", path, strerror(errno)); break; } diff --git a/adb/file_sync_service.cpp b/adb/file_sync_service.cpp index cadf5b3c3..214cead1d 100644 --- a/adb/file_sync_service.cpp +++ b/adb/file_sync_service.cpp @@ -325,7 +325,6 @@ static bool do_recv(int s, const char* path, std::vector& buffer) { int r = adb_read(fd, &buffer[0], buffer.size()); if (r <= 0) { if (r == 0) break; - if (errno == EINTR) continue; SendSyncFailErrno(s, "read failed"); adb_close(fd); return false; diff --git a/adb/transport.cpp b/adb/transport.cpp index ea673f212..afdab86fa 100644 --- a/adb/transport.cpp +++ b/adb/transport.cpp @@ -140,8 +140,7 @@ read_packet(int fd, const char* name, apacket** ppacket) len -= r; p += r; } else { - D("%s: read_packet (fd=%d), error ret=%d errno=%d: %s\n", name, fd, r, errno, strerror(errno)); - if((r < 0) && (errno == EINTR)) continue; + D("%s: read_packet (fd=%d), error ret=%d: %s\n", name, fd, r, strerror(errno)); return -1; } } @@ -171,8 +170,7 @@ write_packet(int fd, const char* name, apacket** ppacket) len -= r; p += r; } else { - D("%s: write_packet (fd=%d) error ret=%d errno=%d: %s\n", name, fd, r, errno, strerror(errno)); - if((r < 0) && (errno == EINTR)) continue; + D("%s: write_packet (fd=%d) error ret=%d: %s\n", name, fd, r, strerror(errno)); return -1; } } @@ -489,9 +487,7 @@ transport_read_action(int fd, struct tmsg* m) len -= r; p += r; } else { - if((r < 0) && (errno == EINTR)) continue; - D("transport_read_action: on fd %d, error %d: %s\n", - fd, errno, strerror(errno)); + D("transport_read_action: on fd %d: %s\n", fd, strerror(errno)); return -1; } } @@ -511,9 +507,7 @@ transport_write_action(int fd, struct tmsg* m) len -= r; p += r; } else { - if((r < 0) && (errno == EINTR)) continue; - D("transport_write_action: on fd %d, error %d: %s\n", - fd, errno, strerror(errno)); + D("transport_write_action: on fd %d: %s\n", fd, strerror(errno)); return -1; } } diff --git a/adb/usb_linux_client.cpp b/adb/usb_linux_client.cpp index c6ad00d41..dc44f16fe 100644 --- a/adb/usb_linux_client.cpp +++ b/adb/usb_linux_client.cpp @@ -431,17 +431,12 @@ static void *usb_ffs_open_thread(void *x) static int bulk_write(int bulk_in, const uint8_t* buf, size_t length) { size_t count = 0; - int ret; - do { - ret = adb_write(bulk_in, buf + count, length - count); - if (ret < 0) { - if (errno != EINTR) - return ret; - } else { - count += ret; - } - } while (count < length); + while (count < length) { + int ret = adb_write(bulk_in, buf + count, length - count); + if (ret < 0) return -1; + count += ret; + } D("[ bulk_write done fd=%d ]\n", bulk_in); return count; @@ -462,20 +457,15 @@ static int usb_ffs_write(usb_handle* h, const void* data, int len) static int bulk_read(int bulk_out, uint8_t* buf, size_t length) { size_t count = 0; - int ret; - do { - ret = adb_read(bulk_out, buf + count, length - count); + while (count < length) { + int ret = adb_read(bulk_out, buf + count, length - count); if (ret < 0) { - if (errno != EINTR) { - D("[ bulk_read failed fd=%d length=%zu count=%zu ]\n", - bulk_out, length, count); - return ret; - } - } else { - count += ret; + D("[ bulk_read failed fd=%d length=%zu count=%zu ]\n", bulk_out, length, count); + return -1; } - } while (count < length); + count += ret; + } return count; }