]> www.infradead.org Git - users/borneoa/openocd-next.git/commitdiff
OpenOCD: drop comparison with true/false
authorAntonio Borneo <borneo.antonio@gmail.com>
Mon, 16 Sep 2024 09:55:20 +0000 (11:55 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 5 Oct 2024 15:49:04 +0000 (15:49 +0000)
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
src/flash/nor/psoc6.c
src/flash/nor/xcf.c
src/jtag/drivers/ulink.c
src/jtag/drivers/usb_blaster/ublast2_access_libusb.c
src/rtos/hwthread.c
src/rtos/rtos.c
src/server/gdb_server.c
src/target/cortex_m.c
src/target/target.c

index 47f3ac69803943560d7bea7eb686030097264304..662910aa046bdf5a5471ee93d529b0bf7b7eeba9 100644 (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);
index 1d67b09430b2e2ac2e6f0534b3a461837e338b3e..4011fa42be8cc7f28d0b34585b19e881f28b69cf 100644 (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;
-
-               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)
index ad3bc6e37e72301db2ef0c677f7e7c4d3ce65e9c..3a248e388fb0eeb025117d3ac275070ec1470f31 100644 (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,
index e790f3ae53e8e4db9b4d80c32b99d3836261f650..8f0ed96f342a9ba505494dcb41013955dffa8af6 100644 (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;
index 65b89eb2237bda0307781c10acac653ad6152143..1890a3d87a31a49ddb6c8125739867ad0b91a34e 100644 (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]);
index 0df1182c0a98cd468b5538447f70c2eaf77906b8..54e31e4268389b3150ff7afa670fa23bb61e110b 100644 (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);
                        }
index 854c4dc65d724d26280ac468b824b04f9449fff5..c1e5e268fb979c75a51e8c81ddc1de7416f49607 100644 (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]))
index 880a83a18c716cfc0f85c3ca7ab80a2269cd2d8b..bd0e8d88673f9c861ba62ad6c8021daf5b0e359e 100644 (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. */
index 2be8b24b9275a03493ca34276e2072ed21377424..49611dfb45800a023bd88e8e8573308ef2fa3023 100644 (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) {