Submitted by limor <limor@ladyada.net>

* usbtiny.c (usbtiny_cmd): Replace sizeof() by a fixed constant
4 for the result array, because otherwise it would take the size
of a pointer which miserably fails on 64-bit machines.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@787 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Joerg Wunsch 2008-11-06 09:47:37 +00:00
parent f66015f6e1
commit 4f316d8f99
2 changed files with 10 additions and 3 deletions

View File

@ -1,3 +1,10 @@
2008-11-06 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
Submitted by limor <limor@ladyada.net>
* usbtiny.c (usbtiny_cmd): Replace sizeof() by a fixed constant
4 for the result array, because otherwise it would take the size
of a pointer which miserably fails on 64-bit machines.
2008-11-05 Joerg Wunsch <j.gnu@uriah.heep.sax.de> 2008-11-05 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
patch #6609: Using PCI parallel port cards on Windows patch #6609: Using PCI parallel port cards on Windows

View File

@ -312,19 +312,19 @@ static int usbtiny_cmd(PROGRAMMER * pgm, unsigned char cmd[4], unsigned char res
int nbytes; int nbytes;
// Make sure its empty so we don't read previous calls if it fails // Make sure its empty so we don't read previous calls if it fails
memset(res, '\0', sizeof(res) ); memset(res, '\0', 4 );
nbytes = usb_in( pgm, USBTINY_SPI, nbytes = usb_in( pgm, USBTINY_SPI,
(cmd[1] << 8) | cmd[0], // convert to 16-bit words (cmd[1] << 8) | cmd[0], // convert to 16-bit words
(cmd[3] << 8) | cmd[2], // " (cmd[3] << 8) | cmd[2], // "
res, sizeof(res), 8 * PDATA(pgm)->sck_period ); res, 4, 8 * PDATA(pgm)->sck_period );
if (verbose > 1) { if (verbose > 1) {
// print out the data we sent and received // print out the data we sent and received
printf( "CMD: [%02x %02x %02x %02x] [%02x %02x %02x %02x]\n", printf( "CMD: [%02x %02x %02x %02x] [%02x %02x %02x %02x]\n",
cmd[0], cmd[1], cmd[2], cmd[3], cmd[0], cmd[1], cmd[2], cmd[3],
res[0], res[1], res[2], res[3] ); res[0], res[1], res[2], res[3] );
} }
return ((nbytes == sizeof(res)) && // should have read 4 bytes return ((nbytes == 4) && // should have read 4 bytes
res[2] == cmd[1]); // AVR's do a delayed-echo thing res[2] == cmd[1]); // AVR's do a delayed-echo thing
} }