Skip to content

Commit

Permalink
[#65795] pw_fastboot: Correct build on native platform
Browse files Browse the repository at this point in the history
  • Loading branch information
lkedziora committed Sep 17, 2024
1 parent 76c9579 commit 04a065e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pw_fastboot/fastboot_device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ bool Device::HandleData(bool read, char* data, size_t size) {
return false;
}
if (static_cast<size_t>(read_write_data_size) != size) {
PW_LOG_ERROR("%s expected %lu bytes, got %u",
PW_LOG_ERROR("%s expected %zu bytes, got %zu",
(read ? "read" : "write"),
(long unsigned int)size,
read_write_data_size);
static_cast<size_t>(size),
static_cast<size_t>(read_write_data_size));
return false;
}
return true;
Expand All @@ -137,7 +137,7 @@ void Device::ExecuteCommands() {

std::vector<std::string> args;
std::string cmd_name;
if (cmd_name.starts_with("oem ")) {
if (stringutils::StartsWith(cmd_name, "oem ")) {
args = {command};
cmd_name = FB_CMD_OEM;
} else {
Expand Down
2 changes: 2 additions & 0 deletions pw_fastboot/lib/stringutils/public/stringutils/strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,6 @@ bool ParseUint(const char* s, T* out, T max = std::numeric_limits<T>::max()) {
std::string StringPrintf(const char* fmt, ...)
__attribute__((__format__(FORMAT_ARCHETYPE, 1, 2)));

bool StartsWith(std::string_view s, std::string_view prefix);

} // namespace stringutils
4 changes: 4 additions & 0 deletions pw_fastboot/lib/stringutils/strings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,8 @@ void StringAppendF(std::string* dst, const char* format, ...) {
va_end(ap);
}

bool StartsWith(std::string_view s, std::string_view prefix) {
return s.substr(0, prefix.size()) == prefix;
}

} // namespace stringutils

0 comments on commit 04a065e

Please sign in to comment.