summaryrefslogtreecommitdiffstats
path: root/adb/transport.c
diff options
context:
space:
mode:
Diffstat (limited to 'adb/transport.c')
-rw-r--r--adb/transport.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/adb/transport.c b/adb/transport.c
index 2baf340..83a349a 100644
--- a/adb/transport.c
+++ b/adb/transport.c
@@ -35,24 +35,30 @@ static atransport transport_list = {
ADB_MUTEX_DEFINE( transport_lock );
#if ADB_TRACE
+#define MAX_DUMP_HEX_LEN 16
static void dump_hex( const unsigned char* ptr, size_t len )
{
int nn, len2 = len;
+ // Build a string instead of logging each character.
+ // MAX chars in 2 digit hex, one space, MAX chars, one '\0'.
+ char buffer[MAX_DUMP_HEX_LEN *2 + 1 + MAX_DUMP_HEX_LEN + 1 ], *pb = buffer;
- if (len2 > 16) len2 = 16;
+ if (len2 > MAX_DUMP_HEX_LEN) len2 = MAX_DUMP_HEX_LEN;
- for (nn = 0; nn < len2; nn++)
- D("%02x", ptr[nn]);
- D(" ");
+ for (nn = 0; nn < len2; nn++) {
+ sprintf(pb, "%02x", ptr[nn]);
+ pb += 2;
+ }
+ sprintf(pb++, " ");
for (nn = 0; nn < len2; nn++) {
int c = ptr[nn];
if (c < 32 || c > 127)
c = '.';
- D("%c", c);
+ *pb++ = c;
}
- D("\n");
- fflush(stdout);
+ *pb++ = '\0';
+ DR("%s\n", buffer);
}
#endif
@@ -192,6 +198,7 @@ write_packet(int fd, const char* name, apacket** ppacket)
static void transport_socket_events(int fd, unsigned events, void *_t)
{
atransport *t = _t;
+ D("transport_socket_events(fd=%d, events=%04x,...)\n", fd, events);
if(events & FDE_READ){
apacket *p = 0;
if(read_packet(fd, t->serial, &p)){
@@ -221,8 +228,10 @@ void send_packet(apacket *p, atransport *t)
print_packet("send", p);
if (t == NULL) {
- fatal_errno("Transport is null");
D("Transport is null \n");
+ // Zap errno because print_packet() and other stuff have errno effect.
+ errno = 0;
+ fatal_errno("Transport is null");
}
if(write_packet(t->transport_socket, t->serial, &p)){
@@ -1069,4 +1078,3 @@ int check_data(apacket *p)
return 0;
}
}
-