diff options
author | Treehugger Robot | 2018-08-02 19:41:16 -0500 |
---|---|---|
committer | Gerrit Code Review | 2018-08-02 19:41:16 -0500 |
commit | 8cf510ff81d3027d9af3fbb5f717e199acb6b312 (patch) | |
tree | 77d0224ed7778f5632ac1f2928dd3af14b21ba74 | |
parent | acc0a90869a2dfc62d4758d5f7958883688da9ff (diff) | |
parent | c771ae0fd432f33d6916c72bf9f7824edfffbd38 (diff) | |
download | platform-system-core-8cf510ff81d3027d9af3fbb5f717e199acb6b312.tar.gz platform-system-core-8cf510ff81d3027d9af3fbb5f717e199acb6b312.tar.xz platform-system-core-8cf510ff81d3027d9af3fbb5f717e199acb6b312.zip |
Merge "Minor fixes to fastboot_driver"
-rw-r--r-- | fastboot/fastboot_driver.cpp | 17 | ||||
-rw-r--r-- | fastboot/fastboot_driver.h | 2 |
2 files changed, 12 insertions, 7 deletions
diff --git a/fastboot/fastboot_driver.cpp b/fastboot/fastboot_driver.cpp index aabc620d4..55ca65d3f 100644 --- a/fastboot/fastboot_driver.cpp +++ b/fastboot/fastboot_driver.cpp | |||
@@ -134,7 +134,7 @@ RetCode FastBootDriver::Partitions(std::vector<std::tuple<std::string, uint32_t> | |||
134 | return ret; | 134 | return ret; |
135 | } | 135 | } |
136 | 136 | ||
137 | std::regex reg("partition-size[[:s:]]*:[[:s:]]*([[:w:]]+)[[:s:]]*:[[:s:]]*0x([[:d:]]+)"); | 137 | std::regex reg("partition-size[[:s:]]*:[[:s:]]*([[:w:]]+)[[:s:]]*:[[:s:]]*0x([[:xdigit:]]+)"); |
138 | std::smatch sm; | 138 | std::smatch sm; |
139 | 139 | ||
140 | for (auto& s : all) { | 140 | for (auto& s : all) { |
@@ -264,11 +264,16 @@ RetCode FastBootDriver::Upload(const std::string& outfile, std::string* response | |||
264 | std::vector<std::string>* info) { | 264 | std::vector<std::string>* info) { |
265 | RetCode ret; | 265 | RetCode ret; |
266 | int dsize; | 266 | int dsize; |
267 | if ((ret = RawCommand(Commands::UPLOAD, response, info, &dsize)) || dsize == 0) { | 267 | if ((ret = RawCommand(Commands::UPLOAD, response, info, &dsize))) { |
268 | error_ = "Upload request failed"; | 268 | error_ = "Upload request failed: " + error_; |
269 | return ret; | 269 | return ret; |
270 | } | 270 | } |
271 | 271 | ||
272 | if (!dsize) { | ||
273 | error_ = "Upload request failed, device reports 0 bytes available"; | ||
274 | return BAD_DEV_RESP; | ||
275 | } | ||
276 | |||
272 | std::vector<char> data; | 277 | std::vector<char> data; |
273 | data.resize(dsize); | 278 | data.resize(dsize); |
274 | 279 | ||
@@ -462,10 +467,10 @@ RetCode FastBootDriver::SendBuffer(const std::vector<char>& buf) { | |||
462 | } | 467 | } |
463 | 468 | ||
464 | RetCode FastBootDriver::SendBuffer(const void* buf, size_t size) { | 469 | RetCode FastBootDriver::SendBuffer(const void* buf, size_t size) { |
470 | // ioctl on 0-length buffer causes freezing | ||
465 | if (!size) { | 471 | if (!size) { |
466 | return SUCCESS; | 472 | return BAD_ARG; |
467 | } | 473 | } |
468 | |||
469 | // Write the buffer | 474 | // Write the buffer |
470 | ssize_t tmp = transport->Write(buf, size); | 475 | ssize_t tmp = transport->Write(buf, size); |
471 | 476 | ||
@@ -521,7 +526,7 @@ int FastBootDriver::SparseWriteCallback(std::vector<char>& tpbuf, const char* da | |||
521 | // Now we need to send a multiple of chunk size | 526 | // Now we need to send a multiple of chunk size |
522 | size_t nchunks = (len - total) / TRANSPORT_CHUNK_SIZE; | 527 | size_t nchunks = (len - total) / TRANSPORT_CHUNK_SIZE; |
523 | size_t nbytes = TRANSPORT_CHUNK_SIZE * nchunks; | 528 | size_t nbytes = TRANSPORT_CHUNK_SIZE * nchunks; |
524 | if (SendBuffer(data + total, nbytes)) { | 529 | if (nbytes && SendBuffer(data + total, nbytes)) { // Don't send a ZLP |
525 | error_ = ErrnoStr("Send failed in SparseWriteCallback()"); | 530 | error_ = ErrnoStr("Send failed in SparseWriteCallback()"); |
526 | return -1; | 531 | return -1; |
527 | } | 532 | } |
diff --git a/fastboot/fastboot_driver.h b/fastboot/fastboot_driver.h index 9fdd31700..e8711cba2 100644 --- a/fastboot/fastboot_driver.h +++ b/fastboot/fastboot_driver.h | |||
@@ -103,7 +103,7 @@ class FastBootDriver { | |||
103 | 103 | ||
104 | /* HELPERS */ | 104 | /* HELPERS */ |
105 | void SetInfoCallback(std::function<void(std::string&)> info); | 105 | void SetInfoCallback(std::function<void(std::string&)> info); |
106 | const std::string RCString(RetCode rc); | 106 | static const std::string RCString(RetCode rc); |
107 | std::string Error(); | 107 | std::string Error(); |
108 | RetCode WaitForDisconnect(); | 108 | RetCode WaitForDisconnect(); |
109 | 109 | ||