Loading adb/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ ADB_COMMON_CFLAGS := \ -Wall -Wextra -Werror \ -Wno-unused-parameter \ -Wno-missing-field-initializers \ -Wvla \ -DADB_REVISION='"$(adb_version)"' \ # Define windows.h and tchar.h Unicode preprocessor symbols so that Loading adb/file_sync_client.cpp +12 −11 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ #include <utime.h> #include <memory> #include <vector> #include "sysdeps.h" Loading Loading @@ -101,14 +102,14 @@ class SyncConnection { // Sending header and payload in a single write makes a noticeable // difference to "adb sync" performance. char buf[sizeof(SyncRequest) + path_length]; SyncRequest* req = reinterpret_cast<SyncRequest*>(buf); std::vector<char> buf(sizeof(SyncRequest) + path_length); SyncRequest* req = reinterpret_cast<SyncRequest*>(&buf[0]); req->id = id; req->path_length = path_length; char* data = reinterpret_cast<char*>(req + 1); memcpy(data, path_and_mode, path_length); return WriteFdExactly(fd, buf, sizeof(buf)); return WriteFdExactly(fd, &buf[0], buf.size()); } // Sending header, payload, and footer in a single write makes a huge Loading @@ -123,10 +124,10 @@ class SyncConnection { return false; } char buf[sizeof(SyncRequest) + path_length + std::vector<char> buf(sizeof(SyncRequest) + path_length + sizeof(SyncRequest) + data_length + sizeof(SyncRequest)]; char* p = buf; sizeof(SyncRequest)); char* p = &buf[0]; SyncRequest* req_send = reinterpret_cast<SyncRequest*>(p); req_send->id = ID_SEND; Loading @@ -147,7 +148,7 @@ class SyncConnection { req_done->path_length = mtime; p += sizeof(SyncRequest); if (!WriteFdExactly(fd, buf, (p-buf))) return false; if (!WriteFdExactly(fd, &buf[0], (p - &buf[0]))) return false; total_bytes += data_length; return true; Loading @@ -172,14 +173,14 @@ class SyncConnection { } bool ReportCopyFailure(const char* from, const char* to, const syncmsg& msg) { char buffer[msg.status.msglen + 1]; if (!ReadFdExactly(fd, buffer, msg.status.msglen)) { std::vector<char> buf(msg.status.msglen + 1); if (!ReadFdExactly(fd, &buf[0], msg.status.msglen)) { fprintf(stderr, "adb: failed to copy '%s' to '%s'; failed to read reason (!): %s\n", from, to, strerror(errno)); return false; } buffer[msg.status.msglen] = 0; fprintf(stderr, "adb: failed to copy '%s' to '%s': %s\n", from, to, buffer); buf[msg.status.msglen] = 0; fprintf(stderr, "adb: failed to copy '%s' to '%s': %s\n", from, to, &buf[0]); return false; } Loading adb/sysdeps_win32.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -567,12 +567,11 @@ char* adb_strerror(int err) { // Lookup the string for an unknown error. char* errmsg = strerror(-1); char unknown_error[(errmsg == nullptr ? 0 : strlen(errmsg)) + 1]; strcpy(unknown_error, errmsg == nullptr ? "" : errmsg); const std::string unknown_error = (errmsg == nullptr) ? "" : errmsg; // Lookup the string for this error to see if the C Runtime has it. errmsg = strerror(err); if ((errmsg != nullptr) && strcmp(errmsg, unknown_error)) { if (errmsg != nullptr && unknown_error != errmsg) { // The CRT returned an error message and it is different than the error // message for an unknown error, so it is probably valid, so use it. } else { Loading Loading
adb/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ ADB_COMMON_CFLAGS := \ -Wall -Wextra -Werror \ -Wno-unused-parameter \ -Wno-missing-field-initializers \ -Wvla \ -DADB_REVISION='"$(adb_version)"' \ # Define windows.h and tchar.h Unicode preprocessor symbols so that Loading
adb/file_sync_client.cpp +12 −11 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ #include <utime.h> #include <memory> #include <vector> #include "sysdeps.h" Loading Loading @@ -101,14 +102,14 @@ class SyncConnection { // Sending header and payload in a single write makes a noticeable // difference to "adb sync" performance. char buf[sizeof(SyncRequest) + path_length]; SyncRequest* req = reinterpret_cast<SyncRequest*>(buf); std::vector<char> buf(sizeof(SyncRequest) + path_length); SyncRequest* req = reinterpret_cast<SyncRequest*>(&buf[0]); req->id = id; req->path_length = path_length; char* data = reinterpret_cast<char*>(req + 1); memcpy(data, path_and_mode, path_length); return WriteFdExactly(fd, buf, sizeof(buf)); return WriteFdExactly(fd, &buf[0], buf.size()); } // Sending header, payload, and footer in a single write makes a huge Loading @@ -123,10 +124,10 @@ class SyncConnection { return false; } char buf[sizeof(SyncRequest) + path_length + std::vector<char> buf(sizeof(SyncRequest) + path_length + sizeof(SyncRequest) + data_length + sizeof(SyncRequest)]; char* p = buf; sizeof(SyncRequest)); char* p = &buf[0]; SyncRequest* req_send = reinterpret_cast<SyncRequest*>(p); req_send->id = ID_SEND; Loading @@ -147,7 +148,7 @@ class SyncConnection { req_done->path_length = mtime; p += sizeof(SyncRequest); if (!WriteFdExactly(fd, buf, (p-buf))) return false; if (!WriteFdExactly(fd, &buf[0], (p - &buf[0]))) return false; total_bytes += data_length; return true; Loading @@ -172,14 +173,14 @@ class SyncConnection { } bool ReportCopyFailure(const char* from, const char* to, const syncmsg& msg) { char buffer[msg.status.msglen + 1]; if (!ReadFdExactly(fd, buffer, msg.status.msglen)) { std::vector<char> buf(msg.status.msglen + 1); if (!ReadFdExactly(fd, &buf[0], msg.status.msglen)) { fprintf(stderr, "adb: failed to copy '%s' to '%s'; failed to read reason (!): %s\n", from, to, strerror(errno)); return false; } buffer[msg.status.msglen] = 0; fprintf(stderr, "adb: failed to copy '%s' to '%s': %s\n", from, to, buffer); buf[msg.status.msglen] = 0; fprintf(stderr, "adb: failed to copy '%s' to '%s': %s\n", from, to, &buf[0]); return false; } Loading
adb/sysdeps_win32.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -567,12 +567,11 @@ char* adb_strerror(int err) { // Lookup the string for an unknown error. char* errmsg = strerror(-1); char unknown_error[(errmsg == nullptr ? 0 : strlen(errmsg)) + 1]; strcpy(unknown_error, errmsg == nullptr ? "" : errmsg); const std::string unknown_error = (errmsg == nullptr) ? "" : errmsg; // Lookup the string for this error to see if the C Runtime has it. errmsg = strerror(err); if ((errmsg != nullptr) && strcmp(errmsg, unknown_error)) { if (errmsg != nullptr && unknown_error != errmsg) { // The CRT returned an error message and it is different than the error // message for an unknown error, so it is probably valid, so use it. } else { Loading