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

Commit 641fd2e4 authored by Elliott Hughes's avatar Elliott Hughes Committed by Android Git Automerger
Browse files

am ebce1470: Merge "adb: fix adb_close() vs. unix_close() usage"

* commit 'ebce1470':
  adb: fix adb_close() vs. unix_close() usage
parents 0895894c ebce1470
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -115,7 +115,7 @@ void start_device_log(void) {
    dup2(fd, STDOUT_FILENO);
    dup2(fd, STDERR_FILENO);
    fprintf(stderr, "--- adb starting (pid %d) ---\n", getpid());
    adb_close(fd);
    unix_close(fd);
}
#endif

+3 −0
Original line number Diff line number Diff line
@@ -420,6 +420,9 @@ int adb_auth_get_userkey(unsigned char *data, size_t len)
    strcat(path, ".pub");

    // TODO(danalbert): ReadFileToString
    // Note that on Windows, load_file() does not do CR/LF translation, but
    // ReadFileToString() uses the C Runtime which uses CR/LF translation by
    // default (by is overridable with _setmode()).
    unsigned size;
    char* file_data = reinterpret_cast<char*>(load_file(path, &size));
    if (file_data == nullptr) {
+1 −1
Original line number Diff line number Diff line
@@ -226,7 +226,7 @@ static void close_stdin() {
        return;
    }
    dup2(fd, STDIN_FILENO);
    adb_close(fd);
    unix_close(fd);
}

int main(int argc, char** argv) {
+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ bool make_block_device_writable(const std::string& dev) {

    int OFF = 0;
    bool result = (ioctl(fd, BLKROSET, &OFF) != -1);
    adb_close(fd);
    unix_close(fd);
    return result;
}

+8 −8
Original line number Diff line number Diff line
@@ -252,7 +252,7 @@ static int create_subproc_pty(const char* cmd, const char* arg0,
    *pid = forkpty(&ptm, pts_name, nullptr, nullptr);
    if (*pid == -1) {
        printf("- fork failed: %s -\n", strerror(errno));
        adb_close(ptm);
        unix_close(ptm);
        return -1;
    }

@@ -263,7 +263,7 @@ static int create_subproc_pty(const char* cmd, const char* arg0,
        if (pts == -1) {
            fprintf(stderr, "child failed to open pseudo-term slave %s: %s\n",
                    pts_name, strerror(errno));
            adb_close(ptm);
            unix_close(ptm);
            exit(-1);
        }

@@ -272,16 +272,16 @@ static int create_subproc_pty(const char* cmd, const char* arg0,
            termios tattr;
            if (tcgetattr(pts, &tattr) == -1) {
                fprintf(stderr, "tcgetattr failed: %s\n", strerror(errno));
                adb_close(pts);
                adb_close(ptm);
                unix_close(pts);
                unix_close(ptm);
                exit(-1);
            }

            cfmakeraw(&tattr);
            if (tcsetattr(pts, TCSADRAIN, &tattr) == -1) {
                fprintf(stderr, "tcsetattr failed: %s\n", strerror(errno));
                adb_close(pts);
                adb_close(ptm);
                unix_close(pts);
                unix_close(ptm);
                exit(-1);
            }
        }
@@ -290,8 +290,8 @@ static int create_subproc_pty(const char* cmd, const char* arg0,
        dup2(pts, STDOUT_FILENO);
        dup2(pts, STDERR_FILENO);

        adb_close(pts);
        adb_close(ptm);
        unix_close(pts);
        unix_close(ptm);

        execl(cmd, cmd, arg0, arg1, nullptr);
        fprintf(stderr, "- exec '%s' failed: %s (%d) -\n",
Loading