openocd: remove NULL comparisons with checkpatch [1/2]
authorAntonio Borneo <borneo.antonio@gmail.com>
Sat, 3 Jul 2021 19:29:32 +0000 (21:29 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 24 Jul 2021 09:38:00 +0000 (10:38 +0100)
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
71 files changed:
src/flash/nand/core.c
src/flash/nor/at91sam3.c
src/flash/nor/at91sam4.c
src/flash/nor/at91sam7.c
src/flash/nor/at91samd.c
src/flash/nor/core.c
src/flash/nor/jtagspi.c
src/flash/nor/pic32mx.c
src/flash/nor/tcl.c
src/flash/nor/virtual.c
src/flash/nor/xcf.c
src/helper/command.c
src/helper/log.c
src/helper/replacements.c
src/jtag/core.c
src/jtag/drivers/at91rm9200.c
src/jtag/drivers/cmsis_dap.c
src/jtag/drivers/driver.c
src/jtag/drivers/ftdi.c
src/jtag/drivers/jtag_dpi.c
src/jtag/drivers/jtag_vpi.c
src/jtag/drivers/libusb_helper.c
src/jtag/drivers/remote_bitbang.c
src/jtag/drivers/rlink.c
src/jtag/drivers/stlink_usb.c
src/jtag/drivers/usb_blaster/usb_blaster.c
src/jtag/drivers/versaloon/usbtoxxx/usbtoxxx.c
src/jtag/hla/hla_interface.c
src/jtag/tcl.c
src/rtos/FreeRTOS.c
src/rtos/ThreadX.c
src/rtos/chibios.c
src/rtos/eCos.c
src/rtos/embKernel.c
src/rtos/hwthread.c
src/rtos/linux.c
src/rtos/mqx.c
src/rtos/nuttx.c
src/rtos/riot.c
src/rtos/rtos.c
src/rtos/uCOS-III.c
src/rtos/zephyr.c
src/server/gdb_server.c
src/server/tcl_server.c
src/server/telnet_server.c
src/svf/svf.c
src/target/aarch64.c
src/target/arc.c
src/target/arm_adi_v5.c
src/target/arm_adi_v5.h
src/target/armv7a.c
src/target/armv7m.c
src/target/armv8.c
src/target/armv8_cache.c
src/target/cortex_a.c
src/target/esirisc.c
src/target/esirisc_jtag.c
src/target/etm.c
src/target/hla_target.c
src/target/lakemont.c
src/target/ls1_sap.c
src/target/mem_ap.c
src/target/mips_m4k.c
src/target/nds32_aice.c
src/target/riscv/riscv-013.c
src/target/riscv/riscv.c
src/target/semihosting_common.c
src/target/target.c
src/target/target_request.c
src/target/x86_32_common.c
src/transport/transport.c

index 8e2af2338193a9f931ba11b5ae3907388027c432..d60e0d071f79c95ab762cae5464d3974a0ccaadc 100644 (file)
@@ -682,7 +682,7 @@ int nand_write_page(struct nand_device *nand, uint32_t page,
        if (nand->blocks[block].is_erased == 1)
                nand->blocks[block].is_erased = 0;
 
-       if (nand->use_raw || nand->controller->write_page == NULL)
+       if (nand->use_raw || !nand->controller->write_page)
                return nand_write_page_raw(nand, page, data, data_size, oob, oob_size);
        else
                return nand->controller->write_page(nand, page, data, data_size, oob, oob_size);
@@ -695,7 +695,7 @@ int nand_read_page(struct nand_device *nand, uint32_t page,
        if (!nand->device)
                return ERROR_NAND_DEVICE_NOT_PROBED;
 
-       if (nand->use_raw || nand->controller->read_page == NULL)
+       if (nand->use_raw || !nand->controller->read_page)
                return nand_read_page_raw(nand, page, data, data_size, oob, oob_size);
        else
                return nand->controller->read_page(nand, page, data, data_size, oob, oob_size);
@@ -769,7 +769,7 @@ int nand_read_data_page(struct nand_device *nand, uint8_t *data, uint32_t size)
 {
        int retval = ERROR_NAND_NO_BUFFER;
 
-       if (nand->controller->read_block_data != NULL)
+       if (nand->controller->read_block_data)
                retval = (nand->controller->read_block_data)(nand, data, size);
 
        if (retval == ERROR_NAND_NO_BUFFER) {
@@ -809,7 +809,7 @@ int nand_write_data_page(struct nand_device *nand, uint8_t *data, uint32_t size)
 {
        int retval = ERROR_NAND_NO_BUFFER;
 
-       if (nand->controller->write_block_data != NULL)
+       if (nand->controller->write_block_data)
                retval = (nand->controller->write_block_data)(nand, data, size);
 
        if (retval == ERROR_NAND_NO_BUFFER) {
index 3f36af211623b19521a83e01d634659d31333a38..cec86fc24181a81b133f092c0edc69769ca66608 100644 (file)
@@ -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;
index 23d1c5f30f9f4bc57a613c8d64e72dc637a63fc1..4ec2ee89ecec7393f698885f59507a8493ffda63 100644 (file)
@@ -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;
index d3eadc786bbb042fd99f6ad9baa526498c73956c..f98d186fb4068b502994cb38d1da2dc87ec491b8 100644 (file)
@@ -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]);
index ea8503967b68cb4697086d3d1ef580dcb0a16778..76c08d7b55e95ac1da78b36844d2a5e0ef309368 100644 (file)
@@ -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;
index 41d2d34ef43d86ac7788619f6d03a69f5f49dd96..a2d7623d04644c120f214cecbe36a4f323c6b425 100644 (file)
@@ -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;
        }
index fade970afbc37c648a10772f6f2c964dc8b1298a..dc49fda6153ddf31e2b97c820cc58d5c42e48c7d 100644 (file)
@@ -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;
        }
index 5e6c99f13580081d64f990e4fe31cf9925c3a9c5..a1f2cdf4ec3e8d8991dae7f9ad2e860d6368ea3e 100644 (file)
@@ -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",
index d7466501782d5311066e451dd6e2f0189af804d8..b078e9095ce83673de87c71b3d713ba3ade3c013 100644 (file)
@@ -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");
index deab3c089554796c12dd67f067c0966dbfd506ee..01a92478fc7299d2b55fd47fb67c6fc1699e2190 100644 (file)
@@ -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 */
index fd31c9d145a9d32c699ad1847cf72da7e0e90c84..c6de1aca11d16ab29bbc642b9e799d3a438a3e84 100644 (file)
@@ -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;
        }
index b3b53aebc0b0fca10a49f3b9453daae410451a5a..681e8705e75d26688e489c73761e47705abb6b4c 100644 (file)
@@ -221,7 +221,7 @@ static char **script_command_args_alloc(
                int len;
                const char *w = Jim_GetString(argv[i], &len);
                words[i] = strdup(w);
-               if (words[i] == NULL) {
+               if (!words[i]) {
                        script_command_args_free(words, i);
                        return NULL;
                }
@@ -501,7 +501,7 @@ void command_print_sameline(struct command_invocation *cmd, const char *format,
        va_start(ap, format);
 
        string = alloc_vprintf(format, ap);
-       if (string != NULL && cmd) {
+       if (string && cmd) {
                /* we want this collected in the log + we also want to pick it up as a tcl return
                 * value.
                 *
@@ -524,7 +524,7 @@ void command_print(struct command_invocation *cmd, const char *format, ...)
        va_start(ap, format);
 
        string = alloc_vprintf(format, ap);
-       if (string != NULL && cmd) {
+       if (string && cmd) {
                strcat(string, "\n");   /* alloc_vprintf guaranteed the buffer to be at least one
                                         *char longer */
                /* we want this collected in the log + we also want to pick it up as a tcl return
index a1b46efd0ee9ec2f0a797cd84864da3663c1bb49..caa0a66bf64707b2d94d3519d489d9687fa328b9 100644 (file)
@@ -230,7 +230,7 @@ COMMAND_HANDLER(handle_debug_level_command)
 COMMAND_HANDLER(handle_log_output_command)
 {
        if (CMD_ARGC == 0 || (CMD_ARGC == 1 && strcmp(CMD_ARGV[0], "default") == 0)) {
-               if (log_output != stderr && log_output != NULL) {
+               if (log_output != stderr && log_output) {
                        /* Close previous log file, if it was open and wasn't stderr. */
                        fclose(log_output);
                }
@@ -244,7 +244,7 @@ COMMAND_HANDLER(handle_log_output_command)
                        LOG_ERROR("failed to open output log '%s'", CMD_ARGV[0]);
                        return ERROR_FAIL;
                }
-               if (log_output != stderr && log_output != NULL) {
+               if (log_output != stderr && log_output) {
                        /* Close previous log file, if it was open and wasn't stderr. */
                        fclose(log_output);
                }
index 68032b7fd5654a4ed47ea6360b05a6d35f60ff06..86ddd8075837a721d7245027528e71c2e2a2abfa 100644 (file)
@@ -145,7 +145,7 @@ int win_select(int max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct time
        struct timeval tvslice;
        int retcode;
 
-#define SAFE_FD_ISSET(fd, set)  (set != NULL && FD_ISSET(fd, set))
+#define SAFE_FD_ISSET(fd, set)  (set && FD_ISSET(fd, set))
 
        /* calculate how long we need to wait in milliseconds */
        if (!tv)
index 3d63fddc835c31b0ac329c0e768ca09e61a167ba..51c1228a329285f2f6966798f8a36b3caa1f2787 100644 (file)
@@ -218,7 +218,7 @@ static void jtag_tap_add(struct jtag_tap *t)
        unsigned jtag_num_taps = 0;
 
        struct jtag_tap **tap = &__jtag_all_taps;
-       while (*tap != NULL) {
+       while (*tap) {
                jtag_num_taps++;
                tap = &(*tap)->next_tap;
        }
@@ -429,7 +429,7 @@ static void jtag_add_scan_check(struct jtag_tap *active, void (*jtag_add_scan)(
        jtag_add_scan(active, in_num_fields, in_fields, state);
 
        for (int i = 0; i < in_num_fields; i++) {
-               if ((in_fields[i].check_value != NULL) && (in_fields[i].in_value != NULL)) {
+               if ((in_fields[i].check_value) && (in_fields[i].in_value)) {
                        jtag_add_callback4(jtag_check_value_mask_callback,
                                (jtag_callback_data_t)in_fields[i].in_value,
                                (jtag_callback_data_t)in_fields[i].check_value,
index bccb9bb2348fa7ac69048febea2f2de91029061b..7bb5d8553854c9240a834342c81abad7fc17a3bc 100644 (file)
@@ -209,7 +209,7 @@ static int at91rm9200_init(void)
 
        cur_device = devices;
 
-       if (at91rm9200_device == NULL || at91rm9200_device[0] == 0) {
+       if (!at91rm9200_device || at91rm9200_device[0] == 0) {
                at91rm9200_device = "rea_ecr";
                LOG_WARNING("No at91rm9200 device specified, using default 'rea_ecr'");
        }
index 68fd470a806c4483fc4a769ffa28dfba0fbaebfc..be8881d9b8a75ac6fd7fb29d95f42e344e9b9909 100644 (file)
@@ -1513,7 +1513,7 @@ static void cmsis_dap_add_jtag_sequence(int s_len, const uint8_t *sequence, int
                                s_offset + offset,
                                tms,
                                tdo_buffer,
-                               tdo_buffer == NULL ? 0 : (tdo_buffer_offset + offset)
+                               !tdo_buffer ? 0 : (tdo_buffer_offset + offset)
                                );
                }
                LOG_DEBUG_IO("END JTAG SEQ SPLIT");
@@ -1530,7 +1530,7 @@ static void cmsis_dap_add_jtag_sequence(int s_len, const uint8_t *sequence, int
        /* control byte */
        queued_seq_buf[queued_seq_buf_end] =
                (tms ? DAP_JTAG_SEQ_TMS : 0) |
-               (tdo_buffer != NULL ? DAP_JTAG_SEQ_TDO : 0) |
+               (tdo_buffer ? DAP_JTAG_SEQ_TDO : 0) |
                (s_len == 64 ? 0 : s_len);
 
        if (sequence)
index e73876c17eadb42c7737078839587d84c6622a3b..dbe3b0819b538f2645eed717a40eb793503b1e79 100644 (file)
@@ -82,7 +82,7 @@ int interface_jtag_add_ir_scan(struct jtag_tap *active,
 
        /* loop over all enabled TAPs */
 
-       for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) {
+       for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap; tap = jtag_tap_next_enabled(tap)) {
                /* search the input field list for fields for the current TAP */
 
                if (tap == active) {
@@ -122,7 +122,7 @@ int interface_jtag_add_dr_scan(struct jtag_tap *active, int in_num_fields,
 
        size_t bypass_devices = 0;
 
-       for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) {
+       for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap; tap = jtag_tap_next_enabled(tap)) {
                if (tap->bypass)
                        bypass_devices++;
        }
@@ -145,7 +145,7 @@ int interface_jtag_add_dr_scan(struct jtag_tap *active, int in_num_fields,
 
        /* loop over all enabled TAPs */
 
-       for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) {
+       for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap; tap = jtag_tap_next_enabled(tap)) {
                /* if TAP is not bypassed insert matching input fields */
 
                if (!tap->bypass) {
@@ -369,7 +369,7 @@ int interface_jtag_execute_queue(void)
        int retval = default_interface_jtag_execute_queue();
        if (retval == ERROR_OK) {
                struct jtag_callback_entry *entry;
-               for (entry = jtag_callback_queue_head; entry != NULL; entry = entry->next) {
+               for (entry = jtag_callback_queue_head; entry; entry = entry->next) {
                        retval = entry->callback(entry->data0, entry->data1, entry->data2, entry->data3);
                        if (retval != ERROR_OK)
                                break;
index f17cd9fd9b35e4dd77173a5a2462b296b1d0b558..82298c23de3461ca19e63ba9ad5e17db288783c1 100644 (file)
@@ -150,11 +150,11 @@ static struct signal *create_signal(const char *name)
                psig = &(*psig)->next;
 
        *psig = calloc(1, sizeof(**psig));
-       if (*psig == NULL)
+       if (!*psig)
                return NULL;
 
        (*psig)->name = strdup(name);
-       if ((*psig)->name == NULL) {
+       if (!(*psig)->name) {
                free(*psig);
                *psig = NULL;
        }
@@ -1068,7 +1068,7 @@ static int ftdi_swd_init(void)
        swd_cmd_queue_alloced = 10;
        swd_cmd_queue = malloc(swd_cmd_queue_alloced * sizeof(*swd_cmd_queue));
 
-       return swd_cmd_queue != NULL ? ERROR_OK : ERROR_FAIL;
+       return swd_cmd_queue ? ERROR_OK : ERROR_FAIL;
 }
 
 static void ftdi_swd_swdio_en(bool enable)
@@ -1143,7 +1143,7 @@ static int ftdi_swd_run_queue(void)
                                goto skip;
                        }
 
-                       if (swd_cmd_queue[i].dst != NULL)
+                       if (swd_cmd_queue[i].dst)
                                *swd_cmd_queue[i].dst = data;
                }
        }
index ceb6628bb5fd89f707fa0c098e5dcccf568e78fb..73746d6d227bba3f3f1070e54d2e71a72fb5506a 100644 (file)
@@ -238,7 +238,7 @@ static int jtag_dpi_execute_queue(void)
        struct jtag_command *cmd;
        int ret = ERROR_OK;
 
-       for (cmd = jtag_command_queue; ret == ERROR_OK && cmd != NULL;
+       for (cmd = jtag_command_queue; ret == ERROR_OK && cmd;
             cmd = cmd->next) {
                switch (cmd->type) {
                case JTAG_RUNTEST:
index aeed6a56c78c1afe21144a299348315bf4f9406c..a5b51aeb8fb97eb3d833b92442a2ef2c10129249 100644 (file)
@@ -496,7 +496,7 @@ static int jtag_vpi_execute_queue(void)
        struct jtag_command *cmd;
        int retval = ERROR_OK;
 
-       for (cmd = jtag_command_queue; retval == ERROR_OK && cmd != NULL;
+       for (cmd = jtag_command_queue; retval == ERROR_OK && cmd;
             cmd = cmd->next) {
                switch (cmd->type) {
                case JTAG_RESET:
index 33f680cc66cfc835c3c93fe182266860241a651d..f285bdcac6097846438f25e84d3db035568cbe08 100644 (file)
@@ -189,7 +189,7 @@ int jtag_libusb_open(const uint16_t vids[], const uint16_t pids[],
                }
 
                /* Device must be open to use libusb_get_string_descriptor_ascii. */
-               if (serial != NULL &&
+               if (serial &&
                                !jtag_libusb_match_serial(libusb_handle, &dev_desc, serial, adapter_get_alternate_serial)) {
                        serial_mismatch = true;
                        libusb_close(libusb_handle);
@@ -285,7 +285,7 @@ int jtag_libusb_set_configuration(struct libusb_device_handle *devh,
                return retval;
 
        retval = libusb_get_config_descriptor(udev, configuration, &config);
-       if (retval != 0 || config == NULL)
+       if (retval != 0 || !config)
                return retval;
 
        /* Only change the configuration if it is not already set to the
index ac1040e23cec254a9378d15f70828a7189a93048..6d1f48bc3188a341231c532588749a1e063150ee 100644 (file)
@@ -250,7 +250,7 @@ static int remote_bitbang_init_tcp(void)
         If socket(2) (or connect(2)) fails, we (close the socket
         and) try the next address. */
 
-       for (rp = result; rp != NULL ; rp = rp->ai_next) {
+       for (rp = result; rp ; rp = rp->ai_next) {
                fd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
                if (fd == -1)
                        continue;
index 7a41a693d10232dc109d4a4d503513a4952a2488..8b6aa3ef4ceb578879f8d6bcbe4803fd4a336b8f 100644 (file)
@@ -677,7 +677,7 @@ static int dtc_queue_run(void)
 
                for (
                        rq_p = dtc_queue.rq_head;
-                       rq_p != NULL;
+                       rq_p;
                        rq_p = rq_next
                        ) {
                        tdo_p = rq_p->scan.buffer + (rq_p->scan.offset / 8);
index 811ad5325275a7802e46c96233b7095d101c6c35..0e86dcd4ad34670a0492e8090095b97ef580a1da 100644 (file)
@@ -568,7 +568,7 @@ static int jtag_libusb_bulk_transfer_n(
                transfers[i].transfer_size = 0;
                transfers[i].transfer = libusb_alloc_transfer(0);
 
-               if (transfers[i].transfer == NULL) {
+               if (!transfers[i].transfer) {
                        for (size_t j = 0; j < i; ++j)
                                libusb_free_transfer(transfers[j].transfer);
 
@@ -3084,7 +3084,7 @@ static int stlink_usb_usb_open(void *handle, struct hl_interface_param_s *param)
        h->cmdbuf = malloc(STLINK_SG_SIZE);
        h->databuf = malloc(STLINK_DATA_SIZE);
 
-       if (h->cmdbuf == NULL || h->databuf == NULL)
+       if (!h->cmdbuf || !h->databuf)
                return ERROR_FAIL;
 
        /*
@@ -3198,7 +3198,7 @@ static int stlink_tcp_open(void *handle, struct hl_interface_param_s *param)
        h->tcp_backend_priv.send_buf = malloc(STLINK_TCP_SEND_BUFFER_SIZE);
        h->tcp_backend_priv.recv_buf = malloc(STLINK_TCP_RECV_BUFFER_SIZE);
 
-       if (h->tcp_backend_priv.send_buf == NULL || h->tcp_backend_priv.recv_buf == NULL)
+       if (!h->tcp_backend_priv.send_buf || !h->tcp_backend_priv.recv_buf)
                return ERROR_FAIL;
 
        h->cmdbuf = &h->tcp_backend_priv.send_buf[8];
index aa7c240ee2d479fec5d6ed8435a23b78c3eb231f..8519d197a56f9433dc9dd5e9c843a16ce336b00c 100644 (file)
@@ -788,7 +788,7 @@ static int ublast_execute_queue(void)
                ublast_initial_wipeout();
        }
 
-       for (cmd = jtag_command_queue; ret == ERROR_OK && cmd != NULL;
+       for (cmd = jtag_command_queue; ret == ERROR_OK && cmd;
             cmd = cmd->next) {
                switch (cmd->type) {
                case JTAG_RESET:
index ee3b72463736f01ef934561c3fc74fc157c1be60..fecd32c326b2975789f27d9ff4661b121d25f729 100644 (file)
@@ -171,10 +171,10 @@ RESULT usbtoxxx_execute_command(void)
                }
 
                /* get result data */
-               if (versaloon_pending[i].pos != NULL) {
+               if (versaloon_pending[i].pos) {
                        uint8_t processed = 0;
 
-                       if (versaloon_pending[i].callback != NULL) {
+                       if (versaloon_pending[i].callback) {
                                versaloon_pending[i].callback(&versaloon_pending[i],
                                        versaloon_buf + usbtoxxx_buffer_index, &processed);
                        }
@@ -197,10 +197,10 @@ RESULT usbtoxxx_execute_command(void)
                                versaloon_pending[i].pos = NULL;
                        }
                } else if ((versaloon_pending[i].want_data_size > 0)
-                               && (versaloon_pending[i].data_buffer != NULL)) {
+                               && (versaloon_pending[i].data_buffer)) {
                        uint8_t processed = 0;
 
-                       if (versaloon_pending[i].callback != NULL) {
+                       if (versaloon_pending[i].callback) {
                                versaloon_pending[i].callback(&versaloon_pending[i],
                                        versaloon_buf + usbtoxxx_buffer_index, &processed);
                        }
index 0aaf22f98ef096845a2d2f86e5fd1bbf6ae522a8..b16a930a99c9984637b1b138284e3eb7b98561c1 100644 (file)
@@ -147,7 +147,7 @@ int hl_interface_init_reset(void)
 
 static int hl_interface_khz(int khz, int *jtag_speed)
 {
-       if (hl_if.layout->api->speed == NULL)
+       if (!hl_if.layout->api->speed)
                return ERROR_OK;
 
        *jtag_speed = hl_if.layout->api->speed(hl_if.handle, khz, true);
@@ -162,7 +162,7 @@ static int hl_interface_speed_div(int speed, int *khz)
 
 static int hl_interface_speed(int speed)
 {
-       if (hl_if.layout->api->speed == NULL)
+       if (!hl_if.layout->api->speed)
                return ERROR_OK;
 
        if (!hl_if.handle) {
index af2f149b09d9627453a01adf5a8b01039817a4e8..6d3fee43cdf940cda95087f737fdd4bd24270416 100644 (file)
@@ -640,7 +640,7 @@ static void jtag_tap_handle_event(struct jtag_tap *tap, enum jtag_event e)
        struct jtag_tap_event_action *jteap;
        int retval;
 
-       for (jteap = tap->event_action; jteap != NULL; jteap = jteap->next) {
+       for (jteap = tap->event_action; jteap; jteap = jteap->next) {
                if (jteap->event != e)
                        continue;
 
index 87b168177c1ade093794f54a2f9fdafe993d8cce..f7ce8cd564999b417ddc2761f28619bb74cb5b23 100644 (file)
@@ -531,7 +531,7 @@ static int freertos_get_thread_ascii_info(struct rtos *rtos, threadid_t thread_i
 
 static bool freertos_detect_rtos(struct target *target)
 {
-       if ((target->rtos->symbols != NULL) &&
+       if ((target->rtos->symbols) &&
                        (target->rtos->symbols[FREERTOS_VAL_PX_READY_TASKS_LISTS].address != 0)) {
                /* looks like FreeRTOS */
                return true;
index c7effe79f961345d1486187a761e722fc8616989..788edc0b4c3af252a2518f455e114e42a9fc70a6 100644 (file)
@@ -491,7 +491,7 @@ static int threadx_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_li
 
 static bool threadx_detect_rtos(struct target *target)
 {
-       if ((target->rtos->symbols != NULL) &&
+       if ((target->rtos->symbols) &&
                        (target->rtos->symbols[THREADX_VAL_TX_THREAD_CREATED_PTR].address != 0)) {
                /* looks like ThreadX */
                return true;
index 6539a78cdbbabb57aa99b1c2df6a14474a5bfeb2..ef1f34d514d95dc9ee867c2c05ba77e309cd0571 100644 (file)
@@ -500,7 +500,7 @@ static int chibios_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_li
 {
        *symbol_list = malloc(sizeof(chibios_symbol_list));
 
-       if (*symbol_list == NULL)
+       if (!*symbol_list)
                return ERROR_FAIL;
 
        memcpy(*symbol_list, chibios_symbol_list, sizeof(chibios_symbol_list));
@@ -509,7 +509,7 @@ static int chibios_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_li
 
 static bool chibios_detect_rtos(struct target *target)
 {
-       if ((target->rtos->symbols != NULL) &&
+       if ((target->rtos->symbols) &&
                        ((target->rtos->symbols[CHIBIOS_VAL_RLIST].address != 0) ||
                         (target->rtos->symbols[CHIBIOS_VAL_CH].address != 0))) {
 
index c6b26285521cce8378064b8016098f1c550a41c1..a81d7b9932594716cdf511e0ca90bf5a5596f467 100644 (file)
@@ -363,7 +363,7 @@ static int ecos_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[
 
 static bool ecos_detect_rtos(struct target *target)
 {
-       if ((target->rtos->symbols != NULL) &&
+       if ((target->rtos->symbols) &&
                        (target->rtos->symbols[ECOS_VAL_THREAD_LIST].address != 0)) {
                /* looks like eCos */
                return true;
index 1987fd59c65c3e032d6a4ffb43fbb3177917df0a..85c8d19053c994f1c438f1ed065d1e2ed7e079a5 100644 (file)
@@ -110,7 +110,7 @@ static const struct embkernel_params embkernel_params_list[] = {
 
 static bool embkernel_detect_rtos(struct target *target)
 {
-       if (target->rtos->symbols != NULL) {
+       if (target->rtos->symbols) {
                if (target->rtos->symbols[SYMBOL_ID_S_CURRENT_TASK].address != 0)
                        return true;
        }
index 5732ac2e9de84d0b6cda51c60760d412d0aa8ec9..3702b0b4762d6976ba548286ba4c62cc72580855 100644 (file)
@@ -107,7 +107,7 @@ static int hwthread_update_threads(struct rtos *rtos)
 
        /* determine the number of "threads" */
        if (target->smp) {
-               for (head = target->head; head != NULL; head = head->next) {
+               for (head = target->head; head; head = head->next) {
                        struct target *curr = head->target;
 
                        if (!target_was_examined(curr))
@@ -123,7 +123,7 @@ static int hwthread_update_threads(struct rtos *rtos)
 
        if (target->smp) {
                /* loop over all threads */
-               for (head = target->head; head != NULL; head = head->next) {
+               for (head = target->head; head; head = head->next) {
                        struct target *curr = head->target;
 
                        if (!target_was_examined(curr))
@@ -218,7 +218,7 @@ static struct target *hwthread_find_thread(struct target *target, int64_t thread
        if (!target)
                return NULL;
        if (target->smp) {
-               for (struct target_list *head = target->head; head != NULL; head = head->next) {
+               for (struct target_list *head = target->head; head; head = head->next) {
                        if (thread_id == threadid_from_target(head->target))
                                return head->target;
                }
@@ -252,20 +252,20 @@ 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] == NULL || reg_list[i]->exist == false || reg_list[i]->hidden)
+               if (!reg_list[i] || reg_list[i]->exist == false || reg_list[i]->hidden)
                        continue;
                j++;
        }
        *rtos_reg_list_size = j;
        *rtos_reg_list = calloc(*rtos_reg_list_size, sizeof(struct rtos_reg));
-       if (*rtos_reg_list == NULL) {
+       if (!*rtos_reg_list) {
                free(reg_list);
                return ERROR_FAIL;
        }
 
        j = 0;
        for (int i = 0; i < reg_list_size; i++) {
-               if (reg_list[i] == NULL || reg_list[i]->exist == false || reg_list[i]->hidden)
+               if (!reg_list[i] || reg_list[i]->exist == false || reg_list[i]->hidden)
                        continue;
                (*rtos_reg_list)[j].number = (*reg_list)[i].number;
                (*rtos_reg_list)[j].size = (*reg_list)[i].size;
index b9749b5612abb3dc44c68a06e3d4f6d126233e12..11a55c43466493d9d4b1d6fd52f7b52f3886d357 100644 (file)
@@ -639,7 +639,7 @@ static struct threads *liste_add_task(struct threads *task_list, struct threads
 {
        t->next = NULL;
 
-       if (*last == NULL)
+       if (!*last)
                if (!task_list) {
                        task_list = t;
                        return task_list;
index f6be35b6cc57ed6aa2f5b70b854c9bbd543ea3f5..710436b7423b23bd3c0f270773116661b2e6dc2d 100644 (file)
@@ -243,7 +243,7 @@ static bool mqx_detect_rtos(
 )
 {
        if (
-               (target->rtos->symbols != NULL) &&
+               (target->rtos->symbols) &&
                (target->rtos->symbols[MQX_VAL_MQX_KERNEL_DATA].address != 0)
        ) {
                return true;
index 00fec7fb764580d6ef5f5b7c95d5dc7572d700a0..cc352d18008f1e051ea560fcb0884d71beccc0ff 100644 (file)
@@ -233,7 +233,7 @@ retok:
 
 static bool nuttx_detect_rtos(struct target *target)
 {
-       if ((target->rtos->symbols != NULL) &&
+       if ((target->rtos->symbols) &&
                        (target->rtos->symbols[0].address != 0) &&
                        (target->rtos->symbols[1].address != 0)) {
                return true;
index 2316f17b5440e0a9e1de0334b51fd0c191b585eb..6652db651104cf39e63b0502f12e557758132b48 100644 (file)
@@ -255,7 +255,7 @@ static int riot_update_threads(struct rtos *rtos)
                        strdup(riot_thread_states[k].desc);
                }
 
-               if (rtos->thread_details[tasks_found].extra_info_str == NULL) {
+               if (!rtos->thread_details[tasks_found].extra_info_str) {
                        LOG_ERROR("RIOT: out of memory");
                        retval = ERROR_FAIL;
                        goto error;
@@ -297,7 +297,7 @@ static int riot_update_threads(struct rtos *rtos)
                        strdup("Enable DEVELHELP to see task names");
                }
 
-               if (rtos->thread_details[tasks_found].thread_name_str == NULL) {
+               if (!rtos->thread_details[tasks_found].thread_name_str) {
                        LOG_ERROR("RIOT: out of memory");
                        retval = ERROR_FAIL;
                        goto error;
@@ -364,7 +364,7 @@ static int riot_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[
 {
        *symbol_list = calloc(ARRAY_SIZE(riot_symbol_list), sizeof(struct symbol_table_elem));
 
-       if (*symbol_list == NULL) {
+       if (!*symbol_list) {
                LOG_ERROR("RIOT: out of memory");
                return ERROR_FAIL;
        }
@@ -387,7 +387,7 @@ static int riot_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[
 
 static bool riot_detect_rtos(struct target *target)
 {
-       if ((target->rtos->symbols != NULL) &&
+       if ((target->rtos->symbols) &&
                (target->rtos->symbols[RIOT_THREADS_BASE].address != 0)) {
                /* looks like RIOT */
                return true;
index 54e9926f1cc222f3da9e3da98cf278e8cd6fa63a..2b621543052b83e40c6a160a753701da02f7a460 100644 (file)
@@ -306,13 +306,13 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa
        struct target *target = get_target_from_connection(connection);
 
        if (strncmp(packet, "qThreadExtraInfo,", 17) == 0) {
-               if ((target->rtos) && (target->rtos->thread_details != NULL) &&
+               if ((target->rtos) && (target->rtos->thread_details) &&
                                (target->rtos->thread_count != 0)) {
                        threadid_t threadid = 0;
                        int found = -1;
                        sscanf(packet, "qThreadExtraInfo,%" SCNx64, &threadid);
 
-                       if ((target->rtos) && (target->rtos->thread_details != NULL)) {
+                       if ((target->rtos) && (target->rtos->thread_details)) {
                                int thread_num;
                                for (thread_num = 0; thread_num < target->rtos->thread_count; thread_num++) {
                                        if (target->rtos->thread_details[thread_num].threadid == threadid) {
@@ -416,7 +416,7 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa
                threadid_t threadid;
                int found = -1;
                sscanf(packet, "T%" SCNx64, &threadid);
-               if ((target->rtos) && (target->rtos->thread_details != NULL)) {
+               if ((target->rtos) && (target->rtos->thread_details)) {
                        int thread_num;
                        for (thread_num = 0; thread_num < target->rtos->thread_count; thread_num++) {
                                if (target->rtos->thread_details[thread_num].threadid == threadid) {
@@ -564,7 +564,7 @@ int rtos_set_reg(struct connection *connection, int reg_num,
        struct target *target = get_target_from_connection(connection);
        int64_t current_threadid = target->rtos->current_threadid;
        if ((target->rtos) &&
-                       (target->rtos->type->set_reg != NULL) &&
+                       (target->rtos->type->set_reg) &&
                        (current_threadid != -1) &&
                        (current_threadid != 0)) {
                return target->rtos->type->set_reg(target->rtos, reg_num, reg_value);
@@ -657,7 +657,7 @@ static int rtos_try_next(struct target *target)
 
 int rtos_update_threads(struct target *target)
 {
-       if ((target->rtos) && (target->rtos->type != NULL))
+       if ((target->rtos) && (target->rtos->type))
                target->rtos->type->update_threads(target->rtos);
        return ERROR_OK;
 }
index 4cdf72de9c8527e3ee3f2be822f9eb0f30250983..385c8d84117997e565ed1232097537e78ba914f7 100644 (file)
@@ -257,7 +257,7 @@ static int ucos_iii_update_thread_offsets(struct rtos *rtos)
 
 static bool ucos_iii_detect_rtos(struct target *target)
 {
-       return target->rtos->symbols != NULL &&
+       return target->rtos->symbols &&
                        target->rtos->symbols[UCOS_III_VAL_OS_RUNNING].address != 0;
 }
 
@@ -511,7 +511,7 @@ static int ucos_iii_get_thread_reg_list(struct rtos *rtos, threadid_t threadid,
 static int ucos_iii_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[])
 {
        *symbol_list = calloc(ARRAY_SIZE(ucos_iii_symbol_list), sizeof(struct symbol_table_elem));
-       if (*symbol_list == NULL) {
+       if (!*symbol_list) {
                LOG_ERROR("uCOS-III: out of memory");
                return ERROR_FAIL;
        }
index ef5ff5879158ff40a775316383b1841f6bfb4a1f..fc5e0375b9a1c4f51a14fc58e47f9baa7b21d87e 100644 (file)
@@ -385,7 +385,7 @@ static const struct symbol_table_elem zephyr_symbol_list[] = {
 
 static bool zephyr_detect_rtos(struct target *target)
 {
-       if (target->rtos->symbols == NULL) {
+       if (!target->rtos->symbols) {
                LOG_INFO("Zephyr: no symbols while detecting RTOS");
                return false;
        }
index bc3a675cf682f3be5e52a1b3f0a8d0b97aeca3b7..3a39f8a252dba661d87ac9bea1fb662d8b12504b 100644 (file)
@@ -1043,7 +1043,7 @@ static int gdb_new_connection(struct connection *connection)
        }
 
        gdb_actual_connections++;
-       log_printf_lf(all_targets->next != NULL ? LOG_LVL_INFO : LOG_LVL_DEBUG,
+       log_printf_lf(all_targets->next ? LOG_LVL_INFO : LOG_LVL_DEBUG,
                        __FILE__, __LINE__, __func__,
                        "New GDB Connection: %d, Target %s, state: %s",
                        gdb_actual_connections,
@@ -1221,7 +1221,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] == NULL || reg_list[i]->exist == false || reg_list[i]->hidden)
+               if (!reg_list[i] || reg_list[i]->exist == false || reg_list[i]->hidden)
                        continue;
                reg_packet_size += DIV_ROUND_UP(reg_list[i]->size, 8) * 2;
        }
@@ -1235,7 +1235,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] == NULL || reg_list[i]->exist == false || reg_list[i]->hidden)
+               if (!reg_list[i] || reg_list[i]->exist == false || reg_list[i]->hidden)
                        continue;
                if (!reg_list[i]->valid) {
                        retval = reg_list[i]->type->get(reg_list[i]);
@@ -1792,14 +1792,14 @@ static __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 5, 6))) void xml_printf(
        int first = 1;
 
        for (;; ) {
-               if ((*xml == NULL) || (!first)) {
+               if ((!*xml) || (!first)) {
                        /* start by 0 to exercise all the code paths.
                         * Need minimum 2 bytes to fit 1 char and 0 terminator. */
 
                        *size = *size * 2 + 2;
                        char *t = *xml;
                        *xml = realloc(*xml, *size);
-                       if (*xml == NULL) {
+                       if (!*xml) {
                                free(t);
                                *retval = ERROR_SERVER_REMOTE_CLOSED;
                                return;
@@ -1840,7 +1840,7 @@ static int decode_xfer_read(char const *buf, char **annex, int *ofs, unsigned in
        /* Extract the annex if needed */
        if (annex) {
                *annex = strndup(buf, annex_end - buf);
-               if (*annex == NULL)
+               if (!*annex)
                        return ERROR_FAIL;
        }
 
@@ -2059,7 +2059,7 @@ static int lookup_add_arch_defined_types(char const **arch_defined_types_list[],
 {
        int tbl_sz = *num_arch_defined_types;
 
-       if (type_id != NULL && (strcmp(type_id, ""))) {
+       if (type_id && (strcmp(type_id, ""))) {
                for (int j = 0; j < (tbl_sz + 1); j++) {
                        if (!((*arch_defined_types_list)[j])) {
                                (*arch_defined_types_list)[tbl_sz++] = type_id;
@@ -2224,8 +2224,8 @@ static int get_reg_features_list(struct target *target, char const **feature_lis
                if (reg_list[i]->exist == false || reg_list[i]->hidden)
                        continue;
 
-               if (reg_list[i]->feature != NULL
-                       && reg_list[i]->feature->name != NULL
+               if (reg_list[i]->feature
+                       && reg_list[i]->feature->name
                        && (strcmp(reg_list[i]->feature->name, ""))) {
                        /* We found a feature, check if the feature is already in the
                         * table. If not, allocate a new entry for the table and
@@ -2322,7 +2322,7 @@ static int gdb_generate_target_description(struct target *target, char **tdesc_o
                                        continue;
 
                                const char *type_str;
-                               if (reg_list[i]->reg_data_type != NULL) {
+                               if (reg_list[i]->reg_data_type) {
                                        if (reg_list[i]->reg_data_type->type == REG_TYPE_ARCH_DEFINED) {
                                                /* generate <type... first, if there are architecture-defined types. */
                                                if (lookup_add_arch_defined_types(&arch_defined_types,
@@ -2360,7 +2360,7 @@ static int gdb_generate_target_description(struct target *target, char **tdesc_o
                                xml_printf(&retval, &tdesc, &pos, &size,
                                                " type=\"%s\"", type_str);
 
-                               if (reg_list[i]->group != NULL)
+                               if (reg_list[i]->group)
                                        xml_printf(&retval, &tdesc, &pos, &size,
                                                        " group=\"%s\"", reg_list[i]->group);
 
@@ -2420,7 +2420,7 @@ static int gdb_get_target_description_chunk(struct target *target, struct target
                transfer_type = 'l';
 
        *chunk = malloc(length + 2);
-       if (*chunk == NULL) {
+       if (!*chunk) {
                LOG_ERROR("Unable to allocate memory");
                return ERROR_FAIL;
        }
@@ -2543,7 +2543,7 @@ static int gdb_generate_thread_list(struct target *target, char **thread_list_ou
 static int gdb_get_thread_list_chunk(struct target *target, char **thread_list,
                char **chunk, int32_t offset, uint32_t length)
 {
-       if (*thread_list == NULL) {
+       if (!*thread_list) {
                int retval = gdb_generate_thread_list(target, thread_list);
                if (retval != ERROR_OK) {
                        LOG_ERROR("Unable to Generate Thread List");
@@ -2565,7 +2565,7 @@ static int gdb_get_thread_list_chunk(struct target *target, char **thread_list,
         * of strlen(chunk) word access:
         * Invalid read of size 4
         * Address 0x4479934 is 44 bytes inside a block of size 45 alloc'd */
-       if (*chunk == NULL) {
+       if (!*chunk) {
                LOG_ERROR("Unable to allocate memory");
                return ERROR_FAIL;
        }
@@ -2770,7 +2770,7 @@ static bool gdb_handle_vcont_packet(struct connection *connection, const char *p
 
        /* query for vCont supported */
        if (parse[0] == '?') {
-               if (target->type->step != NULL) {
+               if (target->type->step) {
                        /* gdb doesn't accept c without C and s without S */
                        gdb_put_packet(connection, "vCont;c;C;s;S", 13);
                        return true;
@@ -3007,7 +3007,7 @@ static bool gdb_handle_vrun_packet(struct connection *connection, const char *pa
 
        char *cmdline = next_hex_encoded_field(&parse, ';');
        char *arg;
-       while (cmdline != NULL && (arg = next_hex_encoded_field(&parse, ';')) != NULL) {
+       while (cmdline && (arg = next_hex_encoded_field(&parse, ';')) != NULL) {
                char *new_cmdline = alloc_printf("%s %s", cmdline, arg);
                free(cmdline);
                free(arg);
index 92a8026cf346c924fc680a9fd2254a66ed5d441d..e088232242ff7a78700f41fc9d80628af83997ba 100644 (file)
@@ -298,10 +298,10 @@ COMMAND_HANDLER(handle_tcl_notifications_command)
        struct connection *connection = NULL;
        struct tcl_connection *tclc = NULL;
 
-       if (CMD_CTX->output_handler_priv != NULL)
+       if (CMD_CTX->output_handler_priv)
                connection = CMD_CTX->output_handler_priv;
 
-       if (connection != NULL && !strcmp(connection->service->name, "tcl")) {
+       if (connection && !strcmp(connection->service->name, "tcl")) {
                tclc = connection->priv;
                return CALL_COMMAND_HANDLER(handle_command_parse_bool, &tclc->tc_notify, "Target Notification output ");
        } else {
@@ -315,10 +315,10 @@ COMMAND_HANDLER(handle_tcl_trace_command)
        struct connection *connection = NULL;
        struct tcl_connection *tclc = NULL;
 
-       if (CMD_CTX->output_handler_priv != NULL)
+       if (CMD_CTX->output_handler_priv)
                connection = CMD_CTX->output_handler_priv;
 
-       if (connection != NULL && !strcmp(connection->service->name, "tcl")) {
+       if (connection && !strcmp(connection->service->name, "tcl")) {
                tclc = connection->priv;
                return CALL_COMMAND_HANDLER(handle_command_parse_bool, &tclc->tc_trace, "Target trace output ");
        } else {
index b01046d9adfe18084422dc069ae15defcaa3328f..97af3d97f1a7c5172998c95b6bf5ada318a105b4 100644 (file)
@@ -199,7 +199,7 @@ static void telnet_save_history(struct telnet_connection *t_con)
                i = t_con->current_history + 1;
                i %= TELNET_LINE_HISTORY_SIZE;
 
-               while (t_con->history[i] == NULL && num > 0) {
+               while (!t_con->history[i] && num > 0) {
                        i++;
                        i %= TELNET_LINE_HISTORY_SIZE;
                        num--;
@@ -640,7 +640,7 @@ static int telnet_input(struct connection *connection)
                                                        /* save only non-blank not repeating lines in the history */
                                                        char *prev_line = t_con->history[(t_con->current_history > 0) ?
                                                                        t_con->current_history - 1 : TELNET_LINE_HISTORY_SIZE-1];
-                                                       if (*t_con->line && (prev_line == NULL ||
+                                                       if (*t_con->line && (!prev_line ||
                                                                        strcmp(t_con->line, prev_line))) {
                                                                /* if the history slot is already taken, free it */
                                                                free(t_con->history[t_con->next_history]);
index e12fbce23cc5913eac488da9614c5045b06b3603..553bdc7e1a5e306df225bf3853134a225c405ca4 100644 (file)
@@ -587,7 +587,7 @@ static int svf_getline(char **lineptr, size_t *n, FILE *stream)
 #define MIN_CHUNK 16   /* Buffer is increased by this size each time as required */
        size_t i = 0;
 
-       if (*lineptr == NULL) {
+       if (!*lineptr) {
                *n = MIN_CHUNK;
                *lineptr = malloc(*n);
                if (!*lineptr)
index 43a13aa9c30fafd9cca8f84632ab21ea47835b23..70e727cf9d42334a2d304ceeba4607446ca800f5 100644 (file)
@@ -501,7 +501,7 @@ static int update_halt_gdb(struct target *target, enum target_debug_reason debug
        }
 
        /* after all targets were updated, poll the gdb serving target */
-       if (gdb_target != NULL && gdb_target != target)
+       if (gdb_target && gdb_target != target)
                aarch64_poll(gdb_target);
 
        return ERROR_OK;
@@ -2855,7 +2855,7 @@ static int aarch64_jim_configure(struct target *target, struct jim_getopt_info *
                                        return JIM_ERR;
                                }
 
-                               if (pc == NULL || pc->cti == NULL) {
+                               if (!pc || !pc->cti) {
                                        Jim_SetResultString(goi->interp, "CTI not configured", -1);
                                        return JIM_ERR;
                                }
index 1e8a515192147737b133b96c27dbacd0b679fac2..4b546c3b4d414fb90a12a2e7848d60fc246a82ff 100644 (file)
@@ -1949,7 +1949,7 @@ static int arc_hit_watchpoint(struct target *target, struct watchpoint **hit_wat
                        LOG_WARNING("Target halted by breakpoint, but is treated as a watchpoint.");
 
                for (struct watchpoint *watchpoint = target->watchpoints;
-                               watchpoint != NULL;
+                               watchpoint;
                                watchpoint = watchpoint->next) {
                        if (actionpoint->bp_value == watchpoint->address) {
                                *hit_watchpoint = watchpoint;
index c458ffd46c83756c72dfd8105ea2c31ec18c6bad..dc6f63d468414331f2dcb27b03a3705aeb6e35e4 100644 (file)
@@ -1028,7 +1028,7 @@ int dap_lookup_cs_component(struct adiv5_ap *ap,
 static int dap_read_part_id(struct adiv5_ap *ap, target_addr_t component_base, uint32_t *cid, uint64_t *pid)
 {
        assert((component_base & 0xFFF) == 0);
-       assert(ap != NULL && cid != NULL && pid != NULL);
+       assert(ap && cid && pid);
 
        uint32_t cid0, cid1, cid2, cid3;
        uint32_t pid0, pid1, pid2, pid3, pid4;
index 8ebe96301319917182c7955d3c77060aa16a6bb3..5d1e793781107d3700f5f7fea4ec5aadf294f133 100644 (file)
@@ -446,7 +446,7 @@ static inline int dap_queue_dp_write(struct adiv5_dap *dap,
 static inline int dap_queue_ap_read(struct adiv5_ap *ap,
                unsigned reg, uint32_t *data)
 {
-       assert(ap->dap->ops != NULL);
+       assert(ap->dap->ops);
        return ap->dap->ops->queue_ap_read(ap, reg, data);
 }
 
@@ -462,7 +462,7 @@ static inline int dap_queue_ap_read(struct adiv5_ap *ap,
 static inline int dap_queue_ap_write(struct adiv5_ap *ap,
                unsigned reg, uint32_t data)
 {
-       assert(ap->dap->ops != NULL);
+       assert(ap->dap->ops);
        return ap->dap->ops->queue_ap_write(ap, reg, data);
 }
 
index cc8c19a9b837484899c5ab52684a61ec14332fbb..6de79c3892747ad1f04c888550f429dfd0affbca 100644 (file)
@@ -483,7 +483,7 @@ int armv7a_identify_cache(struct target *target)
                goto done;
 
        /*  if no l2 cache initialize l1 data cache flush function function */
-       if (armv7a->armv7a_mmu.armv7a_cache.flush_all_data_cache == NULL) {
+       if (!armv7a->armv7a_mmu.armv7a_cache.flush_all_data_cache) {
                armv7a->armv7a_mmu.armv7a_cache.flush_all_data_cache =
                        armv7a_cache_auto_flush_all_data;
        }
index ee05e47299a0ba22c3adc7ddbf6b983124c5dadc..68da020a13f8d45d26813bb679b909c40da23d90 100644 (file)
@@ -474,7 +474,7 @@ int armv7m_get_gdb_reg_list(struct target *target, struct reg **reg_list[],
                size = ARMV7M_NUM_CORE_REGS;
 
        *reg_list = malloc(sizeof(struct reg *) * size);
-       if (*reg_list == NULL)
+       if (!*reg_list)
                return ERROR_FAIL;
 
        for (i = 0; i < size; i++)
index 86c0ebf3c822d10bc2f7ab4d25d1402d065d4fb3..43a365938a57b30b71fd16d1a6b9f91a180f0930 100644 (file)
@@ -204,7 +204,7 @@ static int armv8_read_reg(struct armv8_common *armv8, int regnum, uint64_t *regv
                break;
        }
 
-       if (retval == ERROR_OK && regval != NULL)
+       if (retval == ERROR_OK && regval)
                *regval = value_64;
        else
                retval = ERROR_FAIL;
@@ -430,7 +430,7 @@ static int armv8_read_reg32(struct armv8_common *armv8, int regnum, uint64_t *re
                break;
        }
 
-       if (retval == ERROR_OK && regval != NULL)
+       if (retval == ERROR_OK && regval)
                *regval = value;
 
        return retval;
@@ -1053,7 +1053,7 @@ COMMAND_HANDLER(armv8_handle_exception_catch_command)
                if (n->name)
                        nsec = n->name;
 
-               if (sec == NULL || nsec == NULL) {
+               if (!sec || !nsec) {
                        LOG_WARNING("Exception Catch: unknown exception catch configuration: EDECCR = %02" PRIx32, edeccr & 0xff);
                        return ERROR_FAIL;
                }
@@ -1644,7 +1644,7 @@ struct reg_cache *armv8_build_reg_cache(struct target *target)
 
                reg_list[i].reg_data_type = calloc(1, sizeof(struct reg_data_type));
                if (reg_list[i].reg_data_type) {
-                       if (armv8_regs[i].data_type == NULL)
+                       if (!armv8_regs[i].data_type)
                                reg_list[i].reg_data_type->type = armv8_regs[i].type;
                        else
                                *reg_list[i].reg_data_type = *armv8_regs[i].data_type;
index 86e4a59615451a1bdf6821cef7ee301bb33d760c..b668b84220fa28084b1c860834f6de64468d2e75 100644 (file)
@@ -417,7 +417,7 @@ int armv8_identify_cache(struct armv8_common *armv8)
        armv8->armv8_mmu.armv8_cache.info = 1;
 
        /*  if no l2 cache initialize l1 data cache flush function function */
-       if (armv8->armv8_mmu.armv8_cache.flush_all_data_cache == NULL) {
+       if (!armv8->armv8_mmu.armv8_cache.flush_all_data_cache) {
                armv8->armv8_mmu.armv8_cache.display_cache_info =
                        armv8_handle_inner_cache_info_command;
                armv8->armv8_mmu.armv8_cache.flush_all_data_cache =
index f41f39d0e2732ad5663309fc98fa3af3d7683ad2..8ef196e342e2b28bccb47523a48765837292159d 100644 (file)
@@ -704,7 +704,7 @@ static int update_halt_gdb(struct target *target)
        }
 
        /* after all targets were updated, poll the gdb serving target */
-       if (gdb_target != NULL && gdb_target != target)
+       if (gdb_target && gdb_target != target)
                cortex_a_poll(gdb_target);
        return retval;
 }
@@ -726,7 +726,7 @@ static int cortex_a_poll(struct target *target)
        /*  the next polling trigger an halt event sent to gdb */
        if ((target->state == TARGET_HALTED) && (target->smp) &&
                (target->gdb_service) &&
-               (target->gdb_service->target == NULL)) {
+               (!target->gdb_service->target)) {
                target->gdb_service->target =
                        get_cortex_a(target, target->gdb_service->core[1]);
                target_call_event_callbacks(target, TARGET_EVENT_HALTED);
index d17e1ddff66a0649a475261810a439961a586911..e49f5f6596fc3ea0a36d9b95d599cc2b5d8fdd78 100644 (file)
@@ -472,7 +472,7 @@ static int esirisc_next_breakpoint(struct target *target)
        LOG_DEBUG("-");
 
        for (int bp_index = 0; breakpoints_p < breakpoints_e; ++breakpoints_p, ++bp_index)
-               if (*breakpoints_p == NULL)
+               if (!*breakpoints_p)
                        return bp_index;
 
        return -1;
@@ -608,7 +608,7 @@ static int esirisc_next_watchpoint(struct target *target)
        LOG_DEBUG("-");
 
        for (int wp_index = 0; watchpoints_p < watchpoints_e; ++watchpoints_p, ++wp_index)
-               if (*watchpoints_p == NULL)
+               if (!*watchpoints_p)
                        return wp_index;
 
        return -1;
@@ -1267,7 +1267,7 @@ static const char *esirisc_get_gdb_arch(struct target *target)
         * requires additional configuration to properly interact with these
         * targets in GDB (also see: `esirisc cache_arch`).
         */
-       if (esirisc->gdb_arch == NULL && target_was_examined(target))
+       if (!esirisc->gdb_arch && target_was_examined(target))
                esirisc->gdb_arch = alloc_printf("esirisc:%d_bit_%d_reg_%s",
                                esirisc->num_bits, esirisc->num_regs, esirisc_cache_arch_name(esirisc));
 
@@ -1284,7 +1284,7 @@ static int esirisc_get_gdb_reg_list(struct target *target, struct reg **reg_list
        *reg_list_size = ESIRISC_NUM_REGS;
 
        *reg_list = calloc(*reg_list_size, sizeof(struct reg *));
-       if (*reg_list == NULL)
+       if (!*reg_list)
                return ERROR_FAIL;
 
        if (reg_class == REG_CLASS_ALL)
index 7fd35e5fde6cc9560395b7aed5c32a499a837942..dd5cd5a0ee792b1f17bffc000e845e787c33c96e 100644 (file)
@@ -57,7 +57,7 @@ static int esirisc_jtag_get_padding(void)
        int padding = 0;
        int bypass_devices = 0;
 
-       for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap != NULL;
+       for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap;
                        tap = jtag_tap_next_enabled(tap))
                if (tap->bypass)
                        bypass_devices++;
index 05577ead102e6a27ee667c9cb5558b7e97984dfe..e8bd20fef41825e6fb544a509d600721b965ab4b 100644 (file)
@@ -298,7 +298,7 @@ struct reg_cache *etm_build_reg_cache(struct target *target,
        reg_list = calloc(128, sizeof(struct reg));
        arch_info = calloc(128, sizeof(struct etm_reg));
 
-       if (reg_cache == NULL || reg_list == NULL || arch_info == NULL) {
+       if (!reg_cache || !reg_list || !arch_info) {
                LOG_ERROR("No memory");
                goto fail;
        }
index 78ec7e885943ee55ccc35393c31837172cbf90b3..91861054f47d2109e060657da8778ce7adf67511 100644 (file)
@@ -202,7 +202,7 @@ static int adapter_target_create(struct target *target,
 {
        LOG_DEBUG("%s", __func__);
        struct adiv5_private_config *pc = target->private_config;
-       if (pc != NULL && pc->ap_num > 0) {
+       if (pc && pc->ap_num > 0) {
                LOG_ERROR("hla_target: invalid parameter -ap-num (> 0)");
                return ERROR_COMMAND_SYNTAX_ERROR;
        }
index e3f331d13ad950ee03c46214312ff4a4e3e5a914..c30ac3b74414c9b9600677c085f8c67a8da1a66f 100644 (file)
@@ -381,7 +381,7 @@ struct reg_cache *lakemont_build_reg_cache(struct target *t)
        struct reg_feature *feature;
        int i;
 
-       if (cache == NULL || reg_list == NULL || arch_info == NULL) {
+       if (!cache || !reg_list || !arch_info) {
                free(cache);
                free(reg_list);
                free(arch_info);
@@ -1013,7 +1013,7 @@ int lakemont_resume(struct target *t, int current, target_addr_t address,
                /* running away for a software breakpoint needs some special handling */
                uint32_t eip = buf_get_u32(x86_32->cache->reg_list[EIP].value, 0, 32);
                bp = breakpoint_find(t, eip);
-               if (bp != NULL /*&& bp->type == BKPT_SOFT*/) {
+               if (bp /*&& bp->type == BKPT_SOFT*/) {
                        /* the step will step over the breakpoint */
                        if (lakemont_step(t, 0, 0, 1) != ERROR_OK) {
                                LOG_ERROR("%s stepping over a software breakpoint at 0x%08" PRIx32 " "
@@ -1024,12 +1024,12 @@ int lakemont_resume(struct target *t, int current, target_addr_t address,
 
                /* if breakpoints are enabled, we need to redirect these into probe mode */
                struct breakpoint *activeswbp = t->breakpoints;
-               while (activeswbp != NULL && activeswbp->set == 0)
+               while (activeswbp && activeswbp->set == 0)
                        activeswbp = activeswbp->next;
                struct watchpoint *activehwbp = t->watchpoints;
-               while (activehwbp != NULL && activehwbp->set == 0)
+               while (activehwbp && activehwbp->set == 0)
                        activehwbp = activehwbp->next;
-               if (activeswbp != NULL || activehwbp != NULL)
+               if (activeswbp || activehwbp)
                        buf_set_u32(x86_32->cache->reg_list[PMCR].value, 0, 32, 1);
                if (do_resume(t) != ERROR_OK)
                        return ERROR_FAIL;
@@ -1054,7 +1054,7 @@ int lakemont_step(struct target *t, int current,
        if (check_not_halted(t))
                return ERROR_TARGET_NOT_HALTED;
        bp = breakpoint_find(t, eip);
-       if (retval == ERROR_OK && bp != NULL/*&& bp->type == BKPT_SOFT*/) {
+       if (retval == ERROR_OK && bp/*&& bp->type == BKPT_SOFT*/) {
                /* TODO: This should only be done for software breakpoints.
                 * Stepping from hardware breakpoints should be possible with the resume flag
                 * Needs testing.
@@ -1105,7 +1105,7 @@ int lakemont_step(struct target *t, int current,
        /* try to re-apply the breakpoint, even of step failed
         * TODO: When a bp was set, we should try to stop the target - fix the return above
         */
-       if (bp != NULL/*&& bp->type == BKPT_SOFT*/) {
+       if (bp/*&& bp->type == BKPT_SOFT*/) {
                /* TODO: This should only be done for software breakpoints.
                 * Stepping from hardware breakpoints should be possible with the resume flag
                 * Needs testing.
index 5e1218837ec87654e58ffbc1f2d879b8a4ccb069..c167224d28e0723b79b2966e50f6b77eae0c189c 100644 (file)
@@ -184,7 +184,7 @@ static int ls1_sap_read_memory(struct target *target, target_addr_t address,
        LOG_DEBUG("Reading memory at physical address 0x%" TARGET_PRIxADDR
                  "; size %" PRIu32 "; count %" PRIu32, address, size, count);
 
-       if (count == 0 || buffer == NULL)
+       if (count == 0 || !buffer)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        ls1_sap_set_addr_high(target->tap, 0);
@@ -207,7 +207,7 @@ static int ls1_sap_write_memory(struct target *target, target_addr_t address,
                  "; size %" PRIu32 "; count %" PRIu32, address, size, count);
 
 
-       if (count == 0 || buffer == NULL)
+       if (count == 0 || !buffer)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        ls1_sap_set_addr_high(target->tap, 0);
index 424d6e71674a81420ea61c20d8e19a2d01d4c485..eef05b44bba411eaf1ca3d49fbfab90033baab52 100644 (file)
@@ -238,7 +238,7 @@ static int mem_ap_read_memory(struct target *target, target_addr_t address,
        LOG_DEBUG("Reading memory at physical address " TARGET_ADDR_FMT
                  "; size %" PRIu32 "; count %" PRIu32, address, size, count);
 
-       if (count == 0 || buffer == NULL)
+       if (count == 0 || !buffer)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        return mem_ap_read_buf(mem_ap->ap, buffer, size, count, address);
@@ -253,7 +253,7 @@ static int mem_ap_write_memory(struct target *target, target_addr_t address,
        LOG_DEBUG("Writing memory at physical address " TARGET_ADDR_FMT
                  "; size %" PRIu32 "; count %" PRIu32, address, size, count);
 
-       if (count == 0 || buffer == NULL)
+       if (count == 0 || !buffer)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        return mem_ap_write_buf(mem_ap->ap, buffer, size, count, address);
index 1a402933afbd265f284debee4119b13c4768e538..cd06893511cfe3e6fb26e498d7705704b2951a92 100644 (file)
@@ -186,7 +186,7 @@ static int mips_m4k_poll(struct target *target)
        /*  the next polling trigger an halt event sent to gdb */
        if ((target->state == TARGET_HALTED) && (target->smp) &&
                (target->gdb_service) &&
-               (target->gdb_service->target == NULL)) {
+               (!target->gdb_service->target)) {
                target->gdb_service->target =
                        get_mips_m4k(target, target->gdb_service->core[1]);
                target_call_event_callbacks(target, TARGET_EVENT_HALTED);
index e494a3e1cd42cc055eed10ea6abeb917d83b4163..b01f8c09e86129628dbcbb7a3d5a1f5cd7d39abc 100644 (file)
@@ -24,7 +24,7 @@
 
 int aice_read_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t *val)
 {
-       if (aice->port->api->read_reg_64 == NULL) {
+       if (!aice->port->api->read_reg_64) {
                LOG_WARNING("Not implemented: %s", __func__);
                return ERROR_FAIL;
        }
@@ -34,7 +34,7 @@ int aice_read_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t *val)
 
 int aice_write_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t val)
 {
-       if (aice->port->api->write_reg_64 == NULL) {
+       if (!aice->port->api->write_reg_64) {
                LOG_WARNING("Not implemented: %s", __func__);
                return ERROR_FAIL;
        }
@@ -45,7 +45,7 @@ int aice_write_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t val)
 int aice_read_tlb(struct aice_port_s *aice, target_addr_t virtual_address,
                target_addr_t *physical_address)
 {
-       if (aice->port->api->read_tlb == NULL) {
+       if (!aice->port->api->read_tlb) {
                LOG_WARNING("Not implemented: %s", __func__);
                return ERROR_FAIL;
        }
@@ -55,7 +55,7 @@ int aice_read_tlb(struct aice_port_s *aice, target_addr_t virtual_address,
 
 int aice_cache_ctl(struct aice_port_s *aice, uint32_t subtype, uint32_t address)
 {
-       if (aice->port->api->cache_ctl == NULL) {
+       if (!aice->port->api->cache_ctl) {
                LOG_WARNING("Not implemented: %s", __func__);
                return ERROR_FAIL;
        }
@@ -65,7 +65,7 @@ int aice_cache_ctl(struct aice_port_s *aice, uint32_t subtype, uint32_t address)
 
 int aice_set_retry_times(struct aice_port_s *aice, uint32_t a_retry_times)
 {
-       if (aice->port->api->set_retry_times == NULL) {
+       if (!aice->port->api->set_retry_times) {
                LOG_WARNING("Not implemented: %s", __func__);
                return ERROR_FAIL;
        }
@@ -75,7 +75,7 @@ int aice_set_retry_times(struct aice_port_s *aice, uint32_t a_retry_times)
 
 int aice_program_edm(struct aice_port_s *aice, char *command_sequence)
 {
-       if (aice->port->api->program_edm == NULL) {
+       if (!aice->port->api->program_edm) {
                LOG_WARNING("Not implemented: %s", __func__);
                return ERROR_FAIL;
        }
@@ -86,7 +86,7 @@ int aice_program_edm(struct aice_port_s *aice, char *command_sequence)
 int aice_set_command_mode(struct aice_port_s *aice,
                enum aice_command_mode command_mode)
 {
-       if (aice->port->api->set_command_mode == NULL) {
+       if (!aice->port->api->set_command_mode) {
                LOG_WARNING("Not implemented: %s", __func__);
                return ERROR_FAIL;
        }
@@ -97,7 +97,7 @@ int aice_set_command_mode(struct aice_port_s *aice,
 int aice_execute(struct aice_port_s *aice, uint32_t *instructions,
                uint32_t instruction_num)
 {
-       if (aice->port->api->execute == NULL) {
+       if (!aice->port->api->execute) {
                LOG_WARNING("Not implemented: %s", __func__);
                return ERROR_FAIL;
        }
@@ -107,7 +107,7 @@ int aice_execute(struct aice_port_s *aice, uint32_t *instructions,
 
 int aice_set_custom_srst_script(struct aice_port_s *aice, const char *script)
 {
-       if (aice->port->api->set_custom_srst_script == NULL) {
+       if (!aice->port->api->set_custom_srst_script) {
                LOG_WARNING("Not implemented: %s", __func__);
                return ERROR_FAIL;
        }
@@ -117,7 +117,7 @@ int aice_set_custom_srst_script(struct aice_port_s *aice, const char *script)
 
 int aice_set_custom_trst_script(struct aice_port_s *aice, const char *script)
 {
-       if (aice->port->api->set_custom_trst_script == NULL) {
+       if (!aice->port->api->set_custom_trst_script) {
                LOG_WARNING("Not implemented: %s", __func__);
                return ERROR_FAIL;
        }
@@ -127,7 +127,7 @@ int aice_set_custom_trst_script(struct aice_port_s *aice, const char *script)
 
 int aice_set_custom_restart_script(struct aice_port_s *aice, const char *script)
 {
-       if (aice->port->api->set_custom_restart_script == NULL) {
+       if (!aice->port->api->set_custom_restart_script) {
                LOG_WARNING("Not implemented: %s", __func__);
                return ERROR_FAIL;
        }
@@ -137,7 +137,7 @@ int aice_set_custom_restart_script(struct aice_port_s *aice, const char *script)
 
 int aice_set_count_to_check_dbger(struct aice_port_s *aice, uint32_t count_to_check)
 {
-       if (aice->port->api->set_count_to_check_dbger == NULL) {
+       if (!aice->port->api->set_count_to_check_dbger) {
                LOG_WARNING("Not implemented: %s", __func__);
                return ERROR_FAIL;
        }
@@ -148,7 +148,7 @@ int aice_set_count_to_check_dbger(struct aice_port_s *aice, uint32_t count_to_ch
 int aice_profiling(struct aice_port_s *aice, uint32_t interval, uint32_t iteration,
                uint32_t reg_no, uint32_t *samples, uint32_t *num_samples)
 {
-       if (aice->port->api->profiling == NULL) {
+       if (!aice->port->api->profiling) {
                LOG_WARNING("Not implemented: %s", __func__);
                return ERROR_FAIL;
        }
index b93e5494a859e5b9d7ce17af1b43b211c13123a2..24fb79ccf0ec0fc7ca6c1cc3069bf2602145e92c 100644 (file)
@@ -4409,7 +4409,7 @@ void riscv013_clear_abstract_error(struct target *target)
 #define COMPLIANCE_TEST(b, message) \
 { \
        const char *last_sep = strrchr(__FILE__, FILE_SEP); \
-       const char *fname = (last_sep == NULL ? __FILE__ : last_sep + 1); \
+       const char *fname = (!last_sep ? __FILE__ : last_sep + 1); \
        LOG_INFO("Executing test %d (%s:%d): %s", total_tests, fname, __LINE__, message); \
        int pass = 0;               \
        if (b) {                    \
index 74d59d2d76d16dbec4cf265c7c6868ff7152dd20..8f1f398b3ea708b8319e1a3c1e06f2224a4a75c3 100644 (file)
@@ -2053,7 +2053,7 @@ int riscv_openocd_poll(struct target *target)
                unsigned should_remain_halted = 0;
                unsigned should_resume = 0;
                unsigned i = 0;
-               for (struct target_list *list = target->head; list != NULL;
+               for (struct target_list *list = target->head; list;
                                list = list->next, i++) {
                        total_targets++;
                        struct target *t = list->target;
@@ -3059,7 +3059,7 @@ int riscv_count_harts(struct target *target)
        if (!target)
                return 1;
        RISCV_INFO(r);
-       if (r == NULL || r->hart_count == NULL)
+       if (!r || !r->hart_count)
                return 1;
        return r->hart_count(target);
 }
index fa639038d1dadab416e2079a3f51afaf9d6cc589..5c96e1cd666236061eda2c078142c9e81258f48b 100644 (file)
@@ -516,7 +516,7 @@ int semihosting_common(struct target *target)
                                uint64_t addr = semihosting_get_field(target, 0, fields);
                                size_t size = semihosting_get_field(target, 1, fields);
 
-                               char *arg = semihosting->cmdline != NULL ?
+                               char *arg = semihosting->cmdline ?
                                        semihosting->cmdline : "";
                                uint32_t len = strlen(arg) + 1;
                                if (len > size)
index 9a476cbf2e968958375fde371234676313874e4a..686aa5157f21af4f4331243c2bf1d17860e743d9 100644 (file)
@@ -1397,7 +1397,7 @@ int target_hit_watchpoint(struct target *target,
                return ERROR_TARGET_NOT_HALTED;
        }
 
-       if (target->type->hit_watchpoint == NULL) {
+       if (!target->type->hit_watchpoint) {
                /* For backward compatible, if hit_watchpoint is not implemented,
                 * return ERROR_FAIL such that gdb_server will not take the nonsense
                 * information. */
@@ -1409,7 +1409,7 @@ int target_hit_watchpoint(struct target *target,
 
 const char *target_get_gdb_arch(struct target *target)
 {
-       if (target->type->get_gdb_arch == NULL)
+       if (!target->type->get_gdb_arch)
                return NULL;
        return target->type->get_gdb_arch(target);
 }
@@ -1573,19 +1573,19 @@ static int target_init_one(struct command_context *cmd_ctx,
                type->virt2phys = identity_virt2phys;
        }
 
-       if (target->type->read_buffer == NULL)
+       if (!target->type->read_buffer)
                target->type->read_buffer = target_read_buffer_default;
 
-       if (target->type->write_buffer == NULL)
+       if (!target->type->write_buffer)
                target->type->write_buffer = target_write_buffer_default;
 
-       if (target->type->get_gdb_fileio_info == NULL)
+       if (!target->type->get_gdb_fileio_info)
                target->type->get_gdb_fileio_info = target_get_gdb_fileio_info_default;
 
-       if (target->type->gdb_fileio_end == NULL)
+       if (!target->type->gdb_fileio_end)
                target->type->gdb_fileio_end = target_gdb_fileio_end_default;
 
-       if (target->type->profiling == NULL)
+       if (!target->type->profiling)
                target->type->profiling = target_profiling_default;
 
        return ERROR_OK;
@@ -2120,7 +2120,7 @@ static int target_restore_working_area(struct target *target, struct working_are
 {
        int retval = ERROR_OK;
 
-       if (target->backup_working_area && area->backup != NULL) {
+       if (target->backup_working_area && area->backup) {
                retval = target_write_memory(target, area->address, 4, area->size / 4, area->backup);
                if (retval != ERROR_OK)
                        LOG_ERROR("failed to restore %" PRIu32 " bytes of working area at address " TARGET_ADDR_FMT,
@@ -2555,7 +2555,7 @@ int target_blank_check_memory(struct target *target,
                return ERROR_FAIL;
        }
 
-       if (target->type->blank_check_memory == NULL)
+       if (!target->type->blank_check_memory)
                return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
 
        return target->type->blank_check_memory(target, blocks, num_blocks, erased_value);
@@ -3976,7 +3976,7 @@ static int handle_bp_command_set(struct command_invocation *cmd,
                        command_print(cmd, "breakpoint set at " TARGET_ADDR_FMT "", addr);
 
        } else if (addr == 0) {
-               if (target->type->add_context_breakpoint == NULL) {
+               if (!target->type->add_context_breakpoint) {
                        LOG_ERROR("Context breakpoint not available");
                        return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
                }
@@ -3986,7 +3986,7 @@ static int handle_bp_command_set(struct command_invocation *cmd,
                        command_print(cmd, "Context breakpoint set at 0x%8.8" PRIx32 "", asid);
 
        } else {
-               if (target->type->add_hybrid_breakpoint == NULL) {
+               if (!target->type->add_hybrid_breakpoint) {
                        LOG_ERROR("Hybrid breakpoint not available");
                        return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
                }
@@ -4791,7 +4791,7 @@ void target_handle_event(struct target *target, enum target_event e)
        struct target_event_action *teap;
        int retval;
 
-       for (teap = target->event_action; teap != NULL; teap = teap->next) {
+       for (teap = target->event_action; teap; teap = teap->next) {
                if (teap->event == e) {
                        LOG_DEBUG("target(%d): %s (%s) event: %d (%s) action: %s",
                                           target->target_number,
@@ -4839,7 +4839,7 @@ bool target_has_event_action(struct target *target, enum target_event event)
 {
        struct target_event_action *teap;
 
-       for (teap = target->event_action; teap != NULL; teap = teap->next) {
+       for (teap = target->event_action; teap; teap = teap->next) {
                if (teap->event == event)
                        return true;
        }
@@ -5729,7 +5729,7 @@ static int target_create(struct jim_getopt_info *goi)
                        break;
                }
        }
-       if (target_types[x] == NULL) {
+       if (!target_types[x]) {
                Jim_SetResultFormatted(goi->interp, "Unknown target type %s, try one of ", cp);
                for (x = 0 ; target_types[x] ; x++) {
                        if (target_types[x + 1]) {
@@ -6154,7 +6154,7 @@ COMMAND_HANDLER(handle_fast_load_image_command)
 
                        fastload[i].address = image.sections[i].base_address + offset;
                        fastload[i].data = malloc(length);
-                       if (fastload[i].data == NULL) {
+                       if (!fastload[i].data) {
                                free(buffer);
                                command_print(CMD, "error allocating buffer for section (%" PRIu32 " bytes)",
                                                          length);
index cf588f49fc9f735044a69e752e97a88687148d6b..bea9346e10ef6e6525fcc6ed9dfbd8df1e6e3c94 100644 (file)
@@ -234,7 +234,7 @@ int delete_debug_msg_receiver(struct command_context *cmd_ctx, struct target *ta
                        if (c->cmd_ctx == cmd_ctx) {
                                *p = next;
                                free(c);
-                               if (*p == NULL) {
+                               if (!*p) {
                                        /* disable callback */
                                        target->dbg_msg_enabled = 0;
                                }
@@ -256,7 +256,7 @@ COMMAND_HANDLER(handle_target_request_debugmsgs_command)
 
        int receiving = 0;
 
-       if (target->type->target_request_data == NULL) {
+       if (!target->type->target_request_data) {
                LOG_ERROR("Target %s does not support target requests", target_name(target));
                return ERROR_OK;
        }
index 0d1518ce40a144cd3b82c45ca5438633a563b3a7..a009bfe92fcda8d4ed4243b4fe2607ad82cd575a 100644 (file)
@@ -75,7 +75,7 @@ int x86_32_get_gdb_reg_list(struct target *t,
        *reg_list_size = x86_32->cache->num_regs;
        LOG_DEBUG("num_regs=%d, reg_class=%d", (*reg_list_size), reg_class);
        *reg_list = malloc(sizeof(struct reg *) * (*reg_list_size));
-       if (*reg_list == NULL) {
+       if (!*reg_list) {
                LOG_ERROR("%s out of memory", __func__);
                return ERROR_FAIL;
        }
@@ -258,7 +258,7 @@ int x86_32_common_write_phys_mem(struct target *t, target_addr_t phys_address,
 
                        /* update the breakpoint */
                        struct breakpoint *pbiter = t->breakpoints;
-                       while (pbiter != NULL && pbiter->unique_id != iter->swbp_unique_id)
+                       while (pbiter && pbiter->unique_id != iter->swbp_unique_id)
                                pbiter = pbiter->next;
                        if (pbiter)
                                pbiter->orig_instr[0] = buffer[offset];
@@ -456,7 +456,7 @@ int calcaddr_physfromlin(struct target *t, target_addr_t addr, target_addr_t *ph
 {
        uint8_t entry_buffer[8];
 
-       if (physaddr == NULL || t == NULL)
+       if (!physaddr || !t)
                return ERROR_FAIL;
 
        struct x86_32_common *x86_32 = target_to_x86_32(t);
@@ -1113,7 +1113,7 @@ static int unset_swbp(struct target *t, struct breakpoint *bp)
                        x86_32->swbbp_mem_patch_list = iter->next;
                        free(iter);
                } else {
-                       while (iter->next != NULL && iter->next->swbp_unique_id != bp->unique_id)
+                       while (iter->next && iter->next->swbp_unique_id != bp->unique_id)
                                iter = iter->next;
                        if (iter->next) {
                                /* it's the next one */
index 5ec8b875458849e2af084e6b78ec37a84c93939b..ba1af339897babf44432b8c66e3821d2774a9d23 100644 (file)
@@ -106,7 +106,7 @@ int allow_transports(struct command_context *ctx, const char * const *vector)
         * of one transport; C code should be definitive about what
         * can be used when all goes well.
         */
-       if (allowed_transports != NULL || session) {
+       if (allowed_transports || session) {
                LOG_ERROR("Can't modify the set of allowed transports.");
                return ERROR_FAIL;
        }