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

Commit 8d8126a7 authored by Spencer Low's avatar Spencer Low
Browse files

adb: logging: newlines, thread ids, error code overwriting



Add missing \n to uses of legacy D() macro. This should make the legacy
logging easier to read (and harder to miss important stuff).

On POSIX, use gettid() from libcutils instead of pthread_self() so that
the output shows a more reasonable number instead of a pointer value.
This should be ok since libbase's logging already uses gettid().

Win32:

Don't let the Win32 last error get overwritten by API calls after the
original error'ing API. When encountering an unknown error, log the
specific error code.

Change-Id: Ib8f72754efa7ba895d2f1cd914251fec2a1d894c
Signed-off-by: default avatarSpencer Low <CompareAndSwap@gmail.com>
parent 05418442
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -174,7 +174,7 @@ static void setup_trace_mask() {
    for (const auto& elem : elements) {
        const auto& flag = trace_flags.find(elem);
        if (flag == trace_flags.end()) {
            D("Unknown trace flag: %s", flag->first.c_str());
            D("Unknown trace flag: %s\n", flag->first.c_str());
            continue;
        }

+1 −1
Original line number Diff line number Diff line
@@ -212,7 +212,7 @@ void adb_auth_confirm_key(unsigned char *key, size_t len, atransport *t)

    ret = snprintf(msg, sizeof(msg), "PK%s", key);
    if (ret >= (signed)sizeof(msg)) {
        D("Key too long. ret=%d", ret);
        D("Key too long. ret=%d\n", ret);
        return;
    }
    D("Sending '%s'\n", msg);
+6 −6
Original line number Diff line number Diff line
@@ -183,7 +183,7 @@ static int write_public_keyfile(RSA *private_key, const char *private_key_path)

#if defined(OPENSSL_IS_BORINGSSL)
    if (!EVP_EncodedLength(&encoded_length, sizeof(pkey))) {
        D("Public key too large to base64 encode");
        D("Public key too large to base64 encode\n");
        goto out;
    }
#else
@@ -194,7 +194,7 @@ static int write_public_keyfile(RSA *private_key, const char *private_key_path)

    encoded = new uint8_t[encoded_length];
    if (encoded == nullptr) {
        D("Allocation failure");
        D("Allocation failure\n");
        goto out;
    }

@@ -203,7 +203,7 @@ static int write_public_keyfile(RSA *private_key, const char *private_key_path)

    if (fwrite(encoded, encoded_length, 1, outfile) != 1 ||
        fwrite(info, strlen(info), 1, outfile) != 1) {
        D("Write error while writing public key");
        D("Write error while writing public key\n");
        goto out;
    }

@@ -323,7 +323,7 @@ static int get_user_keyfilepath(char *filename, size_t len)

    if (stat(android_dir, &buf)) {
        if (adb_mkdir(android_dir, 0750) < 0) {
            D("Cannot mkdir '%s'", android_dir);
            D("Cannot mkdir '%s'\n", android_dir);
            return -1;
        }
    }
@@ -339,7 +339,7 @@ static int get_user_key(struct listnode *list)

    ret = get_user_keyfilepath(path, sizeof(path));
    if (ret < 0 || ret >= (signed)sizeof(path)) {
        D("Error getting user key filename");
        D("Error getting user key filename\n");
        return 0;
    }

@@ -414,7 +414,7 @@ int adb_auth_get_userkey(unsigned char *data, size_t len)
    char path[PATH_MAX];
    int ret = get_user_keyfilepath(path, sizeof(path) - 4);
    if (ret < 0 || ret >= (signed)(sizeof(path) - 4)) {
        D("Error getting user key filename");
        D("Error getting user key filename\n");
        return 0;
    }
    strcat(path, ".pub");
+1 −1
Original line number Diff line number Diff line
@@ -243,7 +243,7 @@ int adb_connect(const std::string& service, std::string* error) {

    fd = _adb_connect(service, error);
    if (fd == -1) {
        D("_adb_connect error: %s", error->c_str());
        D("_adb_connect error: %s\n", error->c_str());
    } else if(fd == -2) {
        fprintf(stderr,"** daemon still not running\n");
    }
+1 −1
Original line number Diff line number Diff line
@@ -578,7 +578,7 @@ void fdevent_subproc_setup()
    if(adb_socketpair(s)) {
        FATAL("cannot create shell-exit socket-pair\n");
    }
    D("socketpair: (%d,%d)", s[0], s[1]);
    D("socketpair: (%d,%d)\n", s[0], s[1]);

    SHELL_EXIT_NOTIFY_FD = s[0];
    fdevent *fde;
Loading