command_handler: change to 'argc' to CMD_ARGC

This patch converts all instances of 'argc' in COMMAND_HANDLER routines
to use CMD_ARGC.
This commit is contained in:
Zachary T Welch 2009-11-15 04:57:12 -08:00
parent 5b9899d6ea
commit 7bf1a86e47
64 changed files with 311 additions and 311 deletions

View File

@ -2365,7 +2365,7 @@ COMMAND_HANDLER(sam3_handle_gpnvm_command)
}
switch (argc) {
switch (CMD_ARGC) {
default:
command_print(cmd_ctx,"Too many parameters\n");
return ERROR_COMMAND_SYNTAX_ERROR;
@ -2438,7 +2438,7 @@ COMMAND_HANDLER(sam3_handle_slowclk_command)
}
switch (argc) {
switch (CMD_ARGC) {
case 0:
// show
break;

View File

@ -743,7 +743,7 @@ FLASH_BANK_COMMAND_HANDLER(at91sam7_flash_bank_command)
at91sam7_info->ext_freq = 0;
at91sam7_info->flash_autodetection = 0;
if (argc < 13)
if (CMD_ARGC < 13)
{
at91sam7_info->flash_autodetection = 1;
return ERROR_OK;
@ -760,7 +760,7 @@ FLASH_BANK_COMMAND_HANDLER(at91sam7_flash_bank_command)
COMMAND_PARSE_NUMBER(u16, args[11], page_size);
COMMAND_PARSE_NUMBER(u16, args[12], num_nvmbits);
if (argc == 14) {
if (CMD_ARGC == 14) {
unsigned long freq;
COMMAND_PARSE_NUMBER(ulong, args[13], freq);
ext_freq = freq * 1000;
@ -1107,7 +1107,7 @@ COMMAND_HANDLER(at91sam7_handle_gpnvm_command)
struct at91sam7_flash_bank *at91sam7_info;
int retval;
if (argc != 2)
if (CMD_ARGC != 2)
{
command_print(cmd_ctx, "at91sam7 gpnvm <bit> <set | clear>");
return ERROR_OK;

View File

@ -184,7 +184,7 @@ FLASH_BANK_COMMAND_HANDLER(avrf_flash_bank_command)
{
struct avrf_flash_bank *avrf_info;
if (argc < 6)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank avr configuration");
return ERROR_FLASH_BANK_INVALID;
@ -419,7 +419,7 @@ COMMAND_HANDLER(avrf_handle_mass_erase_command)
{
int i;
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "avr mass_erase <bank>");
return ERROR_OK;

View File

@ -606,7 +606,7 @@ FLASH_BANK_COMMAND_HANDLER(cfi_flash_bank_command)
{
struct cfi_flash_bank *cfi_info;
if (argc < 6)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank cfi configuration");
return ERROR_FLASH_BANK_INVALID;
@ -633,7 +633,7 @@ FLASH_BANK_COMMAND_HANDLER(cfi_flash_bank_command)
cfi_info->jedec_probe = 0;
cfi_info->not_cfi = 0;
for (unsigned i = 6; i < argc; i++)
for (unsigned i = 6; i < CMD_ARGC; i++)
{
if (strcmp(args[i], "x16_as_x8") == 0)
{

View File

@ -645,7 +645,7 @@ NAND_DEVICE_COMMAND_HANDLER(davinci_nand_device_command)
* - aemif address
* Plus someday, optionally, ALE and CLE masks.
*/
if (argc < 5) {
if (CMD_ARGC < 5) {
LOG_ERROR("parameters: %s target "
"chip_addr hwecc_mode aemif_addr",
args[0]);

View File

@ -109,7 +109,7 @@ FLASH_BANK_COMMAND_HANDLER(ecosflash_flash_bank_command)
{
struct ecosflash_flash_bank *info;
if (argc < 7)
if (CMD_ARGC < 7)
{
LOG_WARNING("incomplete flash_bank ecosflash configuration");
return ERROR_FLASH_BANK_INVALID;

View File

@ -41,7 +41,7 @@ FLASH_BANK_COMMAND_HANDLER(faux_flash_bank_command)
{
struct faux_flash_bank *info;
if (argc < 6)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank faux configuration");
return ERROR_FLASH_BANK_INVALID;

View File

@ -222,7 +222,7 @@ COMMAND_HANDLER(handle_flash_bank_command)
int found = 0;
struct target *target;
if (argc < 6)
if (CMD_ARGC < 6)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
@ -303,7 +303,7 @@ COMMAND_HANDLER(handle_flash_info_command)
int j = 0;
int retval;
if (argc != 1)
if (CMD_ARGC != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
unsigned bank_nr;
@ -362,7 +362,7 @@ COMMAND_HANDLER(handle_flash_probe_command)
{
int retval;
if (argc != 1)
if (CMD_ARGC != 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
@ -397,7 +397,7 @@ COMMAND_HANDLER(handle_flash_probe_command)
COMMAND_HANDLER(handle_flash_erase_check_command)
{
if (argc != 1)
if (CMD_ARGC != 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
@ -450,7 +450,7 @@ COMMAND_HANDLER(handle_flash_erase_address_command)
struct target *target = get_current_target(cmd_ctx);
if (argc != 2)
if (CMD_ARGC != 2)
return ERROR_COMMAND_SYNTAX_ERROR;
COMMAND_PARSE_NUMBER(int, args[0], address);
@ -487,7 +487,7 @@ COMMAND_HANDLER(handle_flash_erase_address_command)
COMMAND_HANDLER(handle_flash_protect_check_command)
{
if (argc != 1)
if (CMD_ARGC != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
struct flash_bank *p;
@ -531,7 +531,7 @@ static int flash_check_sector_parameters(struct command_context *cmd_ctx,
COMMAND_HANDLER(handle_flash_erase_command)
{
if (argc != 2)
if (CMD_ARGC != 2)
return ERROR_COMMAND_SYNTAX_ERROR;
uint32_t bank_nr;
@ -571,7 +571,7 @@ COMMAND_HANDLER(handle_flash_erase_command)
COMMAND_HANDLER(handle_flash_protect_command)
{
if (argc != 3)
if (CMD_ARGC != 3)
return ERROR_COMMAND_SYNTAX_ERROR;
uint32_t bank_nr;
@ -622,7 +622,7 @@ COMMAND_HANDLER(handle_flash_write_image_command)
int retval;
if (argc < 1)
if (CMD_ARGC < 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
@ -637,13 +637,13 @@ COMMAND_HANDLER(handle_flash_write_image_command)
{
auto_erase = 1;
args++;
argc--;
CMD_ARGC--;
command_print(cmd_ctx, "auto erase enabled");
} else if (strcmp(args[0], "unlock") == 0)
{
auto_unlock = true;
args++;
argc--;
CMD_ARGC--;
command_print(cmd_ctx, "auto unlock enabled");
} else
{
@ -651,7 +651,7 @@ COMMAND_HANDLER(handle_flash_write_image_command)
}
}
if (argc < 1)
if (CMD_ARGC < 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
@ -665,7 +665,7 @@ COMMAND_HANDLER(handle_flash_write_image_command)
struct duration bench;
duration_start(&bench);
if (argc >= 2)
if (CMD_ARGC >= 2)
{
image.base_address_set = 1;
COMMAND_PARSE_NUMBER(int, args[1], image.base_address);
@ -678,7 +678,7 @@ COMMAND_HANDLER(handle_flash_write_image_command)
image.start_address_set = 0;
retval = image_open(&image, args[0], (argc == 3) ? args[2] : NULL);
retval = image_open(&image, args[0], (CMD_ARGC == 3) ? args[2] : NULL);
if (retval != ERROR_OK)
{
return retval;
@ -718,7 +718,7 @@ COMMAND_HANDLER(handle_flash_fill_command)
uint32_t i;
uint32_t wordsize;
if (argc != 3)
if (CMD_ARGC != 3)
return ERROR_COMMAND_SYNTAX_ERROR;
COMMAND_PARSE_NUMBER(u32, args[0], address);
@ -813,7 +813,7 @@ COMMAND_HANDLER(handle_flash_write_bank_command)
uint8_t *buffer;
struct fileio fileio;
if (argc != 3)
if (CMD_ARGC != 3)
return ERROR_COMMAND_SYNTAX_ERROR;
struct duration bench;

View File

@ -118,7 +118,7 @@ struct flash_driver
*
* For example, args[4] = 16 bit flash, args[5] = 32bit bus.
*
* If extra arguments are provided (@a argc > 6), they will
* If extra arguments are provided (@a CMD_ARGC > 6), they will
* start in @a args[6]. These can be used to implement
* driver-specific extensions.
*

View File

@ -424,7 +424,7 @@ FLASH_BANK_COMMAND_HANDLER(lpc2000_flash_bank_command)
{
struct lpc2000_flash_bank *lpc2000_info;
if (argc < 8)
if (CMD_ARGC < 8)
{
LOG_WARNING("incomplete flash_bank lpc2000 configuration");
return ERROR_FLASH_BANK_INVALID;
@ -469,7 +469,7 @@ FLASH_BANK_COMMAND_HANDLER(lpc2000_flash_bank_command)
lpc2000_info->calc_checksum = 0;
lpc2000_build_sector_list(bank);
if (argc >= 9)
if (CMD_ARGC >= 9)
{
if (strcmp(args[8], "calc_checksum") == 0)
lpc2000_info->calc_checksum = 1;
@ -744,7 +744,7 @@ COMMAND_HANDLER(lpc2000_handle_part_id_command)
uint32_t result_table[4];
int status_code;
if (argc < 1)
if (CMD_ARGC < 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}

View File

@ -169,7 +169,7 @@ FLASH_BANK_COMMAND_HANDLER(lpc288x_flash_bank_command)
{
struct lpc288x_flash_bank *lpc288x_info;
if (argc < 6)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank LPC288x configuration");
return ERROR_FLASH_BANK_INVALID;

View File

@ -537,7 +537,7 @@ COMMAND_HANDLER(lpc2900_handle_signature_command)
uint32_t signature[4];
if( argc < 1 )
if( CMD_ARGC < 1 )
{
LOG_WARNING( "Too few arguments. Call: lpc2900 signature <bank#>" );
return ERROR_FLASH_BANK_INVALID;
@ -583,7 +583,7 @@ COMMAND_HANDLER(lpc2900_handle_signature_command)
*/
COMMAND_HANDLER(lpc2900_handle_read_custom_command)
{
if( argc < 2 )
if( CMD_ARGC < 2 )
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
@ -654,7 +654,7 @@ COMMAND_HANDLER(lpc2900_handle_read_custom_command)
*/
COMMAND_HANDLER(lpc2900_handle_password_command)
{
if (argc < 2)
if (CMD_ARGC < 2)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
@ -689,7 +689,7 @@ COMMAND_HANDLER(lpc2900_handle_password_command)
*/
COMMAND_HANDLER(lpc2900_handle_write_custom_command)
{
if (argc < 2)
if (CMD_ARGC < 2)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
@ -724,7 +724,7 @@ COMMAND_HANDLER(lpc2900_handle_write_custom_command)
image.start_address_set = 0;
const char *filename = args[1];
const char *type = (argc >= 3) ? args[2] : NULL;
const char *type = (CMD_ARGC >= 3) ? args[2] : NULL;
retval = image_open(&image, filename, type);
if (retval != ERROR_OK)
{
@ -799,7 +799,7 @@ COMMAND_HANDLER(lpc2900_handle_write_custom_command)
*/
COMMAND_HANDLER(lpc2900_handle_secure_sector_command)
{
if (argc < 3)
if (CMD_ARGC < 3)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
@ -898,7 +898,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_sector_command)
*/
COMMAND_HANDLER(lpc2900_handle_secure_jtag_command)
{
if (argc < 1)
if (CMD_ARGC < 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
@ -1020,7 +1020,7 @@ FLASH_BANK_COMMAND_HANDLER(lpc2900_flash_bank_command)
{
struct lpc2900_flash_bank *lpc2900_info;
if (argc < 6)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank LPC2900 configuration");
return ERROR_FLASH_BANK_INVALID;

View File

@ -31,7 +31,7 @@ static int lpc3180_controller_ready(struct nand_device *nand, int timeout);
*/
NAND_DEVICE_COMMAND_HANDLER(lpc3180_nand_device_command)
{
if (argc < 3)
if (CMD_ARGC < 3)
{
LOG_WARNING("incomplete 'lpc3180' nand flash configuration");
return ERROR_FLASH_BANK_INVALID;
@ -836,7 +836,7 @@ COMMAND_HANDLER(handle_lpc3180_select_command)
"no", "mlc", "slc"
};
if ((argc < 1) || (argc > 2))
if ((CMD_ARGC < 1) || (CMD_ARGC > 2))
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
@ -852,7 +852,7 @@ COMMAND_HANDLER(handle_lpc3180_select_command)
lpc3180_info = nand->controller_priv;
if (argc == 2)
if (CMD_ARGC == 2)
{
if (strcmp(args[1], "mlc") == 0)
{

View File

@ -710,7 +710,7 @@ COMMAND_HANDLER(mg_write_cmd)
struct fileio fileio;
int ret;
if (argc != 3) {
if (CMD_ARGC != 3) {
return ERROR_COMMAND_SYNTAX_ERROR;
}
@ -775,7 +775,7 @@ COMMAND_HANDLER(mg_dump_cmd)
struct fileio fileio;
int ret;
if (argc != 4) {
if (CMD_ARGC != 4) {
return ERROR_COMMAND_SYNTAX_ERROR;
}
@ -1223,7 +1223,7 @@ COMMAND_HANDLER(mg_config_cmd)
if ((ret = mg_mflash_rst()) != ERROR_OK)
return ret;
switch (argc) {
switch (CMD_ARGC) {
case 2:
if (!strcmp(args[1], "boot"))
return mg_boot_config();
@ -1288,7 +1288,7 @@ COMMAND_HANDLER(mg_bank_cmd)
struct target *target;
int i;
if (argc < 4)
if (CMD_ARGC < 4)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}

View File

@ -79,7 +79,7 @@ NAND_DEVICE_COMMAND_HANDLER(imx31_nand_device_command)
LOG_ERROR ("target '%s' not defined", args[1]);
return ERROR_FAIL;
}
if (argc < 3)
if (CMD_ARGC < 3)
{
LOG_ERROR ("use \"nand device imx31 target noecc|hwecc\"");
return ERROR_FAIL;

View File

@ -210,7 +210,7 @@ COMMAND_HANDLER(handle_nand_device_command)
int i;
int retval;
if (argc < 1)
if (CMD_ARGC < 1)
{
LOG_WARNING("incomplete flash device nand configuration");
return ERROR_FLASH_BANK_INVALID;
@ -1082,7 +1082,7 @@ COMMAND_HANDLER(handle_nand_info_command)
if (ERROR_OK != retval)
return retval;
switch (argc) {
switch (CMD_ARGC) {
default:
return ERROR_COMMAND_SYNTAX_ERROR;
case 1:
@ -1147,7 +1147,7 @@ COMMAND_HANDLER(handle_nand_info_command)
COMMAND_HANDLER(handle_nand_probe_command)
{
if (argc != 1)
if (CMD_ARGC != 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
@ -1175,7 +1175,7 @@ COMMAND_HANDLER(handle_nand_probe_command)
COMMAND_HANDLER(handle_nand_erase_command)
{
if (argc != 1 && argc != 3)
if (CMD_ARGC != 1 && CMD_ARGC != 3)
{
return ERROR_COMMAND_SYNTAX_ERROR;
@ -1190,7 +1190,7 @@ COMMAND_HANDLER(handle_nand_erase_command)
unsigned long length;
/* erase specified part of the chip; or else everything */
if (argc == 3) {
if (CMD_ARGC == 3) {
unsigned long size = p->erase_size * p->num_blocks;
COMMAND_PARSE_NUMBER(ulong, args[1], offset);
@ -1234,7 +1234,7 @@ COMMAND_HANDLER(handle_nand_check_bad_blocks_command)
int first = -1;
int last = -1;
if ((argc < 1) || (argc > 3) || (argc == 2))
if ((CMD_ARGC < 1) || (CMD_ARGC > 3) || (CMD_ARGC == 2))
{
return ERROR_COMMAND_SYNTAX_ERROR;
@ -1245,7 +1245,7 @@ COMMAND_HANDLER(handle_nand_check_bad_blocks_command)
if (ERROR_OK != retval)
return retval;
if (argc == 3)
if (CMD_ARGC == 3)
{
unsigned long offset;
unsigned long length;
@ -1389,7 +1389,7 @@ static COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state,
nand_fileio_init(state);
unsigned minargs = need_size ? 4 : 3;
if (argc < minargs)
if (CMD_ARGC < minargs)
return ERROR_COMMAND_SYNTAX_ERROR;
struct nand_device *nand;
@ -1414,9 +1414,9 @@ static COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state,
}
}
if (argc > minargs)
if (CMD_ARGC > minargs)
{
for (unsigned i = minargs; i < argc; i++)
for (unsigned i = minargs; i < CMD_ARGC; i++)
{
if (!strcmp(args[i], "oob_raw"))
state->oob_format |= NAND_OOB_RAW;
@ -1646,7 +1646,7 @@ COMMAND_HANDLER(handle_nand_dump_command)
COMMAND_HANDLER(handle_nand_raw_access_command)
{
if ((argc < 1) || (argc > 2))
if ((CMD_ARGC < 1) || (CMD_ARGC > 2))
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
@ -1662,7 +1662,7 @@ COMMAND_HANDLER(handle_nand_raw_access_command)
return ERROR_OK;
}
if (argc == 2)
if (CMD_ARGC == 2)
{
if (strcmp("enable", args[1]) == 0)
p->use_raw = 1;

View File

@ -49,7 +49,7 @@ FLASH_BANK_COMMAND_HANDLER(ocl_flash_bank_command)
struct arm7_9_common *arm7_9;
struct ocl_priv *ocl;
if (argc < 6)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank ocl configuration");
return ERROR_FLASH_BANK_INVALID;

View File

@ -131,7 +131,7 @@ NAND_DEVICE_COMMAND_HANDLER(orion_nand_device_command)
uint32_t base;
uint8_t ale, cle;
if (argc != 3) {
if (CMD_ARGC != 3) {
LOG_ERROR("arguments must be: <target_id> <NAND_address>\n");
return ERROR_NAND_DEVICE_INVALID;
}

View File

@ -66,7 +66,7 @@ FLASH_BANK_COMMAND_HANDLER(pic32mx_flash_bank_command)
{
struct pic32mx_flash_bank *pic32mx_info;
if (argc < 6)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank pic32mx configuration");
return ERROR_FLASH_BANK_INVALID;
@ -677,7 +677,7 @@ COMMAND_HANDLER(pic32mx_handle_lock_command)
struct target *target = NULL;
struct pic32mx_flash_bank *pic32mx_info = NULL;
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "pic32mx lock <bank>");
return ERROR_OK;
@ -723,7 +723,7 @@ COMMAND_HANDLER(pic32mx_handle_unlock_command)
struct target *target = NULL;
struct pic32mx_flash_bank *pic32mx_info = NULL;
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "pic32mx unlock <bank>");
return ERROR_OK;
@ -813,7 +813,7 @@ COMMAND_HANDLER(pic32mx_handle_chip_erase_command)
#if 0
int i;
if (argc != 0)
if (CMD_ARGC != 0)
{
command_print(cmd_ctx, "pic32mx chip_erase");
return ERROR_OK;
@ -848,7 +848,7 @@ COMMAND_HANDLER(pic32mx_handle_pgm_word_command)
uint32_t address, value;
int status, res;
if (argc != 3)
if (CMD_ARGC != 3)
{
command_print(cmd_ctx, "pic32mx pgm_word <addr> <value> <bank>");
return ERROR_OK;

View File

@ -218,7 +218,7 @@ FLASH_BANK_COMMAND_HANDLER(stellaris_flash_bank_command)
{
struct stellaris_flash_bank *stellaris_info;
if (argc < 6)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank stellaris configuration");
return ERROR_FLASH_BANK_INVALID;
@ -1132,7 +1132,7 @@ COMMAND_HANDLER(stellaris_handle_mass_erase_command)
{
int i;
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "stellaris mass_erase <bank>");
return ERROR_OK;

View File

@ -38,7 +38,7 @@ FLASH_BANK_COMMAND_HANDLER(stm32x_flash_bank_command)
{
struct stm32x_flash_bank *stm32x_info;
if (argc < 6)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank stm32x configuration");
return ERROR_FLASH_BANK_INVALID;
@ -898,7 +898,7 @@ COMMAND_HANDLER(stm32x_handle_lock_command)
struct target *target = NULL;
struct stm32x_flash_bank *stm32x_info = NULL;
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "stm32x lock <bank>");
return ERROR_OK;
@ -944,7 +944,7 @@ COMMAND_HANDLER(stm32x_handle_unlock_command)
struct target *target = NULL;
struct stm32x_flash_bank *stm32x_info = NULL;
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "stm32x unlock <bank>");
return ERROR_OK;
@ -988,7 +988,7 @@ COMMAND_HANDLER(stm32x_handle_options_read_command)
struct target *target = NULL;
struct stm32x_flash_bank *stm32x_info = NULL;
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "stm32x options_read <bank>");
return ERROR_OK;
@ -1044,7 +1044,7 @@ COMMAND_HANDLER(stm32x_handle_options_write_command)
struct stm32x_flash_bank *stm32x_info = NULL;
uint16_t optionbyte = 0xF8;
if (argc < 4)
if (CMD_ARGC < 4)
{
command_print(cmd_ctx, "stm32x options_write <bank> <SWWDG | HWWDG> <RSTSTNDBY | NORSTSTNDBY> <RSTSTOP | NORSTSTOP>");
return ERROR_OK;
@ -1153,7 +1153,7 @@ COMMAND_HANDLER(stm32x_handle_mass_erase_command)
{
int i;
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "stm32x mass_erase <bank>");
return ERROR_OK;

View File

@ -114,7 +114,7 @@ FLASH_BANK_COMMAND_HANDLER(str7x_flash_bank_command)
{
struct str7x_flash_bank *str7x_info;
if (argc < 7)
if (CMD_ARGC < 7)
{
LOG_WARNING("incomplete flash_bank str7x configuration");
return ERROR_FLASH_BANK_INVALID;
@ -611,7 +611,7 @@ COMMAND_HANDLER(str7x_handle_disable_jtag_command)
uint16_t ProtectionLevel = 0;
uint16_t ProtectionRegs;
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "str7x disable_jtag <bank>");
return ERROR_OK;

View File

@ -121,7 +121,7 @@ FLASH_BANK_COMMAND_HANDLER(str9x_flash_bank_command)
{
struct str9x_flash_bank *str9x_info;
if (argc < 6)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank str9x configuration");
return ERROR_FLASH_BANK_INVALID;
@ -636,7 +636,7 @@ COMMAND_HANDLER(str9x_handle_flash_config_command)
struct str9x_flash_bank *str9x_info;
struct target *target = NULL;
if (argc < 5)
if (CMD_ARGC < 5)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}

View File

@ -242,7 +242,7 @@ FLASH_BANK_COMMAND_HANDLER(str9xpec_flash_bank_command)
struct arm7_9_common *arm7_9 = NULL;
struct arm_jtag *jtag_info = NULL;
if (argc < 6)
if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank str9x configuration");
return ERROR_FLASH_BANK_INVALID;
@ -734,7 +734,7 @@ COMMAND_HANDLER(str9xpec_handle_part_id_command)
uint32_t idcode;
struct str9xpec_flash_controller *str9xpec_info = NULL;
if (argc < 1)
if (CMD_ARGC < 1)
return ERROR_COMMAND_SYNTAX_ERROR;
struct flash_bank *bank;
@ -782,7 +782,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_read_command)
uint8_t status;
struct str9xpec_flash_controller *str9xpec_info = NULL;
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "str9xpec options_read <bank>");
return ERROR_OK;
@ -898,7 +898,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_write_command)
{
uint8_t status;
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "str9xpec options_write <bank>");
return ERROR_OK;
@ -921,7 +921,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_cmap_command)
{
struct str9xpec_flash_controller *str9xpec_info = NULL;
if (argc < 2)
if (CMD_ARGC < 2)
{
command_print(cmd_ctx, "str9xpec options_cmap <bank> <bank0 | bank1>");
return ERROR_OK;
@ -950,7 +950,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_lvdthd_command)
{
struct str9xpec_flash_controller *str9xpec_info = NULL;
if (argc < 2)
if (CMD_ARGC < 2)
{
command_print(cmd_ctx, "str9xpec options_lvdthd <bank> <2.4v | 2.7v>");
return ERROR_OK;
@ -979,7 +979,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_lvdsel_command)
{
struct str9xpec_flash_controller *str9xpec_info = NULL;
if (argc < 2)
if (CMD_ARGC < 2)
{
command_print(cmd_ctx, "str9xpec options_lvdsel <bank> <vdd | vdd_vddq>");
return ERROR_OK;
@ -1008,7 +1008,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_lvdwarn_command)
{
struct str9xpec_flash_controller *str9xpec_info = NULL;
if (argc < 2)
if (CMD_ARGC < 2)
{
command_print(cmd_ctx, "str9xpec options_lvdwarn <bank> <vdd | vdd_vddq>");
return ERROR_OK;
@ -1037,7 +1037,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_lock_command)
{
uint8_t status;
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "str9xpec lock <bank>");
return ERROR_OK;
@ -1060,7 +1060,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_unlock_command)
{
uint8_t status;
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "str9xpec unlock <bank>");
return ERROR_OK;
@ -1086,7 +1086,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_enable_turbo_command)
struct jtag_tap *tap2;
struct str9xpec_flash_controller *str9xpec_info = NULL;
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "str9xpec enable_turbo <bank>");
return ERROR_OK;
@ -1133,7 +1133,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_disable_turbo_command)
struct jtag_tap *tap;
struct str9xpec_flash_controller *str9xpec_info = NULL;
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "str9xpec disable_turbo <bank>");
return ERROR_OK;

View File

@ -291,12 +291,12 @@ static uint32_t flashKeys[4];
COMMAND_HANDLER(tms470_handle_flash_keyset_command)
{
if (argc > 4)
if (CMD_ARGC > 4)
{
command_print(cmd_ctx, "tms470 flash_keyset <key0> <key1> <key2> <key3>");
return ERROR_INVALID_ARGUMENTS;
}
else if (argc == 4)
else if (CMD_ARGC == 4)
{
int i;
@ -314,7 +314,7 @@ COMMAND_HANDLER(tms470_handle_flash_keyset_command)
keysSet = 1;
}
else if (argc != 0)
else if (CMD_ARGC != 0)
{
command_print(cmd_ctx, "tms470 flash_keyset <key0> <key1> <key2> <key3>");
return ERROR_INVALID_ARGUMENTS;
@ -355,12 +355,12 @@ static int oscMHz = 12;
COMMAND_HANDLER(tms470_handle_osc_megahertz_command)
{
if (argc > 1)
if (CMD_ARGC > 1)
{
command_print(cmd_ctx, "tms470 osc_megahertz <MHz>");
return ERROR_INVALID_ARGUMENTS;
}
else if (argc == 1)
else if (CMD_ARGC == 1)
{
sscanf(args[0], "%d", &oscMHz);
}
@ -384,12 +384,12 @@ static int plldis = 0;
COMMAND_HANDLER(tms470_handle_plldis_command)
{
if (argc > 1)
if (CMD_ARGC > 1)
{
command_print(cmd_ctx, "tms470 plldis <0 | 1>");
return ERROR_INVALID_ARGUMENTS;
}
else if (argc == 1)
else if (CMD_ARGC == 1)
{
sscanf(args[0], "%d", &plldis);
plldis = plldis ? 1 : 0;

View File

@ -24,12 +24,12 @@
static COMMAND_HELPER(handle_hello_args, const char **sep, const char **name)
{
if (argc > 1)
if (CMD_ARGC > 1)
{
LOG_ERROR("%s: too many arguments", CMD_NAME);
return ERROR_COMMAND_SYNTAX_ERROR;
}
if (1 == argc)
if (1 == CMD_ARGC)
{
*sep = " ";
*name = args[0];

View File

@ -723,14 +723,14 @@ static int jim_capture(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
COMMAND_HANDLER(handle_sleep_command)
{
bool busy = false;
if (argc == 2)
if (CMD_ARGC == 2)
{
if (strcmp(args[1], "busy") == 0)
busy = true;
else
return ERROR_COMMAND_SYNTAX_ERROR;
}
else if (argc < 1 || argc > 2)
else if (CMD_ARGC < 1 || CMD_ARGC > 2)
return ERROR_COMMAND_SYNTAX_ERROR;
unsigned long duration = 0;
@ -755,7 +755,7 @@ COMMAND_HANDLER(handle_sleep_command)
COMMAND_HANDLER(handle_fast_command)
{
if (argc != 1)
if (CMD_ARGC != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
fast_and_dangerous = strcmp("enable", args[0]) == 0;

View File

@ -59,7 +59,7 @@
COMMAND_HANDLER(handle_rm_command)
{
if (argc != 1)
if (CMD_ARGC != 1)
{
command_print(cmd_ctx, "rm <filename>");
return ERROR_INVALID_ARGUMENTS;
@ -135,7 +135,7 @@ int loadFile(const char *fileName, void **data, size_t *len)
COMMAND_HANDLER(handle_cat_command)
{
if (argc != 1)
if (CMD_ARGC != 1)
{
command_print(cmd_ctx, "cat <filename>");
return ERROR_INVALID_ARGUMENTS;
@ -161,7 +161,7 @@ COMMAND_HANDLER(handle_cat_command)
COMMAND_HANDLER(handle_trunc_command)
{
if (argc != 1)
if (CMD_ARGC != 1)
{
command_print(cmd_ctx, "trunc <filename>");
return ERROR_INVALID_ARGUMENTS;
@ -180,7 +180,7 @@ COMMAND_HANDLER(handle_meminfo_command)
static int prev = 0;
struct mallinfo info;
if (argc != 0)
if (CMD_ARGC != 0)
{
command_print(cmd_ctx, "meminfo");
return ERROR_INVALID_ARGUMENTS;
@ -202,7 +202,7 @@ COMMAND_HANDLER(handle_meminfo_command)
COMMAND_HANDLER(handle_append_command)
{
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx,
"append <filename> [<string1>, [<string2>, ...]]");
@ -217,17 +217,17 @@ COMMAND_HANDLER(handle_append_command)
fseek(config_file, 0, SEEK_END);
unsigned i;
for (i = 1; i < argc; i++)
for (i = 1; i < CMD_ARGC; i++)
{
if (fwrite(args[i], 1, strlen(args[i]), config_file) != strlen(args[i]))
break;
if (i != argc - 1)
if (i != CMD_ARGC - 1)
{
if (fwrite(" ", 1, 1, config_file) != 1)
break;
}
}
if ((i == argc) && (fwrite("\n", 1, 1, config_file) == 1))
if ((i == CMD_ARGC) && (fwrite("\n", 1, 1, config_file) == 1))
{
retval = ERROR_OK;
}
@ -241,7 +241,7 @@ COMMAND_HANDLER(handle_append_command)
COMMAND_HANDLER(handle_cp_command)
{
if (argc != 2)
if (CMD_ARGC != 2)
{
return ERROR_INVALID_ARGUMENTS;
}

View File

@ -275,13 +275,13 @@ void log_printf_lf(enum log_levels level, const char *file, unsigned line, const
*/
COMMAND_HANDLER(handle_debug_level_command)
{
if (argc == 1)
if (CMD_ARGC == 1)
{
unsigned new_level;
COMMAND_PARSE_NUMBER(uint, args[0], new_level);
debug_level = MIN(new_level, LOG_LVL_DEBUG);
}
else if (argc > 1)
else if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
if (debug_level >= LOG_LVL_DEBUG && server_use_pipes == 1)
@ -303,7 +303,7 @@ COMMAND_HANDLER(handle_debug_level_command)
COMMAND_HANDLER(handle_log_output_command)
{
if (argc == 1)
if (CMD_ARGC == 1)
{
FILE* file = fopen(args[0], "w");

View File

@ -497,7 +497,7 @@ static int amt_jtagaccel_quit(void)
COMMAND_HANDLER(amt_jtagaccel_handle_parport_port_command)
{
if (argc == 1)
if (CMD_ARGC == 1)
{
/* only if the port wasn't overwritten by cmdline */
if (amt_jtagaccel_port == 0)
@ -520,7 +520,7 @@ COMMAND_HANDLER(amt_jtagaccel_handle_parport_port_command)
COMMAND_HANDLER(amt_jtagaccel_handle_rtck_command)
{
if (argc == 0)
if (CMD_ARGC == 0)
{
command_print(cmd_ctx, "amt_jtagaccel RTCK feature %s", (rtck_enabled) ? "enabled" : "disabled");
return ERROR_OK;

View File

@ -187,7 +187,7 @@ static int at91rm9200_speed(int speed)
static int at91rm9200_handle_device_command(struct command_context *cmd_ctx, char *cmd, char **args, int argc)
{
if (argc == 0)
if (CMD_ARGC == 0)
return ERROR_OK;
/* only if the device name wasn't overwritten by cmdline */

View File

@ -2801,7 +2801,7 @@ COMMAND_HANDLER(ft2232_handle_device_desc_command)
{
char *cp;
char buf[200];
if (argc == 1)
if (CMD_ARGC == 1)
{
ft2232_device_desc = strdup(args[0]);
cp = strchr(ft2232_device_desc, 0);
@ -2833,7 +2833,7 @@ COMMAND_HANDLER(ft2232_handle_device_desc_command)
COMMAND_HANDLER(ft2232_handle_serial_command)
{
if (argc == 1)
if (CMD_ARGC == 1)
{
ft2232_serial = strdup(args[0]);
}
@ -2847,7 +2847,7 @@ COMMAND_HANDLER(ft2232_handle_serial_command)
COMMAND_HANDLER(ft2232_handle_layout_command)
{
if (argc == 0)
if (CMD_ARGC == 0)
return ERROR_OK;
ft2232_layout = malloc(strlen(args[0]) + 1);
@ -2858,23 +2858,23 @@ COMMAND_HANDLER(ft2232_handle_layout_command)
COMMAND_HANDLER(ft2232_handle_vid_pid_command)
{
if (argc > MAX_USB_IDS * 2)
if (CMD_ARGC > MAX_USB_IDS * 2)
{
LOG_WARNING("ignoring extra IDs in ft2232_vid_pid "
"(maximum is %d pairs)", MAX_USB_IDS);
argc = MAX_USB_IDS * 2;
CMD_ARGC = MAX_USB_IDS * 2;
}
if (argc < 2 || (argc & 1))
if (CMD_ARGC < 2 || (CMD_ARGC & 1))
{
LOG_WARNING("incomplete ft2232_vid_pid configuration directive");
if (argc < 2)
if (CMD_ARGC < 2)
return ERROR_COMMAND_SYNTAX_ERROR;
/* remove the incomplete trailing id */
argc -= 1;
CMD_ARGC -= 1;
}
unsigned i;
for (i = 0; i < argc; i += 2)
for (i = 0; i < CMD_ARGC; i += 2)
{
COMMAND_PARSE_NUMBER(u16, args[i], ft2232_vid[i >> 1]);
COMMAND_PARSE_NUMBER(u16, args[i + 1], ft2232_pid[i >> 1]);
@ -2891,7 +2891,7 @@ COMMAND_HANDLER(ft2232_handle_vid_pid_command)
COMMAND_HANDLER(ft2232_handle_latency_command)
{
if (argc == 1)
if (CMD_ARGC == 1)
{
ft2232_latency = atoi(args[0]);
}

View File

@ -543,7 +543,7 @@ static int gw16012_quit(void)
COMMAND_HANDLER(gw16012_handle_parport_port_command)
{
if (argc == 1)
if (CMD_ARGC == 1)
{
/* only if the port wasn't overwritten by cmdline */
if (gw16012_port == 0)

View File

@ -627,7 +627,7 @@ COMMAND_HANDLER(jlink_handle_jlink_info_command)
COMMAND_HANDLER(jlink_handle_jlink_hw_jtag_command)
{
switch (argc) {
switch (CMD_ARGC) {
case 0:
command_print(cmd_ctx, "jlink hw jtag %i", jlink_hw_jtag_version);
break;

View File

@ -411,7 +411,7 @@ static int parport_quit(void)
COMMAND_HANDLER(parport_handle_parport_port_command)
{
if (argc == 1)
if (CMD_ARGC == 1)
{
/* only if the port wasn't overwritten by cmdline */
if (parport_port == 0)
@ -432,7 +432,7 @@ COMMAND_HANDLER(parport_handle_parport_port_command)
COMMAND_HANDLER(parport_handle_parport_cable_command)
{
if (argc == 0)
if (CMD_ARGC == 0)
return ERROR_OK;
/* only if the cable name wasn't overwritten by cmdline */
@ -447,7 +447,7 @@ COMMAND_HANDLER(parport_handle_parport_cable_command)
COMMAND_HANDLER(parport_handle_write_on_exit_command)
{
if (argc != 1)
if (CMD_ARGC != 1)
{
command_print(cmd_ctx, "usage: parport_write_on_exit <on | off>");
return ERROR_OK;
@ -463,7 +463,7 @@ COMMAND_HANDLER(parport_handle_write_on_exit_command)
COMMAND_HANDLER(parport_handle_parport_toggling_time_command)
{
if (argc == 1) {
if (CMD_ARGC == 1) {
uint32_t ns;
int retval = parse_u32(args[0], &ns);

View File

@ -752,7 +752,7 @@ static char *presto_serial;
COMMAND_HANDLER(presto_handle_serial_command)
{
if (argc == 1)
if (CMD_ARGC == 1)
{
if (presto_serial)
free(presto_serial);

View File

@ -605,7 +605,7 @@ static int default_srst_asserted(int *srst_asserted)
COMMAND_HANDLER(handle_interface_list_command)
{
if (strcmp(CMD_NAME, "interface_list") == 0 && argc > 0)
if (strcmp(CMD_NAME, "interface_list") == 0 && CMD_ARGC > 0)
return ERROR_COMMAND_SYNTAX_ERROR;
command_print(cmd_ctx, "The following JTAG interfaces are available:");
@ -628,7 +628,7 @@ COMMAND_HANDLER(handle_interface_command)
}
/* interface name is a mandatory argument */
if (argc != 1 || args[0][0] == '\0')
if (CMD_ARGC != 1 || args[0][0] == '\0')
return ERROR_COMMAND_SYNTAX_ERROR;
for (unsigned i = 0; NULL != jtag_interfaces[i]; i++)
@ -711,7 +711,7 @@ COMMAND_HANDLER(handle_reset_config_command)
* Here we don't care about the order, and only change values
* which have been explicitly specified.
*/
for (; argc; argc--, args++) {
for (; CMD_ARGC; CMD_ARGC--, args++) {
int tmp = 0;
int m;
@ -897,9 +897,9 @@ next:
COMMAND_HANDLER(handle_jtag_nsrst_delay_command)
{
if (argc > 1)
if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
if (argc == 1)
if (CMD_ARGC == 1)
{
unsigned delay;
COMMAND_PARSE_NUMBER(uint, args[0], delay);
@ -912,9 +912,9 @@ COMMAND_HANDLER(handle_jtag_nsrst_delay_command)
COMMAND_HANDLER(handle_jtag_ntrst_delay_command)
{
if (argc > 1)
if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
if (argc == 1)
if (CMD_ARGC == 1)
{
unsigned delay;
COMMAND_PARSE_NUMBER(uint, args[0], delay);
@ -927,9 +927,9 @@ COMMAND_HANDLER(handle_jtag_ntrst_delay_command)
COMMAND_HANDLER(handle_jtag_nsrst_assert_width_command)
{
if (argc > 1)
if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
if (argc == 1)
if (CMD_ARGC == 1)
{
unsigned delay;
COMMAND_PARSE_NUMBER(uint, args[0], delay);
@ -942,9 +942,9 @@ COMMAND_HANDLER(handle_jtag_nsrst_assert_width_command)
COMMAND_HANDLER(handle_jtag_ntrst_assert_width_command)
{
if (argc > 1)
if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
if (argc == 1)
if (CMD_ARGC == 1)
{
unsigned delay;
COMMAND_PARSE_NUMBER(uint, args[0], delay);
@ -957,11 +957,11 @@ COMMAND_HANDLER(handle_jtag_ntrst_assert_width_command)
COMMAND_HANDLER(handle_jtag_khz_command)
{
if (argc > 1)
if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
int retval = ERROR_OK;
if (argc == 1)
if (CMD_ARGC == 1)
{
unsigned khz = 0;
COMMAND_PARSE_NUMBER(uint, args[0], khz);
@ -986,11 +986,11 @@ COMMAND_HANDLER(handle_jtag_khz_command)
COMMAND_HANDLER(handle_jtag_rclk_command)
{
if (argc > 1)
if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
int retval = ERROR_OK;
if (argc == 1)
if (CMD_ARGC == 1)
{
unsigned khz = 0;
COMMAND_PARSE_NUMBER(uint, args[0], khz);
@ -1015,7 +1015,7 @@ COMMAND_HANDLER(handle_jtag_rclk_command)
COMMAND_HANDLER(handle_jtag_reset_command)
{
if (argc != 2)
if (CMD_ARGC != 2)
return ERROR_COMMAND_SYNTAX_ERROR;
int trst = -1;
@ -1043,7 +1043,7 @@ COMMAND_HANDLER(handle_jtag_reset_command)
COMMAND_HANDLER(handle_runtest_command)
{
if (argc != 1)
if (CMD_ARGC != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
unsigned num_clocks;
@ -1082,7 +1082,7 @@ COMMAND_HANDLER(handle_irscan_command)
struct jtag_tap *tap;
tap_state_t endstate;
if ((argc < 2) || (argc % 2))
if ((CMD_ARGC < 2) || (CMD_ARGC % 2))
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
@ -1093,21 +1093,21 @@ COMMAND_HANDLER(handle_irscan_command)
*/
endstate = TAP_IDLE;
if (argc >= 4) {
if (CMD_ARGC >= 4) {
/* have at least one pair of numbers. */
/* is last pair the magic text? */
if (strcmp("-endstate", args[argc - 2]) == 0) {
endstate = tap_state_by_name(args[argc - 1]);
if (strcmp("-endstate", args[CMD_ARGC - 2]) == 0) {
endstate = tap_state_by_name(args[CMD_ARGC - 1]);
if (endstate == TAP_INVALID)
return ERROR_COMMAND_SYNTAX_ERROR;
if (!scan_is_safe(endstate))
LOG_WARNING("unstable irscan endstate \"%s\"",
args[argc - 1]);
argc -= 2;
args[CMD_ARGC - 1]);
CMD_ARGC -= 2;
}
}
int num_fields = argc / 2;
int num_fields = CMD_ARGC / 2;
size_t fields_len = sizeof(struct scan_field) * num_fields;
fields = malloc(fields_len);
memset(fields, 0, fields_len);
@ -1352,10 +1352,10 @@ static int Jim_Command_flush_count(Jim_Interp *interp, int argc, Jim_Obj *const
COMMAND_HANDLER(handle_verify_ircapture_command)
{
if (argc > 1)
if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
if (argc == 1)
if (CMD_ARGC == 1)
{
if (strcmp(args[0], "enable") == 0)
jtag_set_verify_capture_ir(true);
@ -1373,10 +1373,10 @@ COMMAND_HANDLER(handle_verify_ircapture_command)
COMMAND_HANDLER(handle_verify_jtag_command)
{
if (argc > 1)
if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
if (argc == 1)
if (CMD_ARGC == 1)
{
if (strcmp(args[0], "enable") == 0)
jtag_set_verify(true);
@ -1394,10 +1394,10 @@ COMMAND_HANDLER(handle_verify_jtag_command)
COMMAND_HANDLER(handle_tms_sequence_command)
{
if (argc > 1)
if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
if (argc == 1)
if (CMD_ARGC == 1)
{
bool use_new_table;
if (strcmp(args[0], "short") == 0)

View File

@ -1324,7 +1324,7 @@ static void vsllink_simple_command(uint8_t command)
COMMAND_HANDLER(vsllink_handle_mode_command)
{
if (argc != 1) {
if (CMD_ARGC != 1) {
LOG_ERROR("parameter error, should be one parameter for VID");
return ERROR_FAIL;
}
@ -1348,7 +1348,7 @@ COMMAND_HANDLER(vsllink_handle_mode_command)
COMMAND_HANDLER(vsllink_handle_usb_vid_command)
{
if (argc != 1)
if (CMD_ARGC != 1)
{
LOG_ERROR("parameter error, should be one parameter for VID");
return ERROR_OK;
@ -1360,7 +1360,7 @@ COMMAND_HANDLER(vsllink_handle_usb_vid_command)
COMMAND_HANDLER(vsllink_handle_usb_pid_command)
{
if (argc != 1)
if (CMD_ARGC != 1)
{
LOG_ERROR("parameter error, should be one parameter for PID");
return ERROR_OK;
@ -1371,7 +1371,7 @@ COMMAND_HANDLER(vsllink_handle_usb_pid_command)
COMMAND_HANDLER(vsllink_handle_usb_bulkin_command)
{
if (argc != 1)
if (CMD_ARGC != 1)
{
LOG_ERROR("parameter error, should be one parameter for BULKIN endpoint");
return ERROR_OK;
@ -1386,7 +1386,7 @@ COMMAND_HANDLER(vsllink_handle_usb_bulkin_command)
COMMAND_HANDLER(vsllink_handle_usb_bulkout_command)
{
if (argc != 1)
if (CMD_ARGC != 1)
{
LOG_ERROR("parameter error, should be one parameter for BULKOUT endpoint");
return ERROR_OK;
@ -1401,7 +1401,7 @@ COMMAND_HANDLER(vsllink_handle_usb_bulkout_command)
COMMAND_HANDLER(vsllink_handle_usb_interface_command)
{
if (argc != 1)
if (CMD_ARGC != 1)
{
LOG_ERROR("parameter error, should be one parameter for interface number");
return ERROR_OK;

View File

@ -52,7 +52,7 @@
/* Give TELNET a way to find out what version this is */
COMMAND_HANDLER(handle_version_command)
{
if (argc != 0)
if (CMD_ARGC != 0)
return ERROR_COMMAND_SYNTAX_ERROR;
command_print(cmd_ctx, OPENOCD_VERSION);
@ -95,7 +95,7 @@ int ioutil_init(struct command_context *cmd_ctx);
COMMAND_HANDLER(handle_init_command)
{
if (argc != 0)
if (CMD_ARGC != 0)
return ERROR_COMMAND_SYNTAX_ERROR;
int retval;

View File

@ -62,7 +62,7 @@ COMMAND_HANDLER(handle_pld_device_command)
int i;
int found = 0;
if (argc < 1)
if (CMD_ARGC < 1)
{
LOG_WARNING("incomplete 'pld device' command");
return ERROR_OK;
@ -147,7 +147,7 @@ COMMAND_HANDLER(handle_pld_load_command)
gettimeofday(&start, NULL);
if (argc < 2)
if (CMD_ARGC < 2)
{
command_print(cmd_ctx, "usage: pld load <device#> <file>");
return ERROR_OK;

View File

@ -183,7 +183,7 @@ COMMAND_HANDLER(virtex2_handle_read_stat_command)
struct virtex2_pld_device *virtex2_info;
uint32_t status;
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "usage: virtex2 read_stat <num>");
return ERROR_OK;
@ -213,7 +213,7 @@ PLD_DEVICE_COMMAND_HANDLER(virtex2_pld_device_command)
struct virtex2_pld_device *virtex2_info;
if (argc < 2)
if (CMD_ARGC < 2)
{
LOG_WARNING("incomplete pld device 'virtex2' configuration");
return ERROR_PLD_DEVICE_INVALID;

View File

@ -2245,7 +2245,7 @@ int gdb_init(void)
COMMAND_HANDLER(handle_gdb_sync_command)
{
if (argc != 0)
if (CMD_ARGC != 0)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
@ -2270,7 +2270,7 @@ COMMAND_HANDLER(handle_gdb_port_command)
COMMAND_HANDLER(handle_gdb_memory_map_command)
{
if (argc == 1)
if (CMD_ARGC == 1)
{
if (strcmp(args[0], "enable") == 0)
{
@ -2291,7 +2291,7 @@ COMMAND_HANDLER(handle_gdb_memory_map_command)
COMMAND_HANDLER(handle_gdb_flash_program_command)
{
if (argc == 1)
if (CMD_ARGC == 1)
{
if (strcmp(args[0], "enable") == 0)
{
@ -2312,7 +2312,7 @@ COMMAND_HANDLER(handle_gdb_flash_program_command)
COMMAND_HANDLER(handle_gdb_report_data_abort_command)
{
if (argc == 1)
if (CMD_ARGC == 1)
{
if (strcmp(args[0], "enable") == 0)
{
@ -2334,10 +2334,10 @@ COMMAND_HANDLER(handle_gdb_report_data_abort_command)
/* gdb_breakpoint_override */
COMMAND_HANDLER(handle_gdb_breakpoint_override_command)
{
if (argc == 0)
if (CMD_ARGC == 0)
{
} else if (argc == 1)
} else if (CMD_ARGC == 1)
{
gdb_breakpoint_override = 1;
if (strcmp(args[0], "hard") == 0)

View File

@ -551,7 +551,7 @@ int server_register_commands(struct command_context *context)
SERVER_PORT_COMMAND()
{
switch (argc) {
switch (CMD_ARGC) {
case 0:
command_print(cmd_ctx, "%d", *out);
break;

View File

@ -308,7 +308,7 @@ COMMAND_HANDLER(handle_svf_command)
int ret = ERROR_OK;
long long time_ago;
if ((argc < 1) || (argc > (1 + SVF_NUM_OF_OPTIONS)))
if ((CMD_ARGC < 1) || (CMD_ARGC > (1 + SVF_NUM_OF_OPTIONS)))
{
command_print(cmd_ctx, "usage: svf <file> [quiet]");
return ERROR_FAIL;
@ -316,7 +316,7 @@ COMMAND_HANDLER(handle_svf_command)
// parse variant
svf_quiet = 0;
for (unsigned i = 1; i < argc; i++)
for (unsigned i = 1; i < CMD_ARGC; i++)
{
if (!strcmp(args[i], "quiet"))
{

View File

@ -2005,13 +2005,13 @@ static int arm11_build_reg_cache(struct target *target)
static COMMAND_HELPER(arm11_handle_bool, bool *var, char *name)
{
if (argc == 0)
if (CMD_ARGC == 0)
{
LOG_INFO("%s is %s.", name, *var ? "enabled" : "disabled");
return ERROR_OK;
}
if (argc != 1)
if (CMD_ARGC != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
switch (args[0][0])
@ -2052,7 +2052,7 @@ BOOL_WRAPPER(hardware_step, "hardware single step")
COMMAND_HANDLER(arm11_handle_vcr)
{
switch (argc) {
switch (CMD_ARGC) {
case 0:
break;
case 1:

View File

@ -429,12 +429,12 @@ COMMAND_HANDLER(arm720t_handle_cp15_command)
}
/* one or more argument, access a single register (write if second argument is given */
if (argc >= 1)
if (CMD_ARGC >= 1)
{
uint32_t opcode;
COMMAND_PARSE_NUMBER(u32, args[0], opcode);
if (argc == 1)
if (CMD_ARGC == 1)
{
uint32_t value;
if ((retval = arm720t_read_cp15(target, opcode, &value)) != ERROR_OK)
@ -450,7 +450,7 @@ COMMAND_HANDLER(arm720t_handle_cp15_command)
command_print(cmd_ctx, "0x%8.8" PRIx32 ": 0x%8.8" PRIx32 "", opcode, value);
}
else if (argc == 2)
else if (CMD_ARGC == 2)
{
uint32_t value;
COMMAND_PARSE_NUMBER(u32, args[1], value);

View File

@ -2765,7 +2765,7 @@ COMMAND_HANDLER(handle_arm7_9_write_xpsr_command)
return ERROR_FAIL;
}
if (argc < 2)
if (CMD_ARGC < 2)
{
command_print(cmd_ctx, "usage: write_xpsr <value> <not cpsr | spsr>");
return ERROR_FAIL;
@ -2809,7 +2809,7 @@ COMMAND_HANDLER(handle_arm7_9_write_xpsr_im8_command)
return ERROR_FAIL;
}
if (argc < 3)
if (CMD_ARGC < 3)
{
command_print(cmd_ctx, "usage: write_xpsr_im8 <im8> <rotate> <not cpsr | spsr>");
return ERROR_FAIL;
@ -2849,7 +2849,7 @@ COMMAND_HANDLER(handle_arm7_9_write_core_reg_command)
return ERROR_FAIL;
}
if (argc < 3)
if (CMD_ARGC < 3)
{
command_print(cmd_ctx, "usage: write_core_reg <num> <mode> <value>");
return ERROR_FAIL;
@ -2873,7 +2873,7 @@ COMMAND_HANDLER(handle_arm7_9_dbgrq_command)
return ERROR_TARGET_INVALID;
}
if (argc > 0)
if (CMD_ARGC > 0)
{
if (strcmp("enable", args[0]) == 0)
{
@ -2905,7 +2905,7 @@ COMMAND_HANDLER(handle_arm7_9_fast_memory_access_command)
return ERROR_TARGET_INVALID;
}
if (argc > 0)
if (CMD_ARGC > 0)
{
if (strcmp("enable", args[0]) == 0)
{
@ -2937,7 +2937,7 @@ COMMAND_HANDLER(handle_arm7_9_dcc_downloads_command)
return ERROR_TARGET_INVALID;
}
if (argc > 0)
if (CMD_ARGC > 0)
{
if (strcmp("enable", args[0]) == 0)
{

View File

@ -682,7 +682,7 @@ COMMAND_HANDLER(arm920t_handle_read_cache_command)
if (retval != ERROR_OK)
return retval;
if (argc != 1)
if (CMD_ARGC != 1)
{
command_print(cmd_ctx, "usage: arm920t read_cache <filename>");
return ERROR_OK;
@ -928,7 +928,7 @@ COMMAND_HANDLER(arm920t_handle_read_mmu_command)
if (retval != ERROR_OK)
return retval;
if (argc != 1)
if (CMD_ARGC != 1)
{
command_print(cmd_ctx, "usage: arm920t read_mmu <filename>");
return ERROR_OK;
@ -1207,12 +1207,12 @@ COMMAND_HANDLER(arm920t_handle_cp15_command)
}
/* one or more argument, access a single register (write if second argument is given */
if (argc >= 1)
if (CMD_ARGC >= 1)
{
int address;
COMMAND_PARSE_NUMBER(int, args[0], address);
if (argc == 1)
if (CMD_ARGC == 1)
{
uint32_t value;
if ((retval = arm920t_read_cp15_physical(target, address, &value)) != ERROR_OK)
@ -1227,7 +1227,7 @@ COMMAND_HANDLER(arm920t_handle_cp15_command)
command_print(cmd_ctx, "%i: %8.8" PRIx32 "", address, value);
}
else if (argc == 2)
else if (CMD_ARGC == 2)
{
uint32_t value;
COMMAND_PARSE_NUMBER(u32, args[1], value);
@ -1261,12 +1261,12 @@ COMMAND_HANDLER(arm920t_handle_cp15i_command)
}
/* one or more argument, access a single register (write if second argument is given */
if (argc >= 1)
if (CMD_ARGC >= 1)
{
uint32_t opcode;
COMMAND_PARSE_NUMBER(u32, args[0], opcode);
if (argc == 1)
if (CMD_ARGC == 1)
{
uint32_t value;
if ((retval = arm920t_read_cp15_interpreted(target, opcode, 0x0, &value)) != ERROR_OK)
@ -1277,7 +1277,7 @@ COMMAND_HANDLER(arm920t_handle_cp15i_command)
command_print(cmd_ctx, "%8.8" PRIx32 ": %8.8" PRIx32 "", opcode, value);
}
else if (argc == 2)
else if (CMD_ARGC == 2)
{
uint32_t value;
COMMAND_PARSE_NUMBER(u32, args[1], value);
@ -1288,7 +1288,7 @@ COMMAND_HANDLER(arm920t_handle_cp15i_command)
}
command_print(cmd_ctx, "%8.8" PRIx32 ": %8.8" PRIx32 "", opcode, value);
}
else if (argc == 3)
else if (CMD_ARGC == 3)
{
uint32_t value;
COMMAND_PARSE_NUMBER(u32, args[1], value);

View File

@ -722,7 +722,7 @@ COMMAND_HANDLER(arm926ejs_handle_cp15_command)
int CRn;
int CRm;
if ((argc < 4) || (argc > 5))
if ((CMD_ARGC < 4) || (CMD_ARGC > 5))
{
command_print(cmd_ctx, "usage: arm926ejs cp15 <opcode_1> <opcode_2> <CRn> <CRm> [value]");
return ERROR_OK;
@ -743,7 +743,7 @@ COMMAND_HANDLER(arm926ejs_handle_cp15_command)
return ERROR_OK;
}
if (argc == 4)
if (CMD_ARGC == 4)
{
uint32_t value;
if ((retval = arm926ejs->read_cp15(target, opcode_1, opcode_2, CRn, CRm, &value)) != ERROR_OK)

View File

@ -179,12 +179,12 @@ COMMAND_HANDLER(arm966e_handle_cp15_command)
}
/* one or more argument, access a single register (write if second argument is given */
if (argc >= 1)
if (CMD_ARGC >= 1)
{
uint32_t address;
COMMAND_PARSE_NUMBER(u32, args[0], address);
if (argc == 1)
if (CMD_ARGC == 1)
{
uint32_t value;
if ((retval = arm966e_read_cp15(target, address, &value)) != ERROR_OK)
@ -202,7 +202,7 @@ COMMAND_HANDLER(arm966e_handle_cp15_command)
command_print(cmd_ctx, "%" PRIi32 ": %8.8" PRIx32,
address, value);
}
else if (argc == 2)
else if (CMD_ARGC == 2)
{
uint32_t value;
COMMAND_PARSE_NUMBER(u32, args[1], value);

View File

@ -853,7 +853,7 @@ COMMAND_HANDLER(handle_arm9tdmi_catch_vectors_command)
/* get the current setting */
vector_catch_value = buf_get_u32(vector_catch->value, 0, 8);
if (argc > 0)
if (CMD_ARGC > 0)
{
vector_catch_value = 0x0;
if (strcmp(args[0], "all") == 0)
@ -866,7 +866,7 @@ COMMAND_HANDLER(handle_arm9tdmi_catch_vectors_command)
}
else
{
for (unsigned i = 0; i < argc; i++)
for (unsigned i = 0; i < CMD_ARGC; i++)
{
/* go through list of vectors */
unsigned j;

View File

@ -1370,7 +1370,7 @@ DAP_COMMAND_HANDLER(dap_baseaddr_command)
int retval;
apselsave = swjdp->apsel;
switch (argc) {
switch (CMD_ARGC) {
case 0:
apsel = swjdp->apsel;
break;
@ -1398,7 +1398,7 @@ DAP_COMMAND_HANDLER(dap_memaccess_command)
{
uint32_t memaccess_tck;
switch (argc) {
switch (CMD_ARGC) {
case 0:
memaccess_tck = swjdp->memaccess_tck;
break;
@ -1421,7 +1421,7 @@ DAP_COMMAND_HANDLER(dap_apsel_command)
uint32_t apsel, apid;
int retval;
switch (argc) {
switch (CMD_ARGC) {
case 0:
apsel = 0;
break;
@ -1447,7 +1447,7 @@ DAP_COMMAND_HANDLER(dap_apid_command)
int retval;
apselsave = swjdp->apsel;
switch (argc) {
switch (CMD_ARGC) {
case 0:
apsel = swjdp->apsel;
break;

View File

@ -422,7 +422,7 @@ COMMAND_HANDLER(handle_armv4_5_core_state_command)
return ERROR_FAIL;
}
if (argc > 0)
if (CMD_ARGC > 0)
{
if (strcmp(args[0], "arm") == 0)
{
@ -453,7 +453,7 @@ COMMAND_HANDLER(handle_armv4_5_disassemble_command)
return ERROR_FAIL;
}
switch (argc) {
switch (CMD_ARGC) {
case 3:
if (strcmp(args[2], "thumb") != 0)
goto usage;

View File

@ -259,7 +259,7 @@ COMMAND_HANDLER(handle_dap_info_command)
struct swjdp_common *swjdp = &armv7a->swjdp_info;
uint32_t apsel;
switch (argc) {
switch (CMD_ARGC) {
case 0:
apsel = swjdp->apsel;
break;

View File

@ -766,7 +766,7 @@ COMMAND_HANDLER(handle_dap_baseaddr_command)
int retval;
apselsave = swjdp->apsel;
switch (argc) {
switch (CMD_ARGC) {
case 0:
apsel = swjdp->apsel;
break;
@ -829,7 +829,7 @@ COMMAND_HANDLER(handle_dap_info_command)
struct swjdp_common *swjdp = &armv7m->swjdp_info;
uint32_t apsel;
switch (argc) {
switch (CMD_ARGC) {
case 0:
apsel = swjdp->apsel;
break;

View File

@ -1780,7 +1780,7 @@ COMMAND_HANDLER(handle_cortex_m3_disassemble_command)
return retval;
errno = 0;
switch (argc) {
switch (CMD_ARGC) {
case 2:
COMMAND_PARSE_NUMBER(ulong, args[1], count);
/* FALL THROUGH */
@ -1832,10 +1832,10 @@ COMMAND_HANDLER(handle_cortex_m3_vector_catch_command)
mem_ap_read_atomic_u32(swjdp, DCB_DEMCR, &demcr);
if (argc > 0) {
if (CMD_ARGC > 0) {
unsigned catch = 0;
if (argc == 1) {
if (CMD_ARGC == 1) {
if (strcmp(args[0], "all") == 0) {
catch = VC_HARDERR | VC_INTERR | VC_BUSERR
| VC_STATERR | VC_CHKERR | VC_NOCPERR
@ -1845,16 +1845,16 @@ COMMAND_HANDLER(handle_cortex_m3_vector_catch_command)
goto write;
}
}
while (argc-- > 0) {
while (CMD_ARGC-- > 0) {
unsigned i;
for (i = 0; i < ARRAY_SIZE(vec_ids); i++) {
if (strcmp(args[argc], vec_ids[i].name) != 0)
if (strcmp(args[CMD_ARGC], vec_ids[i].name) != 0)
continue;
catch |= vec_ids[i].mask;
break;
}
if (i == ARRAY_SIZE(vec_ids)) {
LOG_ERROR("No CM3 vector '%s'", args[argc]);
LOG_ERROR("No CM3 vector '%s'", args[CMD_ARGC]);
return ERROR_INVALID_ARGUMENTS;
}
}
@ -1890,7 +1890,7 @@ COMMAND_HANDLER(handle_cortex_m3_mask_interrupts_command)
return ERROR_OK;
}
if (argc > 0)
if (CMD_ARGC > 0)
{
if (!strcmp(args[0], "on"))
{

View File

@ -354,7 +354,7 @@ COMMAND_HANDLER(handle_etb_config_command)
struct jtag_tap *tap;
struct arm *arm;
if (argc != 2)
if (CMD_ARGC != 2)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}

View File

@ -1263,7 +1263,7 @@ COMMAND_HANDLER(handle_etm_tracemode_command)
etmv1_tracemode_t tracemode = etm->tracemode;
switch (argc)
switch (CMD_ARGC)
{
case 0:
break;
@ -1374,7 +1374,7 @@ COMMAND_HANDLER(handle_etm_config_command)
struct etm_context *etm_ctx;
int i;
if (argc != 5)
if (CMD_ARGC != 5)
return ERROR_COMMAND_SYNTAX_ERROR;
target = get_target(args[0]);
@ -1730,7 +1730,7 @@ COMMAND_HANDLER(handle_etm_image_command)
struct arm *arm;
struct etm_context *etm_ctx;
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "usage: etm image <file> [base address] [type]");
return ERROR_FAIL;
@ -1763,7 +1763,7 @@ COMMAND_HANDLER(handle_etm_image_command)
etm_ctx->image->start_address_set = 0;
/* a base address isn't always necessary, default to 0x0 (i.e. don't relocate) */
if (argc >= 2)
if (CMD_ARGC >= 2)
{
etm_ctx->image->base_address_set = 1;
COMMAND_PARSE_NUMBER(int, args[1], etm_ctx->image->base_address);
@ -1773,7 +1773,7 @@ COMMAND_HANDLER(handle_etm_image_command)
etm_ctx->image->base_address_set = 0;
}
if (image_open(etm_ctx->image, args[0], (argc >= 3) ? args[2] : NULL) != ERROR_OK)
if (image_open(etm_ctx->image, args[0], (CMD_ARGC >= 3) ? args[2] : NULL) != ERROR_OK)
{
free(etm_ctx->image);
etm_ctx->image = NULL;
@ -1791,7 +1791,7 @@ COMMAND_HANDLER(handle_etm_dump_command)
struct etm_context *etm_ctx;
uint32_t i;
if (argc != 1)
if (CMD_ARGC != 1)
{
command_print(cmd_ctx, "usage: etm dump <file>");
return ERROR_FAIL;
@ -1859,7 +1859,7 @@ COMMAND_HANDLER(handle_etm_load_command)
struct etm_context *etm_ctx;
uint32_t i;
if (argc != 1)
if (CMD_ARGC != 1)
{
command_print(cmd_ctx, "usage: etm load <file>");
return ERROR_FAIL;
@ -1956,7 +1956,7 @@ COMMAND_HANDLER(handle_etm_trigger_percent_command)
return ERROR_FAIL;
}
if (argc > 0)
if (CMD_ARGC > 0)
{
uint32_t new_value;
COMMAND_PARSE_NUMBER(u32, args[0], new_value);

View File

@ -294,7 +294,7 @@ COMMAND_HANDLER(handle_oocd_trace_config_command)
struct target *target;
struct arm *arm;
if (argc != 2)
if (CMD_ARGC != 2)
{
LOG_ERROR("incomplete 'oocd_trace config <target> <tty>' command");
return ERROR_FAIL;

View File

@ -1648,7 +1648,7 @@ COMMAND_HANDLER(handle_targets_command)
{
struct target *target = all_targets;
if (argc == 1)
if (CMD_ARGC == 1)
{
target = get_target(args[0]);
if (target == NULL) {
@ -1868,7 +1868,7 @@ COMMAND_HANDLER(handle_reg_command)
target = get_current_target(cmd_ctx);
/* list all available registers for the current target */
if (argc == 0)
if (CMD_ARGC == 0)
{
struct reg_cache *cache = target->reg_cache;
@ -1948,9 +1948,9 @@ COMMAND_HANDLER(handle_reg_command)
}
/* display a register */
if ((argc == 1) || ((argc == 2) && !((args[1][0] >= '0') && (args[1][0] <= '9'))))
if ((CMD_ARGC == 1) || ((CMD_ARGC == 2) && !((args[1][0] >= '0') && (args[1][0] <= '9'))))
{
if ((argc == 2) && (strcmp(args[1], "force") == 0))
if ((CMD_ARGC == 2) && (strcmp(args[1], "force") == 0))
reg->valid = 0;
if (reg->valid == 0)
@ -1964,7 +1964,7 @@ COMMAND_HANDLER(handle_reg_command)
}
/* set register value */
if (argc == 2)
if (CMD_ARGC == 2)
{
uint8_t *buf = malloc(DIV_ROUND_UP(reg->size, 8));
str_to_buf(args[1], strlen(args[1]), buf, reg->size, 0);
@ -1990,7 +1990,7 @@ COMMAND_HANDLER(handle_poll_command)
int retval = ERROR_OK;
struct target *target = get_current_target(cmd_ctx);
if (argc == 0)
if (CMD_ARGC == 0)
{
command_print(cmd_ctx, "background polling: %s",
jtag_poll_get_enabled() ? "on" : "off");
@ -2005,7 +2005,7 @@ COMMAND_HANDLER(handle_poll_command)
return retval;
}
else if (argc == 1)
else if (CMD_ARGC == 1)
{
if (strcmp(args[0], "on") == 0)
{
@ -2029,11 +2029,11 @@ COMMAND_HANDLER(handle_poll_command)
COMMAND_HANDLER(handle_wait_halt_command)
{
if (argc > 1)
if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
unsigned ms = 5000;
if (1 == argc)
if (1 == CMD_ARGC)
{
int retval = parse_uint(args[0], &ms);
if (ERROR_OK != retval)
@ -2103,7 +2103,7 @@ COMMAND_HANDLER(handle_halt_command)
if (ERROR_OK != retval)
return retval;
if (argc == 1)
if (CMD_ARGC == 1)
{
unsigned wait;
retval = parse_uint(args[0], &wait);
@ -2129,11 +2129,11 @@ COMMAND_HANDLER(handle_soft_reset_halt_command)
COMMAND_HANDLER(handle_reset_command)
{
if (argc > 1)
if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
enum target_reset_mode reset_mode = RESET_RUN;
if (argc == 1)
if (CMD_ARGC == 1)
{
const Jim_Nvp *n;
n = Jim_Nvp_name2value_simple(nvp_reset_modes, args[0]);
@ -2151,7 +2151,7 @@ COMMAND_HANDLER(handle_reset_command)
COMMAND_HANDLER(handle_resume_command)
{
int current = 1;
if (argc > 1)
if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
struct target *target = get_current_target(cmd_ctx);
@ -2161,7 +2161,7 @@ COMMAND_HANDLER(handle_resume_command)
* with one arguments, addr = args[0],
* handle breakpoints, not debugging */
uint32_t addr = 0;
if (argc == 1)
if (CMD_ARGC == 1)
{
COMMAND_PARSE_NUMBER(u32, args[0], addr);
current = 0;
@ -2172,7 +2172,7 @@ COMMAND_HANDLER(handle_resume_command)
COMMAND_HANDLER(handle_step_command)
{
if (argc > 1)
if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
LOG_DEBUG("-");
@ -2182,7 +2182,7 @@ COMMAND_HANDLER(handle_step_command)
* handle breakpoints, debugging */
uint32_t addr = 0;
int current_pc = 1;
if (argc == 1)
if (CMD_ARGC == 1)
{
COMMAND_PARSE_NUMBER(u32, args[0], addr);
current_pc = 0;
@ -2244,7 +2244,7 @@ static void handle_md_output(struct command_context *cmd_ctx,
COMMAND_HANDLER(handle_md_command)
{
if (argc < 1)
if (CMD_ARGC < 1)
return ERROR_COMMAND_SYNTAX_ERROR;
unsigned size = 0;
@ -2261,14 +2261,14 @@ COMMAND_HANDLER(handle_md_command)
uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer);
if (physical)
{
argc--;
CMD_ARGC--;
args++;
fn=target_read_phys_memory;
} else
{
fn=target_read_memory;
}
if ((argc < 1) || (argc > 2))
if ((CMD_ARGC < 1) || (CMD_ARGC > 2))
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
@ -2277,7 +2277,7 @@ COMMAND_HANDLER(handle_md_command)
COMMAND_PARSE_NUMBER(u32, args[0], address);
unsigned count = 1;
if (argc == 2)
if (CMD_ARGC == 2)
COMMAND_PARSE_NUMBER(uint, args[1], count);
uint8_t *buffer = calloc(count, size);
@ -2294,7 +2294,7 @@ COMMAND_HANDLER(handle_md_command)
COMMAND_HANDLER(handle_mw_command)
{
if (argc < 2)
if (CMD_ARGC < 2)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
@ -2304,14 +2304,14 @@ COMMAND_HANDLER(handle_mw_command)
const char *cmd_name = CMD_NAME;
if (physical)
{
argc--;
CMD_ARGC--;
args++;
fn=target_write_phys_memory;
} else
{
fn=target_write_memory;
}
if ((argc < 2) || (argc > 3))
if ((CMD_ARGC < 2) || (CMD_ARGC > 3))
return ERROR_COMMAND_SYNTAX_ERROR;
uint32_t address;
@ -2321,7 +2321,7 @@ COMMAND_HANDLER(handle_mw_command)
COMMAND_PARSE_NUMBER(u32, args[1], value);
unsigned count = 1;
if (argc == 3)
if (CMD_ARGC == 3)
COMMAND_PARSE_NUMBER(uint, args[2], count);
struct target *target = get_current_target(cmd_ctx);
@ -2360,12 +2360,12 @@ COMMAND_HANDLER(handle_mw_command)
static COMMAND_HELPER(parse_load_image_command_args, struct image *image,
uint32_t *min_address, uint32_t *max_address)
{
if (argc < 1 || argc > 5)
if (CMD_ARGC < 1 || CMD_ARGC > 5)
return ERROR_COMMAND_SYNTAX_ERROR;
/* a base address isn't always necessary,
* default to 0x0 (i.e. don't relocate) */
if (argc >= 2)
if (CMD_ARGC >= 2)
{
uint32_t addr;
COMMAND_PARSE_NUMBER(u32, args[1], addr);
@ -2377,11 +2377,11 @@ static COMMAND_HELPER(parse_load_image_command_args, struct image *image,
image->start_address_set = 0;
if (argc >= 4)
if (CMD_ARGC >= 4)
{
COMMAND_PARSE_NUMBER(u32, args[3], *min_address);
}
if (argc == 5)
if (CMD_ARGC == 5)
{
COMMAND_PARSE_NUMBER(u32, args[4], *max_address);
// use size (given) to find max (required)
@ -2414,7 +2414,7 @@ COMMAND_HANDLER(handle_load_image_command)
struct duration bench;
duration_start(&bench);
if (image_open(&image, args[0], (argc >= 3) ? args[2] : NULL) != ERROR_OK)
if (image_open(&image, args[0], (CMD_ARGC >= 3) ? args[2] : NULL) != ERROR_OK)
{
return ERROR_OK;
}
@ -2495,7 +2495,7 @@ COMMAND_HANDLER(handle_dump_image_command)
struct target *target = get_current_target(cmd_ctx);
if (argc != 3)
if (CMD_ARGC != 3)
{
command_print(cmd_ctx, "usage: dump_image <filename> <address> <size>");
return ERROR_OK;
@ -2562,7 +2562,7 @@ static COMMAND_HELPER(handle_verify_image_command_internal, int verify)
struct target *target = get_current_target(cmd_ctx);
if (argc < 1)
if (CMD_ARGC < 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
@ -2576,7 +2576,7 @@ static COMMAND_HELPER(handle_verify_image_command_internal, int verify)
struct duration bench;
duration_start(&bench);
if (argc >= 2)
if (CMD_ARGC >= 2)
{
uint32_t addr;
COMMAND_PARSE_NUMBER(u32, args[1], addr);
@ -2591,7 +2591,7 @@ static COMMAND_HELPER(handle_verify_image_command_internal, int verify)
image.start_address_set = 0;
if ((retval = image_open(&image, args[0], (argc == 3) ? args[2] : NULL)) != ERROR_OK)
if ((retval = image_open(&image, args[0], (CMD_ARGC == 3) ? args[2] : NULL)) != ERROR_OK)
{
return retval;
}
@ -2745,10 +2745,10 @@ static int handle_bp_command_set(struct command_context *cmd_ctx,
COMMAND_HANDLER(handle_bp_command)
{
if (argc == 0)
if (CMD_ARGC == 0)
return handle_bp_command_list(cmd_ctx);
if (argc < 2 || argc > 3)
if (CMD_ARGC < 2 || CMD_ARGC > 3)
{
command_print(cmd_ctx, "usage: bp <address> <length> ['hw']");
return ERROR_COMMAND_SYNTAX_ERROR;
@ -2760,7 +2760,7 @@ COMMAND_HANDLER(handle_bp_command)
COMMAND_PARSE_NUMBER(u32, args[1], length);
int hw = BKPT_SOFT;
if (argc == 3)
if (CMD_ARGC == 3)
{
if (strcmp(args[2], "hw") == 0)
hw = BKPT_HARD;
@ -2773,7 +2773,7 @@ COMMAND_HANDLER(handle_bp_command)
COMMAND_HANDLER(handle_rbp_command)
{
if (argc != 1)
if (CMD_ARGC != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
uint32_t addr;
@ -2789,7 +2789,7 @@ COMMAND_HANDLER(handle_wp_command)
{
struct target *target = get_current_target(cmd_ctx);
if (argc == 0)
if (CMD_ARGC == 0)
{
struct watchpoint *watchpoint = target->watchpoints;
@ -2815,7 +2815,7 @@ COMMAND_HANDLER(handle_wp_command)
uint32_t data_value = 0x0;
uint32_t data_mask = 0xffffffff;
switch (argc)
switch (CMD_ARGC)
{
case 5:
COMMAND_PARSE_NUMBER(u32, args[4], data_mask);
@ -2861,7 +2861,7 @@ COMMAND_HANDLER(handle_wp_command)
COMMAND_HANDLER(handle_rwp_command)
{
if (argc != 1)
if (CMD_ARGC != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
uint32_t addr;
@ -2882,7 +2882,7 @@ COMMAND_HANDLER(handle_rwp_command)
*/
COMMAND_HANDLER(handle_virt2phys_command)
{
if (argc != 1)
if (CMD_ARGC != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
uint32_t va;
@ -3020,7 +3020,7 @@ COMMAND_HANDLER(handle_profile_command)
struct timeval timeout, now;
gettimeofday(&timeout, NULL);
if (argc != 2)
if (CMD_ARGC != 2)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
@ -4551,7 +4551,7 @@ COMMAND_HANDLER(handle_fast_load_image_command)
struct duration bench;
duration_start(&bench);
if (image_open(&image, args[0], (argc >= 3) ? args[2] : NULL) != ERROR_OK)
if (image_open(&image, args[0], (CMD_ARGC >= 3) ? args[2] : NULL) != ERROR_OK)
{
return ERROR_OK;
}
@ -4645,7 +4645,7 @@ COMMAND_HANDLER(handle_fast_load_image_command)
COMMAND_HANDLER(handle_fast_load_command)
{
if (argc > 0)
if (CMD_ARGC > 0)
return ERROR_COMMAND_SYNTAX_ERROR;
if (fastload == NULL)
{

View File

@ -268,7 +268,7 @@ COMMAND_HANDLER(handle_target_request_debugmsgs_command)
if (find_debug_msg_receiver(cmd_ctx, target) != NULL)
receiving = 1;
if (argc > 0)
if (CMD_ARGC > 0)
{
if (!strcmp(args[0], "enable") || !strcmp(args[0], "charmsg"))
{

View File

@ -52,7 +52,7 @@ COMMAND_HANDLER(handle_trace_point_command)
struct target *target = get_current_target(cmd_ctx);
struct trace *trace = target->trace_info;
if (argc == 0)
if (CMD_ARGC == 0)
{
uint32_t i;
@ -100,7 +100,7 @@ COMMAND_HANDLER(handle_trace_history_command)
struct target *target = get_current_target(cmd_ctx);
struct trace *trace = target->trace_info;
if (argc > 0)
if (CMD_ARGC > 0)
{
trace->trace_history_pos = 0;
trace->trace_history_overflowed = 0;

View File

@ -2995,7 +2995,7 @@ COMMAND_HANDLER(xscale_handle_debug_handler_command)
int retval;
uint32_t handler_address;
if (argc < 2)
if (CMD_ARGC < 2)
{
LOG_ERROR("'xscale debug_handler <target#> <address>' command takes two required operands");
return ERROR_OK;
@ -3035,7 +3035,7 @@ COMMAND_HANDLER(xscale_handle_cache_clean_address_command)
int retval;
uint32_t cache_clean_address;
if (argc < 2)
if (CMD_ARGC < 2)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
@ -3130,7 +3130,7 @@ COMMAND_HANDLER(xscale_handle_mmu_command)
return ERROR_OK;
}
if (argc >= 1)
if (CMD_ARGC >= 1)
{
if (strcmp("enable", args[0]) == 0)
{
@ -3171,7 +3171,7 @@ COMMAND_HANDLER(xscale_handle_idcache_command)
else if (strcmp(CMD_NAME, "dcache") == 0)
dcache = 1;
if (argc >= 1)
if (CMD_ARGC >= 1)
{
if (strcmp("enable", args[0]) == 0)
{
@ -3212,7 +3212,7 @@ COMMAND_HANDLER(xscale_handle_vector_catch_command)
if (retval != ERROR_OK)
return retval;
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "usage: xscale vector_catch [mask]");
}
@ -3240,7 +3240,7 @@ COMMAND_HANDLER(xscale_handle_vector_table_command)
if (retval != ERROR_OK)
return retval;
if (argc == 0) /* print current settings */
if (CMD_ARGC == 0) /* print current settings */
{
int idx;
@ -3254,7 +3254,7 @@ COMMAND_HANDLER(xscale_handle_vector_table_command)
return ERROR_OK;
}
if (argc != 3)
if (CMD_ARGC != 3)
err = 1;
else
{
@ -3305,7 +3305,7 @@ COMMAND_HANDLER(xscale_handle_trace_buffer_command)
return ERROR_OK;
}
if ((argc >= 1) && (strcmp("enable", args[0]) == 0))
if ((CMD_ARGC >= 1) && (strcmp("enable", args[0]) == 0))
{
struct xscale_trace_data *td, *next_td;
xscale->trace.buffer_enabled = 1;
@ -3323,19 +3323,19 @@ COMMAND_HANDLER(xscale_handle_trace_buffer_command)
}
xscale->trace.data = NULL;
}
else if ((argc >= 1) && (strcmp("disable", args[0]) == 0))
else if ((CMD_ARGC >= 1) && (strcmp("disable", args[0]) == 0))
{
xscale->trace.buffer_enabled = 0;
}
if ((argc >= 2) && (strcmp("fill", args[1]) == 0))
if ((CMD_ARGC >= 2) && (strcmp("fill", args[1]) == 0))
{
uint32_t fill = 1;
if (argc >= 3)
if (CMD_ARGC >= 3)
COMMAND_PARSE_NUMBER(u32, args[2], fill);
xscale->trace.buffer_fill = fill;
}
else if ((argc >= 2) && (strcmp("wrap", args[1]) == 0))
else if ((CMD_ARGC >= 2) && (strcmp("wrap", args[1]) == 0))
{
xscale->trace.buffer_fill = -1;
}
@ -3372,7 +3372,7 @@ COMMAND_HANDLER(xscale_handle_trace_image_command)
struct xscale_common *xscale = target_to_xscale(target);
int retval;
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "usage: xscale trace_image <file> [base address] [type]");
return ERROR_OK;
@ -3394,7 +3394,7 @@ COMMAND_HANDLER(xscale_handle_trace_image_command)
xscale->trace.image->start_address_set = 0;
/* a base address isn't always necessary, default to 0x0 (i.e. don't relocate) */
if (argc >= 2)
if (CMD_ARGC >= 2)
{
xscale->trace.image->base_address_set = 1;
COMMAND_PARSE_NUMBER(int, args[1], xscale->trace.image->base_address);
@ -3404,7 +3404,7 @@ COMMAND_HANDLER(xscale_handle_trace_image_command)
xscale->trace.image->base_address_set = 0;
}
if (image_open(xscale->trace.image, args[0], (argc >= 3) ? args[2] : NULL) != ERROR_OK)
if (image_open(xscale->trace.image, args[0], (CMD_ARGC >= 3) ? args[2] : NULL) != ERROR_OK)
{
free(xscale->trace.image);
xscale->trace.image = NULL;
@ -3432,7 +3432,7 @@ COMMAND_HANDLER(xscale_handle_dump_trace_command)
return ERROR_OK;
}
if (argc < 1)
if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "usage: xscale dump_trace <file>");
return ERROR_OK;
@ -3503,7 +3503,7 @@ COMMAND_HANDLER(xscale_handle_cp15)
}
uint32_t reg_no = 0;
struct reg *reg = NULL;
if (argc > 0)
if (CMD_ARGC > 0)
{
COMMAND_PARSE_NUMBER(u32, args[0], reg_no);
/*translate from xscale cp15 register no to openocd register*/
@ -3540,7 +3540,7 @@ COMMAND_HANDLER(xscale_handle_cp15)
reg = &xscale->reg_cache->reg_list[reg_no];
}
if (argc == 1)
if (CMD_ARGC == 1)
{
uint32_t value;
@ -3549,7 +3549,7 @@ COMMAND_HANDLER(xscale_handle_cp15)
value = buf_get_u32(reg->value, 0, 32);
command_print(cmd_ctx, "%s (/%i): 0x%" PRIx32 "", reg->name, (int)(reg->size), value);
}
else if (argc == 2)
else if (CMD_ARGC == 2)
{
uint32_t value;
COMMAND_PARSE_NUMBER(u32, args[1], value);

View File

@ -219,7 +219,7 @@ COMMAND_HANDLER(handle_xsvf_command)
*/
struct jtag_tap *tap = NULL;
if (argc < 2)
if (CMD_ARGC < 2)
{
command_print(cmd_ctx, "usage: xsvf <device#|plain> <file> [<variant>] [quiet]");
return ERROR_FAIL;
@ -245,14 +245,14 @@ COMMAND_HANDLER(handle_xsvf_command)
}
/* if this argument is present, then interpret xruntest counts as TCK cycles rather than as usecs */
if ((argc > 2) && (strcmp(args[2], "virt2") == 0))
if ((CMD_ARGC > 2) && (strcmp(args[2], "virt2") == 0))
{
runtest_requires_tck = 1;
--argc;
--CMD_ARGC;
++args;
}
if ((argc > 2) && (strcmp(args[2], "quiet") == 0))
if ((CMD_ARGC > 2) && (strcmp(args[2], "quiet") == 0))
{
verbose = 0;
}