Skip to content

Commit

Permalink
OpenOCD: drop comparison with true/false
Browse files Browse the repository at this point in the history
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
  • Loading branch information
borneoa committed Oct 5, 2024
1 parent 66006d8 commit 3ccf68c
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 49 deletions.
2 changes: 1 addition & 1 deletion src/flash/nor/psoc6.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
68 changes: 33 additions & 35 deletions src/flash/nor/xcf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;

jtag_add_ir_scan(bank->target->tap, &scan, TAP_IDLE);
jtag_execute_queue();
alive_sleep(1); /* device needs 50 uS to leave ISC mode */

status = read_status(bank);
if (status.isc_mode) {
LOG_ERROR("*** XCF: FAILED to leave ISC mode");
return ERROR_FLASH_OPERATION_FAILED;
}

return ERROR_OK;
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;

jtag_add_ir_scan(bank->target->tap, &scan, TAP_IDLE);
jtag_execute_queue();
alive_sleep(1); /* device needs 50 uS to leave ISC mode */

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)
Expand Down
6 changes: 3 additions & 3 deletions src/jtag/drivers/ulink.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/jtag/drivers/usb_blaster/ublast2_access_libusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/rtos/hwthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand All @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion src/rtos/rtos.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions src/server/gdb_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]))
Expand Down
2 changes: 1 addition & 1 deletion src/target/cortex_m.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
2 changes: 1 addition & 1 deletion src/target/target.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 3ccf68c

Please sign in to comment.