OpenOCD: drop comparison with true/false

Fix checkpatch errors:

	ERROR:BOOL_COMPARISON: Using comparison to true/false is
	error prone

While there,
- drop useless parenthesis,
- drop unnecessary else after a return.

Change-Id: I1234737b3e65bd10df5e938d1c36f9abaf02d348
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8496
Reviewed-by: zapb <dev@zapb.de>
Tested-by: jenkins
This commit is contained in:
Antonio Borneo 2024-09-16 11:55:20 +02:00
parent 66006d83b9
commit 3ccf68cd0a
9 changed files with 44 additions and 46 deletions

View File

@ -487,7 +487,7 @@ static int psoc6_get_info(struct flash_bank *bank, struct command_invocation *cm
{
struct psoc6_target_info *psoc6_info = bank->driver_priv;
if (psoc6_info->is_probed == false)
if (!psoc6_info->is_probed)
return ERROR_FAIL;
int hr = get_silicon_id(bank->target, &psoc6_info->silicon_id, &psoc6_info->protection);

View File

@ -143,28 +143,27 @@ static int isc_enter(struct flash_bank *bank)
struct xcf_status status = read_status(bank);
if (true == status.isc_mode)
if (status.isc_mode)
return ERROR_OK;
else {
struct scan_field scan;
scan.check_mask = NULL;
scan.check_value = NULL;
scan.num_bits = 16;
scan.out_value = cmd_isc_enable;
scan.in_value = NULL;
struct scan_field scan;
jtag_add_ir_scan(bank->target->tap, &scan, TAP_IDLE);
jtag_execute_queue();
scan.check_mask = NULL;
scan.check_value = NULL;
scan.num_bits = 16;
scan.out_value = cmd_isc_enable;
scan.in_value = NULL;
status = read_status(bank);
if (!status.isc_mode) {
LOG_ERROR("*** XCF: FAILED to enter ISC mode");
return ERROR_FLASH_OPERATION_FAILED;
}
jtag_add_ir_scan(bank->target->tap, &scan, TAP_IDLE);
jtag_execute_queue();
return ERROR_OK;
status = read_status(bank);
if (!status.isc_mode) {
LOG_ERROR("*** XCF: FAILED to enter ISC mode");
return ERROR_FLASH_OPERATION_FAILED;
}
return ERROR_OK;
}
static int isc_leave(struct flash_bank *bank)
@ -174,27 +173,26 @@ static int isc_leave(struct flash_bank *bank)
if (!status.isc_mode)
return ERROR_OK;
else {
struct scan_field scan;
scan.check_mask = NULL;
scan.check_value = NULL;
scan.num_bits = 16;
scan.out_value = cmd_isc_disable;
scan.in_value = NULL;
struct scan_field scan;
jtag_add_ir_scan(bank->target->tap, &scan, TAP_IDLE);
jtag_execute_queue();
alive_sleep(1); /* device needs 50 uS to leave ISC mode */
scan.check_mask = NULL;
scan.check_value = NULL;
scan.num_bits = 16;
scan.out_value = cmd_isc_disable;
scan.in_value = NULL;
status = read_status(bank);
if (status.isc_mode) {
LOG_ERROR("*** XCF: FAILED to leave ISC mode");
return ERROR_FLASH_OPERATION_FAILED;
}
jtag_add_ir_scan(bank->target->tap, &scan, TAP_IDLE);
jtag_execute_queue();
alive_sleep(1); /* device needs 50 uS to leave ISC mode */
return ERROR_OK;
status = read_status(bank);
if (status.isc_mode) {
LOG_ERROR("*** XCF: FAILED to leave ISC mode");
return ERROR_FLASH_OPERATION_FAILED;
}
return ERROR_OK;
}
static int sector_state(uint8_t wrpt, int sector)

View File

@ -606,7 +606,7 @@ static void ulink_clear_queue(struct ulink *device)
/* IN payload MUST be freed ONLY if no other commands use the
* payload_in_start buffer */
if (current->free_payload_in_start == true) {
if (current->free_payload_in_start) {
free(current->payload_in_start);
current->payload_in_start = NULL;
current->payload_in = NULL;
@ -1861,7 +1861,7 @@ static int ulink_post_process_queue(struct ulink *device)
/* Check if a corresponding OpenOCD command is stored for this
* OpenULINK command */
if ((current->needs_postprocessing == true) && (openocd_cmd)) {
if (current->needs_postprocessing && openocd_cmd) {
switch (openocd_cmd->type) {
case JTAG_SCAN:
ret = ulink_post_process_scan(current);
@ -2131,7 +2131,7 @@ static int ulink_init(void)
download_firmware = true;
}
if (download_firmware == true) {
if (download_firmware) {
LOG_INFO("Loading OpenULINK firmware. This is reversible by power-cycling"
" ULINK device.");
ret = ulink_load_firmware_and_renumerate(&ulink_handle,

View File

@ -215,7 +215,7 @@ static int ublast2_libusb_init(struct ublast_lowlevel *low)
const uint16_t vids_renum[] = { low->ublast_vid, 0 };
const uint16_t pids_renum[] = { low->ublast_pid, 0 };
if (renumeration == false) {
if (!renumeration) {
if (jtag_libusb_open(vids_renum, pids_renum, NULL, &low->libusb_dev, NULL) != ERROR_OK) {
LOG_ERROR("Altera USB-Blaster II not found");
return ERROR_FAIL;

View File

@ -254,7 +254,7 @@ static int hwthread_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
int j = 0;
for (int i = 0; i < reg_list_size; i++) {
if (!reg_list[i] || reg_list[i]->exist == false || reg_list[i]->hidden)
if (!reg_list[i] || !reg_list[i]->exist || reg_list[i]->hidden)
continue;
j++;
}
@ -267,7 +267,7 @@ static int hwthread_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
j = 0;
for (int i = 0; i < reg_list_size; i++) {
if (!reg_list[i] || reg_list[i]->exist == false || reg_list[i]->hidden)
if (!reg_list[i] || !reg_list[i]->exist || reg_list[i]->hidden)
continue;
if (!reg_list[i]->valid) {
retval = reg_list[i]->type->get(reg_list[i]);

View File

@ -389,7 +389,7 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa
return ERROR_OK;
} else if (strncmp(packet, "qSymbol", 7) == 0) {
if (rtos_qsymbol(connection, packet, packet_size) == 1) {
if (target->rtos_auto_detect == true) {
if (target->rtos_auto_detect) {
target->rtos_auto_detect = false;
target->rtos->type->create(target);
}

View File

@ -1262,7 +1262,7 @@ static int gdb_get_registers_packet(struct connection *connection,
return gdb_error(connection, retval);
for (i = 0; i < reg_list_size; i++) {
if (!reg_list[i] || reg_list[i]->exist == false || reg_list[i]->hidden)
if (!reg_list[i] || !reg_list[i]->exist || reg_list[i]->hidden)
continue;
reg_packet_size += DIV_ROUND_UP(reg_list[i]->size, 8) * 2;
}
@ -1276,7 +1276,7 @@ static int gdb_get_registers_packet(struct connection *connection,
reg_packet_p = reg_packet;
for (i = 0; i < reg_list_size; i++) {
if (!reg_list[i] || reg_list[i]->exist == false || reg_list[i]->hidden)
if (!reg_list[i] || !reg_list[i]->exist || reg_list[i]->hidden)
continue;
retval = gdb_get_reg_value_as_str(target, reg_packet_p, reg_list[i]);
if (retval != ERROR_OK && gdb_report_register_access_error) {
@ -2254,7 +2254,7 @@ static int get_reg_features_list(struct target *target, char const **feature_lis
*feature_list = calloc(1, sizeof(char *));
for (int i = 0; i < reg_list_size; i++) {
if (reg_list[i]->exist == false || reg_list[i]->hidden)
if (!reg_list[i]->exist || reg_list[i]->hidden)
continue;
if (reg_list[i]->feature
@ -2464,7 +2464,7 @@ static int gdb_generate_target_description(struct target *target, char **tdesc_o
int i;
for (i = 0; i < reg_list_size; i++) {
if (reg_list[i]->exist == false || reg_list[i]->hidden)
if (!reg_list[i]->exist || reg_list[i]->hidden)
continue;
if (strcmp(reg_list[i]->feature->name, features[current_feature]))

View File

@ -1521,7 +1521,7 @@ static int cortex_m_step(struct target *target, int current,
/* if no bkpt instruction is found at pc then we can perform
* a normal step, otherwise we have to manually step over the bkpt
* instruction - as such simulate a step */
if (bkpt_inst_found == false) {
if (!bkpt_inst_found) {
if (cortex_m->isrmasking_mode != CORTEX_M_ISRMASK_AUTO) {
/* Automatic ISR masking mode off: Just step over the next
* instruction, with interrupts on or off as appropriate. */

View File

@ -3042,7 +3042,7 @@ COMMAND_HANDLER(handle_reg_command)
for (i = 0, reg = cache->reg_list;
i < cache->num_regs;
i++, reg++, count++) {
if (reg->exist == false || reg->hidden)
if (!reg->exist || reg->hidden)
continue;
/* only print cached values if they are valid */
if (reg->valid) {