diff options
author | Josh Gao <jmgao@google.com> | 2017-08-28 14:43:24 -0700 |
---|---|---|
committer | Josh Gao <jmgao@google.com> | 2017-08-28 14:43:24 -0700 |
commit | e46720938d10609a806f984ffd6b8a4b19d4ba85 (patch) | |
tree | df9f1fa58edf465b9c875457d510a437e3d895a0 | |
parent | 75a40988c0e7a35f2663b644989ce012b66f4586 (diff) | |
download | core-e46720938d10609a806f984ffd6b8a4b19d4ba85.tar.gz core-e46720938d10609a806f984ffd6b8a4b19d4ba85.tar.bz2 core-e46720938d10609a806f984ffd6b8a4b19d4ba85.zip |
adb: improve CHECKs.
Use CHECK_LT(foo, 1234) instead of CHECK(foo < 1234) so that failing
checks have the values emitted.
Bug: http://b/65063965
Test: adb server nodaemon
Change-Id: I094287f7c4d2d177ea216568d06e9e425a28dd96
-rw-r--r-- | adb/transport_usb.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/adb/transport_usb.cpp b/adb/transport_usb.cpp index 7e8ae67c4..6768d31a1 100644 --- a/adb/transport_usb.cpp +++ b/adb/transport_usb.cpp @@ -33,8 +33,8 @@ static int UsbReadMessage(usb_handle* h, amessage* msg) { D("UsbReadMessage"); size_t usb_packet_size = usb_get_max_packet_size(h); - CHECK(usb_packet_size >= sizeof(*msg)); - CHECK(usb_packet_size < 4096); + CHECK_GE(usb_packet_size, sizeof(*msg)); + CHECK_LT(usb_packet_size, 4096ULL); char buffer[4096]; int n = usb_read(h, buffer, usb_packet_size); @@ -52,7 +52,7 @@ static int UsbReadPayload(usb_handle* h, apacket* p) { D("UsbReadPayload(%d)", p->msg.data_length); size_t usb_packet_size = usb_get_max_packet_size(h); - CHECK(sizeof(p->data) % usb_packet_size == 0); + CHECK_EQ(0ULL, sizeof(p->data) % usb_packet_size); // Round the data length up to the nearest packet size boundary. // The device won't send a zero packet for packet size aligned payloads, @@ -62,7 +62,7 @@ static int UsbReadPayload(usb_handle* h, apacket* p) { if (rem_size) { len += usb_packet_size - rem_size; } - CHECK(len <= sizeof(p->data)); + CHECK_LE(len, sizeof(p->data)); return usb_read(h, &p->data, len); } |