Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 342b661e authored by Josh Gao's avatar Josh Gao
Browse files

adb: switch adb_io.h to string_view.

Test: mma
Change-Id: Ifa16502bac18429491426c45ece562657cff1689
parent ac8da2a7
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@
#include "adb_utils.h"
#include "sysdeps.h"

bool SendProtocolString(int fd, const std::string& s) {
bool SendProtocolString(int fd, std::string_view s) {
    unsigned int length = s.size();
    if (length > MAX_PAYLOAD - 4) {
        errno = EMSGSIZE;
@@ -69,7 +69,7 @@ bool SendOkay(int fd) {
    return WriteFdExactly(fd, "OKAY", 4);
}

bool SendFail(int fd, const std::string& reason) {
bool SendFail(int fd, std::string_view reason) {
    return WriteFdExactly(fd, "FAIL", 4) && SendProtocolString(fd, reason);
}

+3 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <sys/types.h>

#include <string>
#include <string_view>

#include "adb_unique_fd.h"

@@ -27,10 +28,10 @@
bool SendOkay(int fd);

// Sends the protocol "FAIL" message, with the given failure reason.
bool SendFail(int fd, const std::string& reason);
bool SendFail(int fd, std::string_view reason);

// Writes a protocol-format string; a four hex digit length followed by the string data.
bool SendProtocolString(int fd, const std::string& s);
bool SendProtocolString(int fd, std::string_view s);

// Reads a protocol-format string; a four hex digit length followed by the string data.
bool ReadProtocolString(int fd, std::string* s, std::string* error);