adb: rationalize types.
Use fixed length types for structs going over the wire, constify
arguments where possible, use char* instead of unsigned char* for
apacket data, and assorted other refactoring.
Bug: http://b/29273531
Test: python test_device.py with every combination of old/new adb and adbd
Change-Id: I0b6f818a32be5386985aa4519f542003cf427f9d
diff --git a/adb/sockets.cpp b/adb/sockets.cpp
index b809c4f..fff6049 100644
--- a/adb/sockets.cpp
+++ b/adb/sockets.cpp
@@ -122,7 +122,7 @@
}
static int local_socket_enqueue(asocket* s, apacket* p) {
- D("LS(%d): enqueue %d", s->id, p->len);
+ D("LS(%d): enqueue %zu", s->id, p->len);
p->ptr = p->data;
@@ -195,7 +195,7 @@
/* dispose of any unwritten data */
for (p = s->pkt_first; p; p = n) {
- D("LS(%d): discarding %d bytes", s->id, p->len);
+ D("LS(%d): discarding %zu bytes", s->id, p->len);
n = p->next;
put_apacket(p);
}
@@ -305,7 +305,7 @@
if (ev & FDE_READ) {
apacket* p = get_apacket();
- unsigned char* x = p->data;
+ char* x = p->data;
const size_t max_payload = s->get_max_payload();
size_t avail = max_payload;
int r = 0;
@@ -553,7 +553,7 @@
s->close(s);
}
-static unsigned unhex(unsigned char* s, int len) {
+static unsigned unhex(char* s, int len) {
unsigned n = 0, c;
while (len-- > 0) {
@@ -665,7 +665,7 @@
TransportType type = kTransportAny;
#endif
- D("SS(%d): enqueue %d", s->id, p->len);
+ D("SS(%d): enqueue %zu", s->id, p->len);
if (s->pkt_first == 0) {
s->pkt_first = p;
@@ -698,7 +698,7 @@
D("SS(%d): len is %d", s->id, len);
/* can't do anything until we have the full header */
if ((len + 4) > p->len) {
- D("SS(%d): waiting for %d more bytes", s->id, len + 4 - p->len);
+ D("SS(%d): waiting for %zu more bytes", s->id, len + 4 - p->len);
return 0;
}