src/flash/nor/at91sam3|4l|7: fix clang static analyzer warnings

Change-Id: I5cd2b2ebb2bd1980bdd1632b5c35bda9718a1089
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5365
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
This commit is contained in:
Tomas Vanek 2019-12-20 23:18:37 +01:00
parent 122c80087c
commit b852429500
3 changed files with 4 additions and 7 deletions

View File

@ -3653,6 +3653,7 @@ showall:
} }
if ((who >= 0) && (((unsigned)(who)) < pChip->details.n_gpnvms)) { if ((who >= 0) && (((unsigned)(who)) < pChip->details.n_gpnvms)) {
r = FLASHD_GetGPNVM(&(pChip->details.bank[0]), who, &v); r = FLASHD_GetGPNVM(&(pChip->details.bank[0]), who, &v);
if (r == ERROR_OK)
command_print(CMD, "sam3-gpnvm%u: %u", who, v); command_print(CMD, "sam3-gpnvm%u: %u", who, v);
return r; return r;
} else { } else {

View File

@ -601,6 +601,7 @@ static int sam4l_write(struct flash_bank *bank, const uint8_t *buffer,
/* There's at least one aligned page to write out. */ /* There's at least one aligned page to write out. */
if (count >= chip->page_size) { if (count >= chip->page_size) {
assert(chip->page_size > 0);
int np = count / chip->page_size + ((count % chip->page_size) ? 1 : 0); int np = count / chip->page_size + ((count % chip->page_size) ? 1 : 0);
for (int i = 0; i < np; i++) { for (int i = 0; i < np; i++) {

View File

@ -711,8 +711,6 @@ FLASH_BANK_COMMAND_HANDLER(at91sam7_flash_bank_command)
uint16_t page_size; uint16_t page_size;
uint16_t num_nvmbits; uint16_t num_nvmbits;
char *target_name_t;
int bnk, sec; int bnk, sec;
at91sam7_info = malloc(sizeof(struct at91sam7_flash_bank)); at91sam7_info = malloc(sizeof(struct at91sam7_flash_bank));
@ -753,9 +751,6 @@ FLASH_BANK_COMMAND_HANDLER(at91sam7_flash_bank_command)
return ERROR_OK; return ERROR_OK;
} }
target_name_t = calloc(strlen(CMD_ARGV[7]) + 1, sizeof(char));
strcpy(target_name_t, CMD_ARGV[7]);
/* calculate bank size */ /* calculate bank size */
bank_size = num_sectors * pages_per_sector * page_size; bank_size = num_sectors * pages_per_sector * page_size;
@ -794,7 +789,7 @@ FLASH_BANK_COMMAND_HANDLER(at91sam7_flash_bank_command)
at91sam7_info = t_bank->driver_priv; at91sam7_info = t_bank->driver_priv;
at91sam7_info->target_name = target_name_t; at91sam7_info->target_name = strdup(CMD_ARGV[7]);
at91sam7_info->flashmode = 0; at91sam7_info->flashmode = 0;
at91sam7_info->ext_freq = ext_freq; at91sam7_info->ext_freq = ext_freq;
at91sam7_info->num_nvmbits = num_nvmbits; at91sam7_info->num_nvmbits = num_nvmbits;