From a28d2feb4f3712c13bfc7f1f89ee9f92b9679f7e Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 22 Sep 2017 21:36:39 +0200 Subject: [PATCH] Replace the size macro with the sizeof operator --- src/uwatec_g2.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/uwatec_g2.c b/src/uwatec_g2.c index f6b0b02..b04d761 100644 --- a/src/uwatec_g2.c +++ b/src/uwatec_g2.c @@ -71,17 +71,17 @@ receive_data (uwatec_g2_device_t *device, dc_event_progress_t *progress, unsigne dc_status_t rc = DC_STATUS_SUCCESS; unsigned int len = 0; - rc = dc_usbhid_read (device->usbhid, buf, PACKET_SIZE, &transferred); + rc = dc_usbhid_read (device->usbhid, buf, sizeof(buf), &transferred); if (rc != DC_STATUS_SUCCESS) { ERROR (device->base.context, "read interrupt transfer failed"); return rc; } - if (transferred != PACKET_SIZE) { - ERROR (device->base.context, "incomplete read interrupt transfer (got " DC_PRINTF_SIZE ", expected %d)", transferred, PACKET_SIZE); + if (transferred != sizeof(buf)) { + ERROR (device->base.context, "incomplete read interrupt transfer (got " DC_PRINTF_SIZE ", expected " DC_PRINTF_SIZE ")", transferred, sizeof(buf)); return DC_STATUS_PROTOCOL; } len = buf[0]; - if (len >= PACKET_SIZE) { + if (len >= sizeof(buf)) { ERROR (device->base.context, "read interrupt transfer returns impossible packet size (%d)", len); return DC_STATUS_PROTOCOL; } @@ -112,7 +112,7 @@ uwatec_g2_transfer (uwatec_g2_device_t *device, const unsigned char command[], u dc_status_t status = DC_STATUS_SUCCESS; size_t transferred = 0; - if (csize + 2 > PACKET_SIZE) { + if (csize + 2 > sizeof(buf)) { ERROR (device->base.context, "command too big (%d)", csize); return DC_STATUS_INVALIDARGS; }