Fixed following findings reported by cppcheck

* avr910.c:625 (error) Possible null pointer dereference: cmd - otherwise it is redundant to check if cmd is null at line 624
	* avr910.c:626 (error) Possible null pointer dereference: cmd - otherwise it is redundant to check if cmd is null at line 624
	* avr910.c:168 (information) The scope of the variable 'devtype_1st' can be reduced
	* avr910.c:169 (information) The scope of the variable 'dev_supported' can be reduced
	* avrftdi.c:647 (error) Using sizeof for array given as function argument returns the size of pointer.
	* stk500v2.c:3347 (error) Memory leak: b
	* stk500v2.c:3452 (error) Memory leak: b
	* usbasp.c:554 (error) Using sizeof for array given as function argument returns the size of pointer.
	* usbasp.c:485 (information) The scope of the variable 'dly' can be reduced

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1035 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
rliebscher
2012-01-08 17:09:40 +00:00
parent 1c7843a191
commit 9ccde79fde
6 changed files with 38 additions and 12 deletions

View File

@@ -482,7 +482,6 @@ static void usbasp_display(PROGRAMMER * pgm, const char * p)
/* Universal functions: for both SPI and TPI */
static int usbasp_initialize(PROGRAMMER * pgm, AVRPART * p)
{
int dly;
unsigned char temp[4];
unsigned char res[4];
IMPORT_PDATA(pgm);
@@ -500,7 +499,7 @@ static int usbasp_initialize(PROGRAMMER * pgm, AVRPART * p)
if(pdata->use_tpi)
{
/* calc tpiclk delay */
dly = 1500000.0 * pgm->bitclock;
int dly = 1500000.0 * pgm->bitclock;
if(dly < 1)
dly = 1;
else if(dly > 2047)
@@ -550,8 +549,10 @@ static int usbasp_initialize(PROGRAMMER * pgm, AVRPART * p)
static int usbasp_spi_cmd(PROGRAMMER * pgm, unsigned char cmd[4],
unsigned char res[4])
{
/* Do not use 'sizeof(res)'. => message from cppcheck:
Using sizeof for array given as function argument returns the size of pointer. */
int nbytes =
usbasp_transmit(pgm, 1, USBASP_FUNC_TRANSMIT, cmd, res, sizeof(res));
usbasp_transmit(pgm, 1, USBASP_FUNC_TRANSMIT, cmd, res, 4);
if(nbytes != 4){
fprintf(stderr, "%s: error: wrong responds size\n",