From: Antonio Ospite Date: Wed, 10 Jun 2015 10:42:39 +0000 (+0200) Subject: am7xxx: split declaration and initialization of the "transferred" variable X-Git-Tag: v0.1.6~15 X-Git-Url: https://git.ao2.it/libam7xxx.git/commitdiff_plain/1515bbc91513eb1c32fc099e70e61028236be546?hp=6ced305e55e2ffb7bbc52d6991ca392331780f73 am7xxx: split declaration and initialization of the "transferred" variable This makes it clearer than we mean to initialize the variable to 0 before _each_ libusb_bulk_transfer() call. --- diff --git a/src/am7xxx.c b/src/am7xxx.c index 94b01ac..d619f89 100644 --- a/src/am7xxx.c +++ b/src/am7xxx.c @@ -381,8 +381,9 @@ static void trace_dump_buffer(am7xxx_context *ctx, const char *message, static int read_data(am7xxx_device *dev, uint8_t *buffer, unsigned int len) { int ret; - int transferred = 0; + int transferred; + transferred = 0; ret = libusb_bulk_transfer(dev->usb_device, 0x81, buffer, len, &transferred, 0); if (ret != 0 || (unsigned int)transferred != len) { error(dev->ctx, "%s. Transferred: %d (expected %u)\n", @@ -398,10 +399,11 @@ static int read_data(am7xxx_device *dev, uint8_t *buffer, unsigned int len) static int send_data(am7xxx_device *dev, uint8_t *buffer, unsigned int len) { int ret; - int transferred = 0; + int transferred; trace_dump_buffer(dev->ctx, "sending -->", buffer, len); + transferred = 0; ret = libusb_bulk_transfer(dev->usb_device, 0x1, buffer, len, &transferred, 0); if (ret != 0 || (unsigned int)transferred != len) { error(dev->ctx, "%s. Transferred: %d (expected %u)\n",