From e46720938d10609a806f984ffd6b8a4b19d4ba85 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Mon, 28 Aug 2017 14:43:24 -0700 Subject: 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 --- adb/transport_usb.cpp | 8 ++++---- 1 file 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); } -- cgit v1.2.3