From: Antonio Ospite Date: Thu, 23 Feb 2012 14:26:44 +0000 (+0100) Subject: am7xxx: initialize the 'transferred' variable before USB transfers X-Git-Tag: v0.1.0~2 X-Git-Url: https://git.ao2.it/libam7xxx.git/commitdiff_plain/3c0bc8695b5eb170b423a1d7598bcad5014ed87a am7xxx: initialize the 'transferred' variable before USB transfers This makes sure the subsequent error messages print a sane value when libusb fails without touching the variable. --- diff --git a/src/am7xxx.c b/src/am7xxx.c index 7ef981e..c02b539 100644 --- a/src/am7xxx.c +++ b/src/am7xxx.c @@ -181,7 +181,7 @@ static void dump_buffer(uint8_t *buffer, unsigned int len) static int read_data(am7xxx_device dev, uint8_t *buffer, unsigned int len) { int ret; - int transferred; + int transferred = 0; ret = libusb_bulk_transfer(dev, 0x81, buffer, len, &transferred, 0); if (ret != 0 || (unsigned int)transferred != len) { @@ -202,7 +202,7 @@ 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; + int transferred = 0; #if DEBUG printf("\nsending -->\n");