openocd: remove NULL comparisons with checkpatch [1/2]
Patch generated automatically through the new checkpatch with flags "--types COMPARISON_TO_NULL --fix-inplace". This only fixes the comparisons if (symbol == NULL) if (symbol != NULL) The case of NULL on the left side of the comparison is not tested. Some automatic fix is incorrect and has been massaged by hands: - if (*psig == NULL) + if (*!psig) changed as + if (!*psig) Change-Id: If4a1e2b4e547e223532e8e3d9da89bf9cb382ce6 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6351 Tested-by: jenkins
This commit is contained in:
@@ -3545,7 +3545,7 @@ COMMAND_HANDLER(sam3_handle_info_command)
|
||||
int r;
|
||||
|
||||
/* bank0 must exist before we can do anything */
|
||||
if (chip->details.bank[0].bank == NULL) {
|
||||
if (!chip->details.bank[0].bank) {
|
||||
x = 0;
|
||||
need_define:
|
||||
command_print(CMD,
|
||||
@@ -3571,7 +3571,7 @@ need_define:
|
||||
if (!(chip->details.bank[x].present))
|
||||
continue;
|
||||
|
||||
if (chip->details.bank[x].bank == NULL)
|
||||
if (!chip->details.bank[x].bank)
|
||||
goto need_define;
|
||||
|
||||
if (chip->details.bank[x].probed)
|
||||
@@ -3606,7 +3606,7 @@ COMMAND_HANDLER(sam3_handle_gpnvm_command)
|
||||
return ERROR_TARGET_NOT_HALTED;
|
||||
}
|
||||
|
||||
if (chip->details.bank[0].bank == NULL) {
|
||||
if (!chip->details.bank[0].bank) {
|
||||
command_print(CMD, "Bank0 must be defined first via: flash bank %s ...",
|
||||
at91sam3_flash.name);
|
||||
return ERROR_FAIL;
|
||||
|
||||
@@ -3092,7 +3092,7 @@ COMMAND_HANDLER(sam4_handle_info_command)
|
||||
int r;
|
||||
|
||||
/* bank0 must exist before we can do anything */
|
||||
if (chip->details.bank[0].bank == NULL) {
|
||||
if (!chip->details.bank[0].bank) {
|
||||
x = 0;
|
||||
need_define:
|
||||
command_print(CMD,
|
||||
@@ -3118,7 +3118,7 @@ need_define:
|
||||
if (!(chip->details.bank[x].present))
|
||||
continue;
|
||||
|
||||
if (chip->details.bank[x].bank == NULL)
|
||||
if (!chip->details.bank[x].bank)
|
||||
goto need_define;
|
||||
|
||||
if (chip->details.bank[x].probed)
|
||||
@@ -3153,7 +3153,7 @@ COMMAND_HANDLER(sam4_handle_gpnvm_command)
|
||||
return ERROR_TARGET_NOT_HALTED;
|
||||
}
|
||||
|
||||
if (chip->details.bank[0].bank == NULL) {
|
||||
if (!chip->details.bank[0].bank) {
|
||||
command_print(CMD, "Bank0 must be defined first via: flash bank %s ...",
|
||||
at91sam4_flash.name);
|
||||
return ERROR_FAIL;
|
||||
|
||||
@@ -1040,7 +1040,7 @@ COMMAND_HANDLER(at91sam7_handle_gpnvm_command)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
|
||||
bank = get_flash_bank_by_num_noprobe(0);
|
||||
if (bank == NULL)
|
||||
if (!bank)
|
||||
return ERROR_FLASH_BANK_INVALID;
|
||||
if (strcmp(bank->driver->name, "at91sam7")) {
|
||||
command_print(CMD, "not an at91sam7 flash bank '%s'", CMD_ARGV[0]);
|
||||
|
||||
@@ -1064,7 +1064,7 @@ static COMMAND_HELPER(get_u64_from_hexarg, unsigned int num, uint64_t *value)
|
||||
char *check = NULL;
|
||||
*value = strtoull(&(CMD_ARGV[num][2]), &check, 16);
|
||||
if ((value == 0 && errno == ERANGE) ||
|
||||
check == NULL || *check != 0) {
|
||||
!check || *check != 0) {
|
||||
command_print(CMD, "Invalid 64-bit hex value in argument %d.",
|
||||
num + 1);
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
|
||||
@@ -70,7 +70,7 @@ int flash_driver_protect(struct flash_bank *bank, int set, unsigned int first,
|
||||
/* force "set" to 0/1 */
|
||||
set = !!set;
|
||||
|
||||
if (bank->driver->protect == NULL) {
|
||||
if (!bank->driver->protect) {
|
||||
LOG_ERROR("Flash protection is not supported.");
|
||||
return ERROR_FLASH_OPER_UNSUPPORTED;
|
||||
}
|
||||
@@ -491,7 +491,7 @@ static int flash_iterate_address_range_inner(struct target *target,
|
||||
return ERROR_FLASH_DST_BREAKS_ALIGNMENT;
|
||||
}
|
||||
|
||||
if (c->prot_blocks == NULL || c->num_prot_blocks == 0) {
|
||||
if (!c->prot_blocks || c->num_prot_blocks == 0) {
|
||||
/* flash driver does not define protect blocks, use sectors instead */
|
||||
iterate_protect_blocks = false;
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ static int jtagspi_probe(struct flash_bank *bank)
|
||||
free(bank->sectors);
|
||||
info->probed = false;
|
||||
|
||||
if (bank->target->tap == NULL) {
|
||||
if (!bank->target->tap) {
|
||||
LOG_ERROR("Target has no JTAG tap");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
@@ -714,7 +714,7 @@ static int pic32mx_probe(struct flash_bank *bank)
|
||||
}
|
||||
|
||||
/* Check for PIC32mx1xx/2xx */
|
||||
for (i = 0; pic32mx_devs[i].name != NULL; i++) {
|
||||
for (i = 0; pic32mx_devs[i].name; i++) {
|
||||
if (pic32mx_devs[i].devid == (device_id & 0x0fffffff)) {
|
||||
if ((pic32mx_devs[i].name[0] == '1') || (pic32mx_devs[i].name[0] == '2'))
|
||||
pic32mx_info->dev_type = (pic32mx_devs[i].name[1] == '7') ? MX_17X_27X : MX_1XX_2XX;
|
||||
@@ -819,14 +819,14 @@ static int pic32mx_info(struct flash_bank *bank, struct command_invocation *cmd)
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = 0; pic32mx_devs[i].name != NULL; i++) {
|
||||
for (i = 0; pic32mx_devs[i].name; i++) {
|
||||
if (pic32mx_devs[i].devid == (device_id & 0x0fffffff)) {
|
||||
command_print_sameline(cmd, "PIC32MX%s", pic32mx_devs[i].name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pic32mx_devs[i].name == NULL)
|
||||
if (!pic32mx_devs[i].name)
|
||||
command_print_sameline(cmd, "Unknown");
|
||||
|
||||
command_print_sameline(cmd, " Ver: 0x%02x",
|
||||
|
||||
+2
-2
@@ -99,7 +99,7 @@ COMMAND_HANDLER(handle_flash_info_command)
|
||||
|
||||
/* If the driver does not implement protection, we show the default
|
||||
* state of is_protected array - usually protection state unknown */
|
||||
if (p->driver->protect_check == NULL) {
|
||||
if (!p->driver->protect_check) {
|
||||
retval = ERROR_FLASH_OPER_UNSUPPORTED;
|
||||
} else {
|
||||
/* We must query the hardware to avoid printing stale information! */
|
||||
@@ -148,7 +148,7 @@ COMMAND_HANDLER(handle_flash_info_command)
|
||||
protect_state);
|
||||
}
|
||||
|
||||
if (p->driver->info != NULL) {
|
||||
if (p->driver->info) {
|
||||
/* Let the flash driver print extra custom info */
|
||||
retval = p->driver->info(p, CMD);
|
||||
command_print_sameline(CMD, "\n");
|
||||
|
||||
@@ -93,7 +93,7 @@ static int virtual_protect_check(struct flash_bank *bank)
|
||||
if (!master_bank)
|
||||
return ERROR_FLASH_OPERATION_FAILED;
|
||||
|
||||
if (master_bank->driver->protect_check == NULL)
|
||||
if (!master_bank->driver->protect_check)
|
||||
return ERROR_FLASH_OPER_UNSUPPORTED;
|
||||
|
||||
/* call master handler */
|
||||
|
||||
+1
-1
@@ -602,7 +602,7 @@ static int xcf_probe(struct flash_bank *bank)
|
||||
free(bank->sectors);
|
||||
priv->probed = false;
|
||||
|
||||
if (bank->target->tap == NULL) {
|
||||
if (!bank->target->tap) {
|
||||
LOG_ERROR("Target has no JTAG tap");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user