adb: clean up debug tracing a little.
Always use LOG() for debug tracing.
Remove useless D_lock. I believe it is useless to lock just before and after fprintf.
I verified the log output both on host and on device. The output looks fine to me.
Change-Id: I96ccfe408ff56864361551afe9ad464d197ae104
diff --git a/adb_auth_client.cpp b/adb_auth_client.cpp
index c3af024..cedc847 100644
--- a/adb_auth_client.cpp
+++ b/adb_auth_client.cpp
@@ -60,7 +60,7 @@
f = fopen(file, "re");
if (!f) {
- D("Can't open '%s'\n", file);
+ D("Can't open '%s'", file);
return;
}
@@ -69,7 +69,7 @@
auto key = reinterpret_cast<adb_public_key*>(
calloc(1, sizeof(adb_public_key) + 4));
if (key == nullptr) {
- D("Can't malloc key\n");
+ D("Can't malloc key");
break;
}
@@ -79,13 +79,13 @@
ret = __b64_pton(buf, (u_char *)&key->key, sizeof(key->key) + 4);
if (ret != sizeof(key->key)) {
- D("%s: Invalid base64 data ret=%d\n", file, ret);
+ D("%s: Invalid base64 data ret=%d", file, ret);
free(key);
continue;
}
if (key->key.len != RSANUMWORDS) {
- D("%s: Invalid key len %d\n", file, key->key.len);
+ D("%s: Invalid key len %d", file, key->key.len);
free(key);
continue;
}
@@ -117,7 +117,7 @@
while ((path = *paths++)) {
if (!stat(path, &buf)) {
- D("Loading keys from '%s'\n", path);
+ D("Loading keys from '%s'", path);
read_keys(path, list);
}
}
@@ -163,7 +163,7 @@
static void usb_disconnected(void* unused, atransport* t)
{
- D("USB disconnect\n");
+ D("USB disconnect");
usb_transport = NULL;
needs_retry = false;
}
@@ -176,7 +176,7 @@
if (events & FDE_READ) {
ret = unix_read(fd, response, sizeof(response));
if (ret <= 0) {
- D("Framework disconnect\n");
+ D("Framework disconnect");
if (usb_transport)
fdevent_remove(&usb_transport->auth_fde);
framework_fd = -1;
@@ -199,26 +199,26 @@
}
if (framework_fd < 0) {
- D("Client not connected\n");
+ D("Client not connected");
needs_retry = true;
return;
}
if (key[len - 1] != '\0') {
- D("Key must be a null-terminated string\n");
+ D("Key must be a null-terminated string");
return;
}
ret = snprintf(msg, sizeof(msg), "PK%s", key);
if (ret >= (signed)sizeof(msg)) {
- D("Key too long. ret=%d\n", ret);
+ D("Key too long. ret=%d", ret);
return;
}
- D("Sending '%s'\n", msg);
+ D("Sending '%s'", msg);
ret = unix_write(framework_fd, msg, ret);
if (ret < 0) {
- D("Failed to write PK, errno=%d\n", errno);
+ D("Failed to write PK, errno=%d", errno);
return;
}
@@ -236,7 +236,7 @@
s = adb_socket_accept(fd, &addr, &alen);
if (s < 0) {
- D("Failed to accept: errno=%d\n", errno);
+ D("Failed to accept: errno=%d", errno);
return;
}
@@ -251,7 +251,7 @@
void adbd_cloexec_auth_socket() {
int fd = android_get_control_socket("adbd");
if (fd == -1) {
- D("Failed to get adbd socket\n");
+ D("Failed to get adbd socket");
return;
}
fcntl(fd, F_SETFD, FD_CLOEXEC);
@@ -260,12 +260,12 @@
void adbd_auth_init(void) {
int fd = android_get_control_socket("adbd");
if (fd == -1) {
- D("Failed to get adbd socket\n");
+ D("Failed to get adbd socket");
return;
}
if (listen(fd, 4) == -1) {
- D("Failed to listen on '%d'\n", fd);
+ D("Failed to listen on '%d'", fd);
return;
}