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

Commit 0f29cbc7 authored by Josh Gao's avatar Josh Gao
Browse files

adb: switch unix_open to string_view.

Test: test_adb.py
Test: test_device.py
Test: $ANDROID_HOST_OUT/nativetest64/adb_test/adb_test
Test: adb shell /data/nativetest64/adbd_test/adbd_test
Change-Id: Ieecc9b1b7f2111f4da45d4bbd1b7703535fe7d4d
parent db2ffaa0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -600,7 +600,7 @@ static void ReportServerStartupFailure(pid_t pid) {
    fprintf(stderr, "Full server startup log: %s\n", GetLogFilePath().c_str());
    fprintf(stderr, "Server had pid: %d\n", pid);

    android::base::unique_fd fd(unix_open(GetLogFilePath().c_str(), O_RDONLY));
    android::base::unique_fd fd(unix_open(GetLogFilePath(), O_RDONLY));
    if (fd == -1) return;

    // Let's not show more than 128KiB of log...
+1 −2
Original line number Diff line number Diff line
@@ -72,8 +72,7 @@ static std::string get_log_file_name() {
}

void start_device_log(void) {
    int fd = unix_open(get_log_file_name().c_str(),
                       O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0640);
    int fd = unix_open(get_log_file_name(), O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0640);
    if (fd == -1) {
        return;
    }
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@

static void setup_daemon_logging() {
    const std::string log_file_path(GetLogFilePath());
    int fd = unix_open(log_file_path.c_str(), O_WRONLY | O_CREAT | O_APPEND, 0640);
    int fd = unix_open(log_file_path, O_WRONLY | O_CREAT | O_APPEND, 0640);
    if (fd == -1) {
        PLOG(FATAL) << "cannot open " << log_file_path;
    }
+3 −3
Original line number Diff line number Diff line
@@ -156,7 +156,7 @@ static void find_usb_device(const std::string& base,
                continue;
            }

            int fd = unix_open(dev_name.c_str(), O_RDONLY | O_CLOEXEC);
            int fd = unix_open(dev_name, O_RDONLY | O_CLOEXEC);
            if (fd == -1) {
                continue;
            }
@@ -535,10 +535,10 @@ static void register_device(const char* dev_name, const char* dev_path, unsigned
    // Initialize mark so we don't get garbage collected after the device scan.
    usb->mark = true;

    usb->fd = unix_open(usb->path.c_str(), O_RDWR | O_CLOEXEC);
    usb->fd = unix_open(usb->path, O_RDWR | O_CLOEXEC);
    if (usb->fd == -1) {
        // Opening RW failed, so see if we have RO access.
        usb->fd = unix_open(usb->path.c_str(), O_RDONLY | O_CLOEXEC);
        usb->fd = unix_open(usb->path, O_RDONLY | O_CLOEXEC);
        if (usb->fd == -1) {
            D("[ usb open %s failed: %s]", usb->path.c_str(), strerror(errno));
            return;
+1 −1
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ bool dev_is_overlayfs(const std::string& dev) {

bool make_block_device_writable(const std::string& dev) {
    if (dev_is_overlayfs(dev)) return true;
    int fd = unix_open(dev.c_str(), O_RDONLY | O_CLOEXEC);
    int fd = unix_open(dev, O_RDONLY | O_CLOEXEC);
    if (fd == -1) {
        return false;
    }
Loading