openocd: fix simple cases of NULL comparison
authorAntonio Borneo <borneo.antonio@gmail.com>
Sat, 3 Jul 2021 16:51:20 +0000 (18:51 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 24 Jul 2021 09:37:49 +0000 (10:37 +0100)
There are more than 1000 NULL comparisons to be aligned to the
coding style.
For recurrent NULL comparison it's preferable using trivial
scripts in order to minimize the review effort.

Patch generated automatically with the command:
sed -i PATTERN $(find src/ -type f)
where PATTERN is in the list:
's/(\([a-z][a-z0-9_]*\) == NULL)/(!\1)/g'
's/(\([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\) == NULL)/(!\1)/g'
's/(\([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\) == NULL)/(!\1)/g'

's/(\([a-z][a-z0-9_]*\) != NULL)/(\1)/g'
's/(\([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\) != NULL)/(\1)/g'
's/(\([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\) != NULL)/(\1)/g'

's/(NULL == \([a-z][a-z0-9_]*\))/(!\1)/g'
's/(NULL == \([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\))/(!\1)/g'
's/(NULL == \([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\))/(!\1)/g'

's/(NULL != \([a-z][a-z0-9_]*\))/(\1)/g'
's/(NULL != \([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\))/(\1)/g'
's/(NULL != \([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\))/(\1)/g'

Change-Id: Ida103e325d6d0600fb69c0b7a1557ee969db4417
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6350
Tested-by: jenkins
166 files changed:
src/flash/common.c
src/flash/nand/davinci.c
src/flash/nand/fileio.c
src/flash/nand/mx3.c
src/flash/nand/mxc.c
src/flash/nand/s3c24xx.c
src/flash/nand/tcl.c
src/flash/nor/at91sam3.c
src/flash/nor/at91sam4.c
src/flash/nor/at91samd.c
src/flash/nor/atsame5.c
src/flash/nor/avrf.c
src/flash/nor/bluenrg-x.c
src/flash/nor/cc26xx.c
src/flash/nor/cc3220sf.c
src/flash/nor/cfi.c
src/flash/nor/core.c
src/flash/nor/efm32.c
src/flash/nor/faux.c
src/flash/nor/fespi.c
src/flash/nor/jtagspi.c
src/flash/nor/kinetis.c
src/flash/nor/kinetis_ke.c
src/flash/nor/lpcspifi.c
src/flash/nor/mdr.c
src/flash/nor/mrvlqspi.c
src/flash/nor/msp432.c
src/flash/nor/niietcm4.c
src/flash/nor/nrf5.c
src/flash/nor/numicro.c
src/flash/nor/pic32mx.c
src/flash/nor/psoc4.c
src/flash/nor/psoc5lp.c
src/flash/nor/sfdp.c
src/flash/nor/sim3x.c
src/flash/nor/stm32f1x.c
src/flash/nor/stm32f2x.c
src/flash/nor/stm32h7x.c
src/flash/nor/stm32l4x.c
src/flash/nor/stm32lx.c
src/flash/nor/stmqspi.c
src/flash/nor/stmsmi.c
src/flash/nor/str9xpec.c
src/flash/nor/tcl.c
src/flash/nor/virtual.c
src/flash/nor/xcf.c
src/flash/nor/xmc4xxx.c
src/helper/command.c
src/helper/configuration.c
src/helper/jim-nvp.c
src/helper/log.c
src/helper/options.c
src/helper/replacements.c
src/jtag/aice/aice_transport.c
src/jtag/aice/aice_usb.c
src/jtag/commands.c
src/jtag/core.c
src/jtag/drivers/arm-jtag-ew.c
src/jtag/drivers/bitq.c
src/jtag/drivers/buspirate.c
src/jtag/drivers/cmsis_dap.c
src/jtag/drivers/cmsis_dap_usb_bulk.c
src/jtag/drivers/cmsis_dap_usb_hid.c
src/jtag/drivers/driver.c
src/jtag/drivers/ft232r.c
src/jtag/drivers/ftdi.c
src/jtag/drivers/jlink.c
src/jtag/drivers/jtag_dpi.c
src/jtag/drivers/jtag_usb_common.c
src/jtag/drivers/kitprog.c
src/jtag/drivers/libusb_helper.c
src/jtag/drivers/linuxgpiod.c
src/jtag/drivers/mpsse.c
src/jtag/drivers/opendous.c
src/jtag/drivers/openjtag.c
src/jtag/drivers/parport.c
src/jtag/drivers/presto.c
src/jtag/drivers/remote_bitbang.c
src/jtag/drivers/rlink.c
src/jtag/drivers/stlink_usb.c
src/jtag/drivers/ti_icdi_usb.c
src/jtag/drivers/ulink.c
src/jtag/drivers/versaloon/usbtoxxx/usbtoswd.c
src/jtag/drivers/versaloon/usbtoxxx/usbtoxxx.c
src/jtag/drivers/versaloon/versaloon.c
src/jtag/drivers/vsllink.c
src/jtag/drivers/xds110.c
src/jtag/hla/hla_interface.c
src/jtag/hla/hla_layout.c
src/jtag/tcl.c
src/pld/virtex2.c
src/pld/xilinx_bit.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/server.c
src/server/tcl_server.c
src/server/telnet_server.c
src/svf/svf.c
src/target/aarch64.c
src/target/adi_v5_jtag.c
src/target/adi_v5_swd.c
src/target/arc.c
src/target/arm.h
src/target/arm11.c
src/target/arm11_dbgtap.c
src/target/arm7_9_common.c
src/target/arm920t.c
src/target/arm_adi_v5.c
src/target/arm_adi_v5.h
src/target/arm_cti.c
src/target/arm_dap.c
src/target/arm_dpm.c
src/target/arm_jtag.c
src/target/arm_tpiu_swo.c
src/target/armv4_5.c
src/target/armv7a.c
src/target/armv7a_mmu.c
src/target/armv7m.c
src/target/armv8.c
src/target/armv8_dpm.c
src/target/avr32_jtag.c
src/target/avrt.c
src/target/breakpoints.c
src/target/cortex_a.c
src/target/cortex_m.c
src/target/dsp5680xx.c
src/target/esirisc.c
src/target/esirisc_trace.c
src/target/etb.c
src/target/etm.c
src/target/hla_target.c
src/target/image.c
src/target/lakemont.c
src/target/mem_ap.c
src/target/mips32_pracc.c
src/target/mips64_pracc.c
src/target/mips_ejtag.c
src/target/mips_m4k.c
src/target/nds32.c
src/target/nds32.h
src/target/nds32_cmd.c
src/target/openrisc/or1k.c
src/target/openrisc/or1k_du_adv.c
src/target/quark_d20xx.c
src/target/riscv/batch.c
src/target/riscv/riscv.c
src/target/semihosting_common.c
src/target/smp.h
src/target/target.c
src/target/target_request.c
src/target/x86_32_common.c
src/target/xscale.c
src/transport/transport.c
src/xsvf/xsvf.c

index e8e795a4e2dcb99189316723057aab55d59f1c7e..0e7fe13ab1657149d5ad3879689c18c013768098 100644 (file)
@@ -25,7 +25,7 @@
 unsigned get_flash_name_index(const char *name)
 {
        const char *name_index = strrchr(name, '.');
-       if (NULL == name_index)
+       if (!name_index)
                return 0;
        if (name_index[1] < '0' || name_index[1] > '9')
                return ~0U;
index 167b40150406c97c118a8b18255d4a71f4ccd3e3..84f8e3480650da74b3e1f99bcc590ba7fdef673e 100644 (file)
@@ -731,7 +731,7 @@ NAND_DEVICE_COMMAND_HANDLER(davinci_nand_device_command)
        }
 
        info = calloc(1, sizeof(*info));
-       if (info == NULL)
+       if (!info)
                goto fail;
 
        info->eccmode = eccmode;
index 5504841b544a5a71deef2082ce075b7857168d22..49db112e2d62711a1818b452fe4b6ecab4951780 100644 (file)
@@ -65,7 +65,7 @@ int nand_fileio_start(struct command_invocation *cmd,
 
        duration_start(&state->bench);
 
-       if (NULL != filename) {
+       if (filename) {
                int retval = fileio_open(&state->fileio, filename, filemode, FILEIO_BINARY);
                if (retval != ERROR_OK) {
                        const char *msg = (filemode == FILEIO_READ) ? "read" : "write";
@@ -127,7 +127,7 @@ COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state,
        if (retval != ERROR_OK)
                return retval;
 
-       if (NULL == nand->device) {
+       if (!nand->device) {
                command_print(CMD, "#%s: not probed", CMD_ARGV[0]);
                return ERROR_NAND_DEVICE_NOT_PROBED;
        }
@@ -184,7 +184,7 @@ int nand_fileio_read(struct nand_device *nand, struct nand_fileio_state *s)
        size_t total_read = 0;
        size_t one_read;
 
-       if (NULL != s->page) {
+       if (s->page) {
                fileio_read(s->fileio, s->page_size, s->page, &one_read);
                if (one_read < s->page_size)
                        memset(s->page + one_read, 0xff, s->page_size - one_read);
@@ -213,7 +213,7 @@ int nand_fileio_read(struct nand_device *nand, struct nand_fileio_state *s)
                        nand_calculate_ecc_kw(nand, s->page + i, ecc);
                        ecc += 10;
                }
-       } else if (NULL != s->oob)   {
+       } else if (s->oob)   {
                fileio_read(s->fileio, s->oob_size, s->oob, &one_read);
                if (one_read < s->oob_size)
                        memset(s->oob + one_read, 0xff, s->oob_size - one_read);
index b9f5ff1b9f1673d6e52ae47fcb82420f4ad0ad06..dc8d619a06a7695f240b3d46b32378bb5d4e17c5 100644 (file)
@@ -64,7 +64,7 @@ NAND_DEVICE_COMMAND_HANDLER(imx31_nand_device_command)
 {
        struct mx3_nf_controller *mx3_nf_info;
        mx3_nf_info = malloc(sizeof(struct mx3_nf_controller));
-       if (mx3_nf_info == NULL) {
+       if (!mx3_nf_info) {
                LOG_ERROR("no memory for nand controller");
                return ERROR_FAIL;
        }
index 1fe7d30d20476bd9174affab819095f3d6023e87..7aac7216380fbd991812abbdaa1c4b4b7f776e14 100644 (file)
@@ -89,7 +89,7 @@ NAND_DEVICE_COMMAND_HANDLER(mxc_nand_device_command)
        int hwecc_needed;
 
        mxc_nf_info = malloc(sizeof(struct mxc_nf_controller));
-       if (mxc_nf_info == NULL) {
+       if (!mxc_nf_info) {
                LOG_ERROR("no memory for nand controller");
                return ERROR_FAIL;
        }
index ae3f137371d70eba962da54724d29c391b272d60..c0471eddfd1b5bdc631c0676d39136abcaac86fd 100644 (file)
@@ -34,7 +34,7 @@ S3C24XX_DEVICE_COMMAND()
 
        struct s3c24xx_nand_controller *s3c24xx_info;
        s3c24xx_info = malloc(sizeof(struct s3c24xx_nand_controller));
-       if (s3c24xx_info == NULL) {
+       if (!s3c24xx_info) {
                LOG_ERROR("no memory for nand controller");
                return -ENOMEM;
        }
index cbc51b8d1515720dd7e4fb676be6c736b65ebffb..6707314ccc824d3c87caebf02107c8b663aaa57c 100644 (file)
@@ -86,7 +86,7 @@ COMMAND_HANDLER(handle_nand_info_command)
        if (retval != ERROR_OK)
                return retval;
 
-       if (NULL == p->device) {
+       if (!p->device) {
                command_print(CMD, "#%s: not probed", CMD_ARGV[0]);
                return ERROR_OK;
        }
@@ -359,10 +359,10 @@ COMMAND_HANDLER(handle_nand_dump_command)
                        return retval;
                }
 
-               if (NULL != s.page)
+               if (s.page)
                        fileio_write(s.fileio, s.page_size, s.page, &size_written);
 
-               if (NULL != s.oob)
+               if (s.oob)
                        fileio_write(s.fileio, s.oob_size, s.oob, &size_written);
 
                s.size -= nand->page_size;
@@ -391,7 +391,7 @@ COMMAND_HANDLER(handle_nand_raw_access_command)
        if (retval != ERROR_OK)
                return retval;
 
-       if (NULL == p->device) {
+       if (!p->device) {
                command_print(CMD, "#%s: not probed", CMD_ARGV[0]);
                return ERROR_OK;
        }
@@ -527,14 +527,14 @@ static COMMAND_HELPER(create_nand_device, const char *bank_name,
                return ERROR_COMMAND_ARGUMENT_INVALID;
        }
 
-       if (NULL != controller->commands) {
+       if (controller->commands) {
                retval = register_commands(CMD_CTX, NULL,
                                controller->commands);
                if (retval != ERROR_OK)
                        return retval;
        }
        c = malloc(sizeof(struct nand_device));
-       if (c == NULL) {
+       if (!c) {
                LOG_ERROR("End of memory");
                return ERROR_FAIL;
        }
@@ -560,7 +560,7 @@ static COMMAND_HELPER(create_nand_device, const char *bank_name,
                return retval;
        }
 
-       if (controller->usage == NULL)
+       if (!controller->usage)
                LOG_DEBUG("'%s' driver usage field missing", controller->name);
 
        nand_device_add(c);
@@ -580,7 +580,7 @@ COMMAND_HANDLER(handle_nand_device_command)
        const char *driver_name = CMD_ARGV[0];
        struct nand_flash_controller *controller;
        controller = nand_driver_find_by_name(CMD_ARGV[0]);
-       if (NULL == controller) {
+       if (!controller) {
                LOG_ERROR("No valid NAND flash driver found (%s)", driver_name);
                return CALL_COMMAND_HANDLER(handle_nand_list_drivers);
        }
index 4a7c1cdab33a7f6d34413e501a19bedb1cd4c9d0..3f36af211623b19521a83e01d634659d31333a38 100644 (file)
@@ -2810,7 +2810,7 @@ static struct sam3_chip *target2sam3(struct target *target)
 {
        struct sam3_chip *chip;
 
-       if (target == NULL)
+       if (!target)
                return NULL;
 
        chip = all_sam3_chips;
@@ -3126,7 +3126,7 @@ static int sam3_get_details(struct sam3_bank_private *private)
                else
                        details++;
        }
-       if (details->name == NULL) {
+       if (!details->name) {
                LOG_ERROR("SAM3 ChipID 0x%08x not found in table (perhaps you can ID this chip?)",
                        (unsigned int)(private->chip->cfg.CHIPID_CIDR));
                /* Help the victim, print details about the chip */
@@ -3207,9 +3207,9 @@ static int _sam3_probe(struct flash_bank *bank, int noise)
                }
        }
 
-       if (bank->sectors == NULL) {
+       if (!bank->sectors) {
                bank->sectors = calloc(private->nsectors, (sizeof((bank->sectors)[0])));
-               if (bank->sectors == NULL) {
+               if (!bank->sectors) {
                        LOG_ERROR("No memory!");
                        return ERROR_FAIL;
                }
index 958ec5ec0a0f5575c24197ea3aa85093d645358c..23d1c5f30f9f4bc57a613c8d64e72dc637a63fc1 100644 (file)
@@ -2318,7 +2318,7 @@ static struct sam4_chip *target2sam4(struct target *target)
 {
        struct sam4_chip *chip;
 
-       if (target == NULL)
+       if (!target)
                return NULL;
 
        chip = all_sam4_chips;
@@ -2611,7 +2611,7 @@ static int sam4_get_details(struct sam4_bank_private *private)
                else
                        details++;
        }
-       if (details->name == NULL) {
+       if (!details->name) {
                LOG_ERROR("SAM4 ChipID 0x%08x not found in table (perhaps you can ID this chip?)",
                        (unsigned int)(private->chip->cfg.CHIPID_CIDR));
                /* Help the victim, print details about the chip */
@@ -2662,7 +2662,7 @@ static int sam4_info(struct flash_bank *bank, struct command_invocation *cmd)
        int k = bank->size / 1024;
 
        private = get_sam4_bank_private(bank);
-       if (private == NULL)
+       if (!private)
                return ERROR_FAIL;
 
        command_print_sameline(cmd, "%s bank %d: %d kB at " TARGET_ADDR_FMT,
@@ -2715,9 +2715,9 @@ static int sam4_probe(struct flash_bank *bank)
                }
        }
 
-       if (bank->sectors == NULL) {
+       if (!bank->sectors) {
                bank->sectors = calloc(private->nsectors, (sizeof((bank->sectors)[0])));
-               if (bank->sectors == NULL) {
+               if (!bank->sectors) {
                        LOG_ERROR("No memory!");
                        return ERROR_FAIL;
                }
index 5fbf8bcaa83277d7cca08b8e8d640d0e0fa4aeea..ea8503967b68cb4697086d3d1ef580dcb0a16778 100644 (file)
@@ -385,7 +385,7 @@ static const struct samd_part *samd_find_part(uint32_t id)
 {
        uint8_t devsel = SAMD_GET_DEVSEL(id);
        const struct samd_family *family = samd_find_family(id);
-       if (family == NULL)
+       if (!family)
                return NULL;
 
        for (unsigned i = 0; i < family->num_parts; i++) {
@@ -452,7 +452,7 @@ static int samd_probe(struct flash_bank *bank)
        }
 
        part = samd_find_part(id);
-       if (part == NULL) {
+       if (!part) {
                LOG_ERROR("Couldn't find part corresponding to DID %08" PRIx32, id);
                return ERROR_FAIL;
        }
@@ -606,7 +606,7 @@ static int samd_get_reservedmask(struct target *target, uint64_t *mask)
        }
        const struct samd_family *family;
        family = samd_find_family(id);
-       if (family == NULL) {
+       if (!family) {
                LOG_ERROR("Couldn't determine device family");
                return ERROR_FAIL;
        }
index 50e56a72ae9f43150f5420d94674e5e6b1d6d15c..7c7e5d0f0b130a871198c29856c277c728be7407 100644 (file)
@@ -220,7 +220,7 @@ static const struct samd_part *samd_find_part(uint32_t id)
 {
        uint8_t devsel = SAMD_GET_DEVSEL(id);
        const struct samd_family *family = samd_find_family(id);
-       if (family == NULL)
+       if (!family)
                return NULL;
 
        for (unsigned i = 0; i < family->num_parts; i++) {
@@ -287,7 +287,7 @@ static int same5_probe(struct flash_bank *bank)
        }
 
        part = samd_find_part(id);
-       if (part == NULL) {
+       if (!part) {
                LOG_ERROR("Couldn't find part corresponding to DID %08" PRIx32, id);
                return ERROR_FAIL;
        }
index 51f8d47f710fb54797e5d433382c1ce170fdca72..4fa4e0d45e8bfd59853b165250e3cc16b91ff4fb 100644 (file)
@@ -332,7 +332,7 @@ static int avrf_probe(struct flash_bank *bank)
                }
        }
 
-       if (avr_info != NULL) {
+       if (avr_info) {
                free(bank->sectors);
 
                /* chip found */
@@ -398,7 +398,7 @@ static int avrf_info(struct flash_bank *bank, struct command_invocation *cmd)
                }
        }
 
-       if (avr_info != NULL) {
+       if (avr_info) {
                /* chip found */
                command_print_sameline(cmd, "%s - Rev: 0x%" PRIx32 "", avr_info->name,
                        EXTRACT_VER(device_id));
index f533d54e9c01e8804eb4f7076412b3e6ed862654..a686e83d3920ba40f4e3fa2f0fda5a0428ddbe3c 100644 (file)
@@ -94,7 +94,7 @@ FLASH_BANK_COMMAND_HANDLER(bluenrgx_flash_bank_command)
        bluenrgx_info = calloc(1, sizeof(*bluenrgx_info));
 
        /* Check allocation */
-       if (bluenrgx_info == NULL) {
+       if (!bluenrgx_info) {
                LOG_ERROR("failed to allocate bank structure");
                return ERROR_FAIL;
        }
index 250fc373d65152282c95f33c21d2c86d3e95823c..0895798d34a7127ae33777758de4e8801bebe70e 100644 (file)
@@ -140,7 +140,7 @@ static int cc26xx_init(struct flash_bank *bank)
                return retval;
 
        /* Check for working area to use for flash helper algorithm */
-       if (NULL != cc26xx_bank->working_area)
+       if (cc26xx_bank->working_area)
                target_free_working_area(target, cc26xx_bank->working_area);
        retval = target_alloc_working_area(target, cc26xx_bank->algo_working_size,
                                &cc26xx_bank->working_area);
@@ -248,7 +248,7 @@ FLASH_BANK_COMMAND_HANDLER(cc26xx_flash_bank_command)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        cc26xx_bank = malloc(sizeof(struct cc26xx_bank));
-       if (NULL == cc26xx_bank)
+       if (!cc26xx_bank)
                return ERROR_FAIL;
 
        /* Initialize private flash information */
@@ -461,7 +461,7 @@ static int cc26xx_probe(struct flash_bank *bank)
                num_sectors = max_sectors;
 
        bank->sectors = malloc(sizeof(struct flash_sector) * num_sectors);
-       if (NULL == bank->sectors)
+       if (!bank->sectors)
                return ERROR_FAIL;
 
        bank->base = CC26XX_FLASH_BASE_ADDR;
index 88604dff4315ad217fec94ad6bc4740d47ab4969..522b21a8c1e190041cccc5413ada31500e93a589 100644 (file)
@@ -93,7 +93,7 @@ FLASH_BANK_COMMAND_HANDLER(cc3220sf_flash_bank_command)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        cc3220sf_bank = malloc(sizeof(struct cc3220sf_bank));
-       if (NULL == cc3220sf_bank)
+       if (!cc3220sf_bank)
                return ERROR_FAIL;
 
        /* Initialize private flash information */
@@ -441,7 +441,7 @@ static int cc3220sf_probe(struct flash_bank *bank)
        free(bank->sectors);
 
        bank->sectors = malloc(sizeof(struct flash_sector) * num_sectors);
-       if (NULL == bank->sectors)
+       if (!bank->sectors)
                return ERROR_FAIL;
 
        bank->base = base;
index a03179aec7ad44ee4a781f91f6fc4a8d923cfe91..830d3e36942b23ad2a2a5229cbee8b16b6fe6c14 100644 (file)
@@ -426,7 +426,7 @@ static int cfi_read_intel_pri_ext(struct flash_bank *bank)
        free(cfi_info->pri_ext);
 
        pri_ext = malloc(sizeof(struct cfi_intel_pri_ext));
-       if (pri_ext == NULL) {
+       if (!pri_ext) {
                LOG_ERROR("Out of memory");
                return ERROR_FAIL;
        }
@@ -522,7 +522,7 @@ static int cfi_read_spansion_pri_ext(struct flash_bank *bank)
        free(cfi_info->pri_ext);
 
        pri_ext = malloc(sizeof(struct cfi_spansion_pri_ext));
-       if (pri_ext == NULL) {
+       if (!pri_ext) {
                LOG_ERROR("Out of memory");
                return ERROR_FAIL;
        }
@@ -624,7 +624,7 @@ static int cfi_read_atmel_pri_ext(struct flash_bank *bank)
        free(cfi_info->pri_ext);
 
        pri_ext = malloc(sizeof(struct cfi_spansion_pri_ext));
-       if (pri_ext == NULL) {
+       if (!pri_ext) {
                LOG_ERROR("Out of memory");
                return ERROR_FAIL;
        }
@@ -811,7 +811,7 @@ int cfi_flash_bank_cmd(struct flash_bank *bank, unsigned int argc, const char **
        }
 
        cfi_info = calloc(1, sizeof(struct cfi_flash_bank));
-       if (cfi_info == NULL) {
+       if (!cfi_info) {
                LOG_ERROR("No memory for flash bank info");
                return ERROR_FAIL;
        }
@@ -1488,7 +1488,7 @@ static int cfi_spansion_write_block_mips(struct flash_bank *bank, const uint8_t
 
        /* convert bus-width dependent algorithm code to correct endianness */
        target_code = malloc(target_code_size);
-       if (target_code == NULL) {
+       if (!target_code) {
                LOG_ERROR("Out of memory");
                return ERROR_FAIL;
        }
@@ -1867,7 +1867,7 @@ static int cfi_spansion_write_block(struct flash_bank *bank, const uint8_t *buff
 
        /* convert bus-width dependent algorithm code to correct endianness */
        target_code = malloc(target_code_size);
-       if (target_code == NULL) {
+       if (!target_code) {
                LOG_ERROR("Out of memory");
                return ERROR_FAIL;
        }
index 1f97cf528c81f71c324b193929bb1a4a3a7e8a84..41d2d34ef43d86ac7788619f6d03a69f5f49dd96 100644 (file)
@@ -179,7 +179,7 @@ void flash_bank_add(struct flash_bank *bank)
        if (flash_banks) {
                /* find last flash bank */
                struct flash_bank *p = flash_banks;
-               while (NULL != p->next) {
+               while (p->next) {
                        bank_num += 1;
                        p = p->next;
                }
@@ -275,7 +275,7 @@ int get_flash_bank_by_name(const char *name, struct flash_bank **bank_result)
        int retval;
 
        bank = get_flash_bank_by_name_noprobe(name);
-       if (bank != NULL) {
+       if (bank) {
                retval = bank->driver->auto_probe(bank);
 
                if (retval != ERROR_OK) {
@@ -293,7 +293,7 @@ int get_flash_bank_by_num(unsigned int num, struct flash_bank **bank)
        struct flash_bank *p = get_flash_bank_by_num_noprobe(num);
        int retval;
 
-       if (p == NULL)
+       if (!p)
                return ERROR_FAIL;
 
        retval = p->driver->auto_probe(p);
@@ -400,7 +400,7 @@ int default_flash_blank_check(struct flash_bank *bank)
 
        struct target_memory_check_block *block_array;
        block_array = malloc(bank->num_sectors * sizeof(struct target_memory_check_block));
-       if (block_array == NULL)
+       if (!block_array)
                return default_flash_mem_blank_check(bank);
 
        for (unsigned int i = 0; i < bank->num_sectors; i++) {
@@ -791,7 +791,7 @@ int flash_write_unlock_verify(struct target *target, struct image *image,
                retval = get_flash_bank_by_addr(target, run_address, false, &c);
                if (retval != ERROR_OK)
                        goto done;
-               if (c == NULL) {
+               if (!c) {
                        LOG_WARNING("no flash bank found for address " TARGET_ADDR_FMT, run_address);
                        section++;      /* and skip it */
                        section_offset = 0;
@@ -903,7 +903,7 @@ int flash_write_unlock_verify(struct target *target, struct image *image,
 
                /* allocate buffer */
                buffer = malloc(run_size);
-               if (buffer == NULL) {
+               if (!buffer) {
                        LOG_ERROR("Out of memory for flash bank buffer");
                        retval = ERROR_FAIL;
                        goto done;
@@ -989,7 +989,7 @@ int flash_write_unlock_verify(struct target *target, struct image *image,
                        goto done;
                }
 
-               if (written != NULL)
+               if (written)
                        *written += run_size;   /* add run size to total written counter */
        }
 
@@ -1010,7 +1010,7 @@ struct flash_sector *alloc_block_array(uint32_t offset, uint32_t size,
                unsigned int num_blocks)
 {
        struct flash_sector *array = calloc(num_blocks, sizeof(struct flash_sector));
-       if (array == NULL)
+       if (!array)
                return NULL;
 
        for (unsigned int i = 0; i < num_blocks; i++) {
index f461956c10d242298a876118bc26f3a189219fc3..c8ce90866e6c94c0c4cfd1153d936f4a5e8084a4 100644 (file)
@@ -271,7 +271,7 @@ static int efm32x_read_info(struct flash_bank *bank,
                        efm32_info->family_data = &efm32_families[i];
        }
 
-       if (efm32_info->family_data == NULL) {
+       if (!efm32_info->family_data) {
                LOG_ERROR("Unknown MCU family %d", efm32_info->part_family);
                return ERROR_FAIL;
        }
@@ -885,7 +885,7 @@ static int efm32x_write(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t old_count = count;
                count = (old_count | 3) + 1;
                new_buffer = malloc(count);
-               if (new_buffer == NULL) {
+               if (!new_buffer) {
                        LOG_ERROR("odd number of bytes to write and no memory "
                                "for padding buffer");
                        return ERROR_FAIL;
@@ -1016,7 +1016,7 @@ static int efm32x_protect_check(struct flash_bank *bank)
                return ret;
        }
 
-       assert(NULL != bank->sectors);
+       assert(bank->sectors);
 
        for (unsigned int i = 0; i < bank->num_sectors; i++)
                bank->sectors[i].is_protected = efm32x_get_page_lock(bank, i);
index aaa219502daa3753f3c4df0eb27c8cc6eec912b2..7646e4b1d0569f1cf93f33361422fb996af0d563 100644 (file)
@@ -43,12 +43,12 @@ FLASH_BANK_COMMAND_HANDLER(faux_flash_bank_command)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        info = malloc(sizeof(struct faux_flash_bank));
-       if (info == NULL) {
+       if (!info) {
                LOG_ERROR("no memory for flash bank info");
                return ERROR_FAIL;
        }
        info->memory = malloc(bank->size);
-       if (info->memory == NULL) {
+       if (!info->memory) {
                free(info);
                LOG_ERROR("no memory for flash bank info");
                return ERROR_FAIL;
@@ -68,7 +68,7 @@ FLASH_BANK_COMMAND_HANDLER(faux_flash_bank_command)
        }
 
        info->target = get_target(CMD_ARGV[5]);
-       if (info->target == NULL) {
+       if (!info->target) {
                LOG_ERROR("target '%s' not defined", CMD_ARGV[5]);
                free(info->memory);
                free(info);
index 0a14c5092fb394873200608232136308414e3c5e..99ec67d304d9eec3ed44ac5410813b22649634de 100644 (file)
@@ -151,7 +151,7 @@ FLASH_BANK_COMMAND_HANDLER(fespi_flash_bank_command)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        fespi_info = malloc(sizeof(struct fespi_flash_bank));
-       if (fespi_info == NULL) {
+       if (!fespi_info) {
                LOG_ERROR("not enough memory");
                return ERROR_FAIL;
        }
@@ -986,7 +986,7 @@ static int fespi_probe(struct flash_bank *bank)
        /* create and fill sectors array */
        bank->num_sectors = fespi_info->dev->size_in_bytes / sectorsize;
        sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
-       if (sectors == NULL) {
+       if (!sectors) {
                LOG_ERROR("not enough memory");
                return ERROR_FAIL;
        }
index f40efe84fa0d496eb98653e2b34eef996460129a..fade970afbc37c648a10772f6f2c964dc8b1298a 100644 (file)
@@ -42,7 +42,7 @@ FLASH_BANK_COMMAND_HANDLER(jtagspi_flash_bank_command)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        info = malloc(sizeof(struct jtagspi_flash_bank));
-       if (info == NULL) {
+       if (!info) {
                LOG_ERROR("no memory for flash bank info");
                return ERROR_FAIL;
        }
@@ -129,7 +129,7 @@ static int jtagspi_cmd(struct flash_bank *bank, uint8_t cmd,
        lenb = DIV_ROUND_UP(len, 8);
        data_buf = malloc(lenb);
        if (lenb > 0) {
-               if (data_buf == NULL) {
+               if (!data_buf) {
                        LOG_ERROR("no memory for spi buffer");
                        return ERROR_FAIL;
                }
@@ -211,7 +211,7 @@ static int jtagspi_probe(struct flash_bank *bank)
        /* create and fill sectors array */
        bank->num_sectors = info->dev->size_in_bytes / sectorsize;
        sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
-       if (sectors == NULL) {
+       if (!sectors) {
                LOG_ERROR("not enough memory");
                return ERROR_FAIL;
        }
index 7d45523fafc542e2812064b4fd7e9d5d8aa5a08d..c99f881e8ad11ea28a7d771479f062572aaf9397 100644 (file)
@@ -882,9 +882,9 @@ FLASH_BANK_COMMAND_HANDLER(kinetis_flash_bank_command)
 
        k_chip = kinetis_get_chip(target);
 
-       if (k_chip == NULL) {
+       if (!k_chip) {
                k_chip = calloc(sizeof(struct kinetis_chip), 1);
-               if (k_chip == NULL) {
+               if (!k_chip) {
                        LOG_ERROR("No memory");
                        return ERROR_FAIL;
                }
@@ -915,11 +915,11 @@ FLASH_BANK_COMMAND_HANDLER(kinetis_flash_bank_command)
 static void kinetis_free_driver_priv(struct flash_bank *bank)
 {
        struct kinetis_flash_bank *k_bank = bank->driver_priv;
-       if (k_bank == NULL)
+       if (!k_bank)
                return;
 
        struct kinetis_chip *k_chip = k_bank->k_chip;
-       if (k_chip == NULL)
+       if (!k_chip)
                return;
 
        k_chip->num_banks--;
@@ -985,7 +985,7 @@ static int kinetis_create_missing_banks(struct kinetis_chip *k_chip)
                }
 
                bank = calloc(sizeof(struct flash_bank), 1);
-               if (bank == NULL)
+               if (!bank)
                        return ERROR_FAIL;
 
                bank->target = k_chip->target;
@@ -1174,7 +1174,7 @@ COMMAND_HANDLER(kinetis_disable_wdog_handler)
        struct target *target = get_current_target(CMD_CTX);
        struct kinetis_chip *k_chip = kinetis_get_chip(target);
 
-       if (k_chip == NULL)
+       if (!k_chip)
                return ERROR_FAIL;
 
        if (CMD_ARGC > 0)
@@ -1428,7 +1428,7 @@ static int kinetis_fill_fcf(struct flash_bank *bank, uint8_t *fcf)
                k_bank = &(k_chip->banks[bank_idx]);
                bank_iter = k_bank->bank;
 
-               if (bank_iter == NULL) {
+               if (!bank_iter) {
                        LOG_WARNING("Missing bank %u configuration, FCF protection flags may be incomplete", bank_idx);
                        continue;
                }
@@ -1538,7 +1538,7 @@ static int kinetis_check_run_mode(struct kinetis_chip *k_chip)
        uint8_t pmstat;
        struct target *target;
 
-       if (k_chip == NULL) {
+       if (!k_chip) {
                LOG_ERROR("Chip not probed.");
                return ERROR_FAIL;
        }
@@ -1840,7 +1840,7 @@ static int kinetis_write_inner(struct flash_bank *bank, const uint8_t *buffer,
                        uint32_t old_count = count;
                        count = (old_count | 3) + 1;
                        new_buffer = malloc(count);
-                       if (new_buffer == NULL) {
+                       if (!new_buffer) {
                                LOG_ERROR("odd number of bytes to write and no memory "
                                        "for padding buffer");
                                return ERROR_FAIL;
@@ -2896,7 +2896,7 @@ COMMAND_HANDLER(kinetis_nvm_partition)
        }
        switch (sz_type) {
        case SHOW_INFO:
-               if (k_chip == NULL) {
+               if (!k_chip) {
                        LOG_ERROR("Chip not probed.");
                        return ERROR_FAIL;
                }
index 0d094b5f9eec5500e4aa9439ab313c11aa1e63e5..0b5ba12a9a7fa97dc985ee9201907b3d0e11bf0d 100644 (file)
@@ -945,7 +945,7 @@ COMMAND_HANDLER(kinetis_ke_securing_test)
        if (result != ERROR_OK)
                return result;
 
-       assert(bank != NULL);
+       assert(bank);
 
        if (target->state != TARGET_HALTED) {
                LOG_ERROR("Target not halted");
@@ -1046,7 +1046,7 @@ static int kinetis_ke_write(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t old_count = count;
                count = (old_count | 3) + 1;
                new_buffer = malloc(count);
-               if (new_buffer == NULL) {
+               if (!new_buffer) {
                        LOG_ERROR("odd number of bytes to write and no memory "
                                "for padding buffer");
                        return ERROR_FAIL;
index c99ce8d4c8305a7556774c56b2cbc5a3227bfd44..160e2dc6746c27bcd2106fd16d5b3614c448e3d2 100644 (file)
@@ -66,7 +66,7 @@ FLASH_BANK_COMMAND_HANDLER(lpcspifi_flash_bank_command)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        lpcspifi_info = malloc(sizeof(struct lpcspifi_flash_bank));
-       if (lpcspifi_info == NULL) {
+       if (!lpcspifi_info) {
                LOG_ERROR("not enough memory");
                return ERROR_FAIL;
        }
@@ -894,7 +894,7 @@ static int lpcspifi_probe(struct flash_bank *bank)
        /* create and fill sectors array */
        bank->num_sectors = lpcspifi_info->dev->size_in_bytes / sectorsize;
        sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
-       if (sectors == NULL) {
+       if (!sectors) {
                LOG_ERROR("not enough memory");
                return ERROR_FAIL;
        }
index e8484199ae3ce502502a1244469cff4605000fc6..228d4bcd5c099d4575b24a5bb9c100126f244662 100644 (file)
@@ -328,7 +328,7 @@ static int mdr_write(struct flash_bank *bank, const uint8_t *buffer,
        int rem = count % 4;
        if (rem) {
                new_buffer = malloc(count + rem);
-               if (new_buffer == NULL) {
+               if (!new_buffer) {
                        LOG_ERROR("odd number of bytes to write and no memory for padding buffer");
                        return ERROR_FAIL;
                }
index 44de98907fde1b59f66b79ccbb030a3ba67cd9d7..a752f0943c6e493b9a9671870b00cee4e3e1f648 100644 (file)
@@ -882,7 +882,7 @@ static int mrvlqspi_probe(struct flash_bank *bank)
        /* create and fill sectors array */
        bank->num_sectors = mrvlqspi_info->dev->size_in_bytes / sectorsize;
        sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
-       if (sectors == NULL) {
+       if (!sectors) {
                LOG_ERROR("not enough memory");
                return ERROR_FAIL;
        }
@@ -938,7 +938,7 @@ FLASH_BANK_COMMAND_HANDLER(mrvlqspi_flash_bank_command)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        mrvlqspi_info = malloc(sizeof(struct mrvlqspi_flash_bank));
-       if (mrvlqspi_info == NULL) {
+       if (!mrvlqspi_info) {
                LOG_ERROR("not enough memory");
                return ERROR_FAIL;
        }
index 81c94b6db034bb0d1dceef068862fcf919375217..23d4982f40e1c7e4164a81c612867871c88fa614 100644 (file)
@@ -335,7 +335,7 @@ static int msp432_init(struct flash_bank *bank)
        }
 
        /* Check for working area to use for flash helper algorithm */
-       if (NULL != msp432_bank->working_area)
+       if (msp432_bank->working_area)
                target_free_working_area(target, msp432_bank->working_area);
        retval = target_alloc_working_area(target, ALGO_WORKING_SIZE,
                                &msp432_bank->working_area);
@@ -569,7 +569,7 @@ FLASH_BANK_COMMAND_HANDLER(msp432_flash_bank_command)
 
        /* Create shared private struct for flash banks */
        msp432_bank = malloc(sizeof(struct msp432_bank));
-       if (NULL == msp432_bank)
+       if (!msp432_bank)
                return ERROR_FAIL;
 
        /* Initialize private flash information */
@@ -907,7 +907,7 @@ static int msp432_probe(struct flash_bank *bank)
 
        if (num_sectors > 0) {
                bank->sectors = malloc(sizeof(struct flash_sector) * num_sectors);
-               if (NULL == bank->sectors)
+               if (!bank->sectors)
                        return ERROR_FAIL;
        }
 
@@ -933,7 +933,7 @@ static int msp432_probe(struct flash_bank *bank)
        if (is_main && MSP432P4 == msp432_bank->family_type) {
                /* Create the info flash bank needed by MSP432P4 variants */
                struct flash_bank *info = calloc(sizeof(struct flash_bank), 1);
-               if (NULL == info)
+               if (!info)
                        return ERROR_FAIL;
 
                /* Create a name for the info bank, append "_1" to main name */
index d485694230a06ee4ec55a9e713436267b9947635..b26680383b0b04a238aa3a5ed3c7ff6d86bf31ab 100644 (file)
@@ -1394,7 +1394,7 @@ static int niietcm4_write(struct flash_bank *bank, const uint8_t *buffer,
        int rem = count % 16;
        if (rem) {
                new_buffer = malloc(count + 16 - rem);
-               if (new_buffer == NULL) {
+               if (!new_buffer) {
                        LOG_ERROR("Odd number of words to write and no memory for padding buffer");
                        return ERROR_FAIL;
                }
index 9decbea9df42e8ad53177756828c9ce4fe0e1c83..8870164d286a2fcd62ac9465abae3bbc66ea51d5 100644 (file)
@@ -293,7 +293,7 @@ static bool nrf5_bank_is_probed(const struct flash_bank *bank)
 {
        struct nrf5_bank *nbank = bank->driver_priv;
 
-       assert(nbank != NULL);
+       assert(nbank);
 
        return nbank->probed;
 }
@@ -444,7 +444,7 @@ static int nrf5_protect_check_clenr0(struct flash_bank *bank)
        struct nrf5_bank *nbank = bank->driver_priv;
        struct nrf5_info *chip = nbank->chip;
 
-       assert(chip != NULL);
+       assert(chip);
 
        res = target_read_u32(chip->target, NRF51_FICR_CLENR0,
                              &clenr0);
@@ -474,7 +474,7 @@ static int nrf5_protect_check_bprot(struct flash_bank *bank)
        struct nrf5_bank *nbank = bank->driver_priv;
        struct nrf5_info *chip = nbank->chip;
 
-       assert(chip != NULL);
+       assert(chip);
 
        static uint32_t nrf5_bprot_offsets[4] = { 0x600, 0x604, 0x610, 0x614 };
        uint32_t bprot_reg = 0;
@@ -505,7 +505,7 @@ static int nrf5_protect_check(struct flash_bank *bank)
        struct nrf5_bank *nbank = bank->driver_priv;
        struct nrf5_info *chip = nbank->chip;
 
-       assert(chip != NULL);
+       assert(chip);
 
        if (chip->features & NRF5_FEATURE_BPROT)
                return nrf5_protect_check_bprot(bank);
@@ -1133,7 +1133,7 @@ static void nrf5_free_driver_priv(struct flash_bank *bank)
 {
        struct nrf5_bank *nbank = bank->driver_priv;
        struct nrf5_info *chip = nbank->chip;
-       if (chip == NULL)
+       if (!chip)
                return;
 
        chip->refcount--;
@@ -1197,7 +1197,7 @@ FLASH_BANK_COMMAND_HANDLER(nrf5_flash_bank_command)
                nbank = &chip->bank[1];
                break;
        }
-       assert(nbank != NULL);
+       assert(nbank);
 
        chip->refcount++;
        nbank->chip = chip;
@@ -1218,7 +1218,7 @@ COMMAND_HANDLER(nrf5_handle_mass_erase_command)
        if (res != ERROR_OK)
                return res;
 
-       assert(bank != NULL);
+       assert(bank);
 
        struct nrf5_info *chip;
 
@@ -1265,7 +1265,7 @@ COMMAND_HANDLER(nrf5_handle_info_command)
        if (res != ERROR_OK)
                return res;
 
-       assert(bank != NULL);
+       assert(bank);
 
        struct nrf5_info *chip;
 
index e8e2d74a106801b5fb4edc8134c550fdbe5e3dec..ce3973b9f331a3764be399a1b8b886b018d51161 100644 (file)
@@ -1386,7 +1386,7 @@ static int numicro_writeblock(struct flash_bank *bank, const uint8_t *buffer,
        init_reg_param(&reg_params[2], "r2", 32, PARAM_OUT);    /* number of words to program */
 
        struct armv7m_common *armv7m = target_to_armv7m(target);
-       if (armv7m == NULL) {
+       if (!armv7m) {
                /* something is very wrong if armv7m is NULL */
                LOG_ERROR("unable to get armv7m target");
                return retval;
index 38f900f3e9532a9675c80e98dbaa4011f2a2db4f..5e6c99f13580081d64f990e4fe31cf9925c3a9c5 100644 (file)
@@ -515,7 +515,7 @@ static int pic32mx_write_block(struct flash_bank *bank, const uint8_t *buffer,
        uint8_t *new_buffer = NULL;
        if (row_offset && (count >= (row_size / 4))) {
                new_buffer = malloc(buffer_size);
-               if (new_buffer == NULL) {
+               if (!new_buffer) {
                        LOG_ERROR("Out of memory");
                        return ERROR_FAIL;
                }
index 28c2124221a52a9e4a9f4b1b8171fc2bd64f6286..609d3b9dd583095c938e58a88d0f87e9e17b5bd8 100644 (file)
@@ -320,7 +320,7 @@ static int psoc4_sysreq(struct flash_bank *bank, uint8_t cmd,
                    sysreq_wait_algorithm->address + sysreq_wait_algorithm->size);
 
        struct armv7m_common *armv7m = target_to_armv7m(target);
-       if (armv7m == NULL) {
+       if (!armv7m) {
                /* something is very wrong if armv7m is NULL */
                LOG_ERROR("unable to get armv7m target");
                retval = ERROR_FAIL;
@@ -576,7 +576,7 @@ static int psoc4_protect(struct flash_bank *bank, int set, unsigned int first,
        int prot_sz = num_bits / 8;
 
        sysrq_buffer = malloc(param_sz + prot_sz);
-       if (sysrq_buffer == NULL) {
+       if (!sysrq_buffer) {
                LOG_ERROR("no memory for row buffer");
                return ERROR_FAIL;
        }
@@ -658,7 +658,7 @@ static int psoc4_write(struct flash_bank *bank, const uint8_t *buffer,
                return retval;
 
        sysrq_buffer = malloc(param_sz + psoc4_info->row_size);
-       if (sysrq_buffer == NULL) {
+       if (!sysrq_buffer) {
                LOG_ERROR("no memory for row buffer");
                return ERROR_FAIL;
        }
@@ -833,7 +833,7 @@ static int psoc4_probe(struct flash_bank *bank)
        bank->size = num_rows * row_size;
        bank->num_sectors = num_rows;
        bank->sectors = alloc_block_array(0, row_size, num_rows);
-       if (bank->sectors == NULL)
+       if (!bank->sectors)
                return ERROR_FAIL;
 
        LOG_DEBUG("flash bank set %" PRIu32 " rows", num_rows);
index 6fcb7060d4ba375a957ad1becf9434785663c4b8..f383213ba6c7dab9aa5c3aef37c12e691628ae20 100644 (file)
@@ -1113,7 +1113,7 @@ static int psoc5lp_erase_check(struct flash_bank *bank)
 
        struct target_memory_check_block *block_array;
        block_array = malloc(num_sectors * sizeof(struct target_memory_check_block));
-       if (block_array == NULL)
+       if (!block_array)
                return ERROR_FAIL;
 
        for (unsigned int i = 0; i < num_sectors; i++) {
index 2183ac1f1c82617d9a916214ba0ad311dbba3aa4..88d3b96f43316b328078872b3c4c8d51f1986e45 100644 (file)
@@ -99,7 +99,7 @@ int spi_sfdp(struct flash_bank *bank, struct flash_device *dev,
        nph = ((header.revision >> 16) & 0xFF) + 1;
        LOG_DEBUG("parameter headers: %d", nph);
        pheaders = malloc(sizeof(struct sfdp_phdr) * nph);
-       if (pheaders == NULL) {
+       if (!pheaders) {
                LOG_ERROR("not enough memory");
                return ERROR_FAIL;
        }
@@ -119,7 +119,7 @@ int spi_sfdp(struct flash_bank *bank, struct flash_device *dev,
 
                /* retrieve parameter table */
                ptable = malloc(words << 2);
-               if (ptable == NULL) {
+               if (!ptable) {
                        LOG_ERROR("not enough memory");
                        retval = ERROR_FAIL;
                        goto err;
index a84fcf0e35a37153dcaf5efbc645655e2a934862..20b5e397282f8726a9c7df251684ea7148fede69 100644 (file)
@@ -511,7 +511,7 @@ static int sim3x_flash_write(struct flash_bank *bank, const uint8_t *buffer, uin
                count++;
                new_buffer = malloc(count);
 
-               if (new_buffer == NULL) {
+               if (!new_buffer) {
                        LOG_ERROR("odd number of bytes to write and no memory "
                                        "for padding buffer");
                        return ERROR_FAIL;
@@ -935,7 +935,7 @@ COMMAND_HANDLER(sim3x_mass_erase)
        struct cortex_m_common *cortex_m = target_to_cm(target);
        struct adiv5_dap *dap = cortex_m->armv7m.arm.dap;
 
-       if (dap == NULL) {
+       if (!dap) {
                /* Used debug interface doesn't support direct DAP access */
                LOG_ERROR("mass_erase can't be used by this debug interface");
                return ERROR_FAIL;
@@ -980,7 +980,7 @@ COMMAND_HANDLER(sim3x_lock)
        struct cortex_m_common *cortex_m = target_to_cm(target);
        struct adiv5_dap *dap = cortex_m->armv7m.arm.dap;
 
-       if (dap == NULL) {
+       if (!dap) {
                /* Used debug interface doesn't support direct DAP access */
                LOG_INFO("Target can't by unlocked by this debug interface");
 
@@ -1052,7 +1052,7 @@ COMMAND_HANDLER(sim3x_lock)
                LOG_ERROR("Unexpected lock word value");
 
                /* SIM3X_AP_ID_VALUE is not checked */
-               if (dap == NULL)
+               if (!dap)
                        LOG_INFO("Maybe this isn't a SiM3x MCU");
 
                return ERROR_FAIL;
index d50e0d80e4798d02c5460af0647de7b26da10e6b..afc6ec9b6c628638f3584534514ece61462b16b3 100644 (file)
@@ -561,7 +561,7 @@ static int stm32x_write(struct flash_bank *bank, const uint8_t *buffer,
         * discrete accesses. */
        if (count & 1) {
                new_buffer = malloc(count + 1);
-               if (new_buffer == NULL) {
+               if (!new_buffer) {
                        LOG_ERROR("odd number of bytes to write and no memory for padding buffer");
                        return ERROR_FAIL;
                }
@@ -1179,7 +1179,7 @@ static int get_stm32x_info(struct flash_bank *bank, struct command_invocation *c
                return ERROR_FAIL;
        }
 
-       if (rev_str != NULL)
+       if (rev_str)
                command_print_sameline(cmd, "%s - Rev: %s", device_str, rev_str);
        else
                command_print_sameline(cmd, "%s - Rev: unknown (0x%04x)", device_str, rev_id);
index 00e6be0ac1007dbcedb2a5ec040060cfbd031c2b..c5adf0926eb25be47d53d3dae607cc67edd31d17 100644 (file)
@@ -1412,7 +1412,7 @@ static int get_stm32x_info(struct flash_bank *bank, struct command_invocation *c
                return ERROR_FAIL;
        }
 
-       if (rev_str != NULL)
+       if (rev_str)
                command_print_sameline(cmd, "%s - Rev: %s", device_str, rev_str);
        else
                command_print_sameline(cmd, "%s - Rev: unknown (0x%04" PRIx16 ")", device_str, rev_id);
index 16ab6aeb7eba4286b0f6b86e59de431e421c5f3e..5c71d31f06653f30742dbc722b68846287f73571 100644 (file)
@@ -879,7 +879,7 @@ static int stm32x_probe(struct flash_bank *bank)
        bank->sectors = alloc_block_array(0, stm32x_info->part_info->page_size_kb * 1024,
                        bank->num_sectors);
 
-       if (bank->sectors == NULL) {
+       if (!bank->sectors) {
                LOG_ERROR("failed to allocate bank sectors");
                return ERROR_FAIL;
        }
@@ -896,7 +896,7 @@ static int stm32x_probe(struct flash_bank *bank)
        bank->prot_blocks = alloc_block_array(0, stm32x_info->part_info->page_size_kb * wpsn * 1024,
                        bank->num_prot_blocks);
 
-       if (bank->prot_blocks == NULL) {
+       if (!bank->prot_blocks) {
                LOG_ERROR("failed to allocate bank prot_block");
                return ERROR_FAIL;
        }
@@ -937,7 +937,7 @@ static int stm32x_get_info(struct flash_bank *bank, struct command_invocation *c
                        if (rev_id == info->revs[i].rev)
                                rev_str = info->revs[i].str;
 
-               if (rev_str != NULL) {
+               if (rev_str) {
                        command_print_sameline(cmd, "%s - Rev: %s",
                                stm32x_info->part_info->device_str, rev_str);
                } else {
index 9e460a2510db831a59c3b98247b78f11d88f9bc5..d70895c536fa0b2ce1665f4ef1dd606f908b4693 100644 (file)
@@ -1603,7 +1603,7 @@ static int stm32l4_probe(struct flash_bank *bank)
        bank->size = (flash_size_kb + gap_size_kb) * 1024;
        bank->num_sectors = num_pages;
        bank->sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
-       if (bank->sectors == NULL) {
+       if (!bank->sectors) {
                LOG_ERROR("failed to allocate bank sectors");
                return ERROR_FAIL;
        }
index e8655aa803bf481cbdaec48150f0dd4cf6e60cde..3bb986e1ca90fb22d8c1e989820d6a8ff39eca32 100644 (file)
@@ -290,7 +290,7 @@ FLASH_BANK_COMMAND_HANDLER(stm32lx_flash_bank_command)
        stm32lx_info = calloc(1, sizeof(*stm32lx_info));
 
        /* Check allocation */
-       if (stm32lx_info == NULL) {
+       if (!stm32lx_info) {
                LOG_ERROR("failed to allocate bank structure");
                return ERROR_FAIL;
        }
@@ -503,7 +503,7 @@ static int stm32lx_write_half_pages(struct flash_bank *bank, const uint8_t *buff
        }
 
        struct armv7m_common *armv7m = target_to_armv7m(target);
-       if (armv7m == NULL) {
+       if (!armv7m) {
 
                /* something is very wrong if armv7m is NULL */
                LOG_ERROR("unable to get armv7m target");
@@ -842,7 +842,7 @@ static int stm32lx_probe(struct flash_bank *bank)
        bank->base = base_address;
        bank->num_sectors = num_sectors;
        bank->sectors = malloc(sizeof(struct flash_sector) * num_sectors);
-       if (bank->sectors == NULL) {
+       if (!bank->sectors) {
                LOG_ERROR("failed to allocate bank sectors");
                return ERROR_FAIL;
        }
@@ -889,7 +889,7 @@ static int stm32lx_get_info(struct flash_bank *bank, struct command_invocation *
                if (rev_id == info->revs[i].rev)
                        rev_str = info->revs[i].str;
 
-       if (rev_str != NULL) {
+       if (rev_str) {
                command_print_sameline(cmd, "%s - Rev: %s", info->device_str, rev_str);
        } else {
                command_print_sameline(cmd, "%s - Rev: unknown (0x%04x)", info->device_str, rev_id);
index e8e0061307882a72a558b98e8841840e0ecd355f..f6a4934141b21c94f679fc716cb2d7bf6e16c470 100644 (file)
@@ -225,7 +225,7 @@ FLASH_BANK_COMMAND_HANDLER(stmqspi_flash_bank_command)
        COMMAND_PARSE_NUMBER(u32, CMD_ARGV[6], io_base);
 
        stmqspi_info = malloc(sizeof(struct stmqspi_flash_bank));
-       if (stmqspi_info == NULL) {
+       if (!stmqspi_info) {
                LOG_ERROR("not enough memory");
                return ERROR_FAIL;
        }
@@ -754,7 +754,7 @@ COMMAND_HANDLER(stmqspi_handle_set)
        bank->num_sectors =
                stmqspi_info->dev.size_in_bytes / stmqspi_info->dev.sectorsize;
        sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
-       if (sectors == NULL) {
+       if (!sectors) {
                LOG_ERROR("not enough memory");
                return ERROR_FAIL;
        }
@@ -2358,7 +2358,7 @@ static int stmqspi_probe(struct flash_bank *bank)
        /* create and fill sectors array */
        bank->num_sectors = stmqspi_info->dev.size_in_bytes / stmqspi_info->dev.sectorsize;
        sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
-       if (sectors == NULL) {
+       if (!sectors) {
                LOG_ERROR("not enough memory");
                retval = ERROR_FAIL;
                goto err;
index 662b4595353915db6e888c6d9657a04cd07be5b5..553bf2924af8c0dfdf1a465f8e0c1f552718a4c0 100644 (file)
@@ -144,7 +144,7 @@ FLASH_BANK_COMMAND_HANDLER(stmsmi_flash_bank_command)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        stmsmi_info = malloc(sizeof(struct stmsmi_flash_bank));
-       if (stmsmi_info == NULL) {
+       if (!stmsmi_info) {
                LOG_ERROR("not enough memory");
                return ERROR_FAIL;
        }
@@ -600,7 +600,7 @@ static int stmsmi_probe(struct flash_bank *bank)
        bank->num_sectors =
                stmsmi_info->dev->size_in_bytes / sectorsize;
        sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
-       if (sectors == NULL) {
+       if (!sectors) {
                LOG_ERROR("not enough memory");
                return ERROR_FAIL;
        }
index 1d9e59e822b0d45a70c9b7d6504527027f13ad15..da66a99a8213e97e51eb05e9d1a0268721d51666 100644 (file)
@@ -81,7 +81,7 @@ static int str9xpec_write_options(struct flash_bank *bank);
 
 static int str9xpec_set_instr(struct jtag_tap *tap, uint32_t new_instr, tap_state_t end_state)
 {
-       if (tap == NULL)
+       if (!tap)
                return ERROR_TARGET_INVALID;
 
        if (buf_get_u32(tap->cur_instr, 0, tap->ir_length) != new_instr) {
@@ -1043,19 +1043,19 @@ COMMAND_HANDLER(str9xpec_handle_flash_enable_turbo_command)
 
        /* remove arm core from chain - enter turbo mode */
        tap0 = str9xpec_info->tap;
-       if (tap0 == NULL) {
+       if (!tap0) {
                /* things are *WRONG* */
                command_print(CMD, "**STR9FLASH** (tap0) invalid chain?");
                return ERROR_FAIL;
        }
        tap1 = tap0->next_tap;
-       if (tap1 == NULL) {
+       if (!tap1) {
                /* things are *WRONG* */
                command_print(CMD, "**STR9FLASH** (tap1) invalid chain?");
                return ERROR_FAIL;
        }
        tap2 = tap1->next_tap;
-       if (tap2 == NULL) {
+       if (!tap2) {
                /* things are *WRONG* */
                command_print(CMD, "**STR9FLASH** (tap2) invalid chain?");
                return ERROR_FAIL;
@@ -1089,7 +1089,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_disable_turbo_command)
        str9xpec_info = bank->driver_priv;
        tap = str9xpec_info->tap;
 
-       if (tap == NULL)
+       if (!tap)
                return ERROR_FAIL;
 
        /* exit turbo mode via RESET */
index 1705384c7acbd0cad1769c4cc4f835276d821f08..d7466501782d5311066e451dd6e2f0189af804d8 100644 (file)
@@ -88,7 +88,7 @@ COMMAND_HANDLER(handle_flash_info_command)
        if (retval != ERROR_OK)
                return retval;
 
-       if (p != NULL) {
+       if (p) {
                int num_blocks;
                struct flash_sector *block_array;
 
@@ -584,7 +584,7 @@ COMMAND_HANDLER(handle_flash_fill_command)
        uint32_t padding_at_end = aligned_end - end_addr;
 
        uint8_t *buffer = malloc(aligned_size);
-       if (buffer == NULL)
+       if (!buffer)
                return ERROR_FAIL;
 
        if (padding_at_start) {
@@ -724,7 +724,7 @@ COMMAND_HANDLER(handle_flash_md_command)
        }
 
        uint8_t *buffer = calloc(count, wordsize);
-       if (buffer == NULL) {
+       if (!buffer) {
                command_print(CMD, "No memory for flash read buffer");
                return ERROR_FAIL;
        }
@@ -799,7 +799,7 @@ COMMAND_HANDLER(handle_flash_write_bank_command)
        uint32_t padding_at_end = aligned_end - end_addr;
 
        buffer = malloc(aligned_size);
-       if (buffer == NULL) {
+       if (!buffer) {
                fileio_close(fileio);
                LOG_ERROR("Out of memory");
                return ERROR_FAIL;
@@ -896,7 +896,7 @@ COMMAND_HANDLER(handle_flash_read_bank_command)
        }
 
        buffer = malloc(length);
-       if (buffer == NULL) {
+       if (!buffer) {
                LOG_ERROR("Out of memory");
                return ERROR_FAIL;
        }
@@ -990,7 +990,7 @@ COMMAND_HANDLER(handle_flash_verify_bank_command)
                        "first %zu bytes of the file", length);
 
        buffer_file = malloc(length);
-       if (buffer_file == NULL) {
+       if (!buffer_file) {
                LOG_ERROR("Out of memory");
                fileio_close(fileio);
                return ERROR_FAIL;
@@ -1011,7 +1011,7 @@ COMMAND_HANDLER(handle_flash_verify_bank_command)
        }
 
        buffer_flash = malloc(length);
-       if (buffer_flash == NULL) {
+       if (!buffer_flash) {
                LOG_ERROR("Out of memory");
                free(buffer_file);
                return ERROR_FAIL;
@@ -1262,14 +1262,14 @@ COMMAND_HANDLER(handle_flash_bank_command)
        CMD_ARGC--;
 
        struct target *target = get_target(CMD_ARGV[5]);
-       if (target == NULL) {
+       if (!target) {
                LOG_ERROR("target '%s' not defined", CMD_ARGV[5]);
                return ERROR_FAIL;
        }
 
        const char *driver_name = CMD_ARGV[0];
        const struct flash_driver *driver = flash_driver_find_by_name(driver_name);
-       if (NULL == driver) {
+       if (!driver) {
                /* no matching flash driver found */
                LOG_ERROR("flash driver '%s' not found", driver_name);
                return ERROR_FAIL;
@@ -1283,7 +1283,7 @@ COMMAND_HANDLER(handle_flash_bank_command)
        }
 
        /* register flash specific commands */
-       if (NULL != driver->commands) {
+       if (driver->commands) {
                int retval = register_commands(CMD_CTX, NULL,
                                driver->commands);
                if (retval != ERROR_OK) {
@@ -1313,7 +1313,7 @@ COMMAND_HANDLER(handle_flash_bank_command)
                return retval;
        }
 
-       if (driver->usage == NULL)
+       if (!driver->usage)
                LOG_DEBUG("'%s' driver usage field missing", driver_name);
 
        flash_bank_add(c);
index c9525d179b2d86b938a7e43a2a95d176609cc106..deab3c089554796c12dd67f067c0966dbfd506ee 100644 (file)
@@ -27,7 +27,7 @@ static struct flash_bank *virtual_get_master_bank(struct flash_bank *bank)
        struct flash_bank *master_bank;
 
        master_bank = get_flash_bank_by_name_noprobe(bank->driver_priv);
-       if (master_bank == NULL)
+       if (!master_bank)
                LOG_ERROR("master flash bank '%s' does not exist", (char *)bank->driver_priv);
 
        return master_bank;
@@ -37,7 +37,7 @@ static void virtual_update_bank_info(struct flash_bank *bank)
 {
        struct flash_bank *master_bank = virtual_get_master_bank(bank);
 
-       if (master_bank == NULL)
+       if (!master_bank)
                return;
 
        /* update the info we do not have */
@@ -64,7 +64,7 @@ FLASH_BANK_COMMAND_HANDLER(virtual_flash_bank_command)
        const char *bank_name = CMD_ARGV[6];
        struct flash_bank *master_bank = get_flash_bank_by_name_noprobe(bank_name);
 
-       if (master_bank == NULL) {
+       if (!master_bank) {
                LOG_ERROR("master flash bank '%s' does not exist", bank_name);
                return ERROR_FLASH_OPERATION_FAILED;
        }
@@ -80,7 +80,7 @@ static int virtual_protect(struct flash_bank *bank, int set, unsigned int first,
 {
        struct flash_bank *master_bank = virtual_get_master_bank(bank);
 
-       if (master_bank == NULL)
+       if (!master_bank)
                return ERROR_FLASH_OPERATION_FAILED;
 
        return flash_driver_protect(master_bank, set, first, last);
@@ -90,7 +90,7 @@ static int virtual_protect_check(struct flash_bank *bank)
 {
        struct flash_bank *master_bank = virtual_get_master_bank(bank);
 
-       if (master_bank == NULL)
+       if (!master_bank)
                return ERROR_FLASH_OPERATION_FAILED;
 
        if (master_bank->driver->protect_check == NULL)
@@ -106,7 +106,7 @@ static int virtual_erase(struct flash_bank *bank, unsigned int first,
        struct flash_bank *master_bank = virtual_get_master_bank(bank);
        int retval;
 
-       if (master_bank == NULL)
+       if (!master_bank)
                return ERROR_FLASH_OPERATION_FAILED;
 
        /* call master handler */
@@ -123,7 +123,7 @@ static int virtual_write(struct flash_bank *bank, const uint8_t *buffer,
        struct flash_bank *master_bank = virtual_get_master_bank(bank);
        int retval;
 
-       if (master_bank == NULL)
+       if (!master_bank)
                return ERROR_FLASH_OPERATION_FAILED;
 
        /* call master handler */
@@ -139,7 +139,7 @@ static int virtual_probe(struct flash_bank *bank)
        struct flash_bank *master_bank = virtual_get_master_bank(bank);
        int retval;
 
-       if (master_bank == NULL)
+       if (!master_bank)
                return ERROR_FLASH_OPERATION_FAILED;
 
        /* call master handler */
@@ -158,7 +158,7 @@ static int virtual_auto_probe(struct flash_bank *bank)
        struct flash_bank *master_bank = virtual_get_master_bank(bank);
        int retval;
 
-       if (master_bank == NULL)
+       if (!master_bank)
                return ERROR_FLASH_OPERATION_FAILED;
 
        /* call master handler */
@@ -176,7 +176,7 @@ static int virtual_info(struct flash_bank *bank, struct command_invocation *cmd)
 {
        struct flash_bank *master_bank = virtual_get_master_bank(bank);
 
-       if (master_bank == NULL)
+       if (!master_bank)
                return ERROR_FLASH_OPERATION_FAILED;
 
        command_print_sameline(cmd, "%s driver for flash bank %s at " TARGET_ADDR_FMT,
@@ -190,7 +190,7 @@ static int virtual_blank_check(struct flash_bank *bank)
        struct flash_bank *master_bank = virtual_get_master_bank(bank);
        int retval;
 
-       if (master_bank == NULL)
+       if (!master_bank)
                return ERROR_FLASH_OPERATION_FAILED;
 
        /* call master handler */
@@ -207,7 +207,7 @@ static int virtual_flash_read(struct flash_bank *bank,
        struct flash_bank *master_bank = virtual_get_master_bank(bank);
        int retval;
 
-       if (master_bank == NULL)
+       if (!master_bank)
                return ERROR_FLASH_OPERATION_FAILED;
 
        /* call master handler */
index 1a37e9c5b53fab6193a72187b51d48e7486959b2..fd31c9d145a9d32c699ad1847cf72da7e0e90c84 100644 (file)
@@ -572,7 +572,7 @@ FLASH_BANK_COMMAND_HANDLER(xcf_flash_bank_command)
        struct xcf_priv *priv;
 
        priv = malloc(sizeof(struct xcf_priv));
-       if (priv == NULL) {
+       if (!priv) {
                LOG_ERROR("no memory for flash bank info");
                return ERROR_FAIL;
        }
@@ -629,7 +629,7 @@ static int xcf_probe(struct flash_bank *bank)
        }
 
        bank->sectors = malloc(bank->num_sectors * sizeof(struct flash_sector));
-       if (bank->sectors == NULL) {
+       if (!bank->sectors) {
                LOG_ERROR("No memory for sector table");
                return ERROR_FAIL;
        }
index a2cf6a0b1e58f88b20bd4e17598c9634165a819e..04734d10f9ff0b0cbc0acbb4232508983bcab3a3 100644 (file)
@@ -941,7 +941,7 @@ static int xmc4xxx_get_info_command(struct flash_bank *bank, struct command_invo
                }
        }
 
-       if (rev_str != NULL)
+       if (rev_str)
                command_print_sameline(cmd, "%s - Rev: %s%s", dev_str, rev_str, prot_str);
        else
                command_print_sameline(cmd, "%s - Rev: unknown (0x%01x)%s", dev_str, rev_id, prot_str);
index 0c76450fa7de5ed66f42b41b76b81cf7912b8885..b3b53aebc0b0fca10a49f3b9453daae410451a5a 100644 (file)
@@ -118,7 +118,7 @@ static struct log_capture_state *command_log_capture_start(Jim_Interp *interp)
  */
 static void command_log_capture_finish(struct log_capture_state *state)
 {
-       if (NULL == state)
+       if (!state)
                return;
 
        log_remove_callback(tcl_output, state);
@@ -175,7 +175,7 @@ static int workaround_createcommand(Jim_Interp *interp, const char *cmdName,
 static int command_retval_set(Jim_Interp *interp, int retval)
 {
        int *return_retval = Jim_GetAssocData(interp, "retval");
-       if (return_retval != NULL)
+       if (return_retval)
                *return_retval = retval;
 
        return (retval == ERROR_OK) ? JIM_OK : retval;
@@ -213,7 +213,7 @@ static char **script_command_args_alloc(
        unsigned argc, Jim_Obj * const *argv, unsigned *nwords)
 {
        char **words = malloc(argc * sizeof(char *));
-       if (NULL == words)
+       if (!words)
                return NULL;
 
        unsigned i;
@@ -234,7 +234,7 @@ struct command_context *current_command_context(Jim_Interp *interp)
 {
        /* grab the command context from the associated data */
        struct command_context *cmd_ctx = Jim_GetAssocData(interp, "context");
-       if (NULL == cmd_ctx) {
+       if (!cmd_ctx) {
                /* Tcl can invoke commands directly instead of via command_run_line(). This would
                 * happen when the Jim Tcl interpreter is provided by eCos or if we are running
                 * commands in a startup script.
@@ -285,7 +285,7 @@ static struct command *command_new(struct command_context *cmd_ctx,
                        full_name);
 
        struct command *c = calloc(1, sizeof(struct command));
-       if (NULL == c)
+       if (!c)
                return NULL;
 
        c->name = strdup(cr->name);
@@ -369,16 +369,16 @@ int __register_commands(struct command_context *cmd_ctx, const char *cmd_prefix,
                const struct command_registration *cr = cmds + i;
 
                struct command *c = NULL;
-               if (NULL != cr->name) {
+               if (cr->name) {
                        c = register_command(cmd_ctx, cmd_prefix, cr);
-                       if (NULL == c) {
+                       if (!c) {
                                retval = ERROR_FAIL;
                                break;
                        }
                        c->jim_handler_data = data;
                        c->jim_override_target = override_target;
                }
-               if (NULL != cr->chain) {
+               if (cr->chain) {
                        if (cr->name) {
                                if (cmd_prefix) {
                                        char *new_prefix = alloc_printf("%s %s", cmd_prefix, cr->name);
@@ -670,7 +670,7 @@ int command_run_linef(struct command_context *context, const char *format, ...)
        va_list ap;
        va_start(ap, format);
        string = alloc_vprintf(format, ap);
-       if (string != NULL) {
+       if (string) {
                retval = command_run_line(context, string);
                free(string);
        }
@@ -696,7 +696,7 @@ struct command_context *copy_command_context(struct command_context *context)
 
 void command_done(struct command_context *cmd_ctx)
 {
-       if (NULL == cmd_ctx)
+       if (!cmd_ctx)
                return;
 
        free(cmd_ctx);
@@ -709,7 +709,7 @@ static int jim_find(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
                return JIM_ERR;
        const char *file = Jim_GetString(argv[1], NULL);
        char *full_path = find_file(file);
-       if (full_path == NULL)
+       if (!full_path)
                return JIM_ERR;
        Jim_Obj *result = Jim_NewStringObj(interp, full_path, strlen(full_path));
        free(full_path);
@@ -816,8 +816,8 @@ static COMMAND_HELPER(command_help_show, struct help_entry *c,
        /* If the match string occurs anywhere, we print out
         * stuff for this command. */
        bool is_match = (strstr(c->cmd_name, cmd_match) != NULL) ||
-               ((c->usage != NULL) && (strstr(c->usage, cmd_match) != NULL)) ||
-               ((c->help != NULL) && (strstr(c->help, cmd_match) != NULL));
+               ((c->usage) && (strstr(c->usage, cmd_match) != NULL)) ||
+               ((c->help) && (strstr(c->help, cmd_match) != NULL));
 
        if (is_match) {
                if (c->usage && strlen(c->usage) > 0) {
@@ -870,7 +870,7 @@ static COMMAND_HELPER(command_help_show, struct help_entry *c,
                } else
                        msg = alloc_printf("%s", c->help ? c->help : "");
 
-               if (NULL != msg) {
+               if (msg) {
                        command_help_show_wrap(msg, n + 3, n + 3);
                        free(msg);
                } else
@@ -899,7 +899,7 @@ COMMAND_HANDLER(handle_help_command)
                }
        }
 
-       if (cmd_match == NULL) {
+       if (!cmd_match) {
                LOG_ERROR("unable to build search string");
                return -ENOMEM;
        }
@@ -1286,7 +1286,7 @@ struct command_context *command_init(const char *startup_tcl, Jim_Interp *interp
        INIT_LIST_HEAD(context->help_list);
 
        /* Create a jim interpreter if we were not handed one */
-       if (interp == NULL) {
+       if (!interp) {
                /* Create an interpreter */
                interp = Jim_CreateInterp();
                /* Add all the Jim core commands */
index 8f4f118334f639297c41dbd088e8df4418e435af..7e791d08489740782175e47487ca2775557501f9 100644 (file)
@@ -111,7 +111,7 @@ FILE *open_file_from_path(const char *file, const char *mode)
                return fopen(file, mode);
        else {
                char *full_path = find_file(file);
-               if (full_path == NULL)
+               if (!full_path)
                        return NULL;
                FILE *fp = NULL;
                fp = fopen(full_path, mode);
@@ -150,12 +150,12 @@ char *get_home_dir(const char *append_path)
 {
        char *home = getenv("HOME");
 
-       if (home == NULL) {
+       if (!home) {
 
 #ifdef _WIN32
                home = getenv("USERPROFILE");
 
-               if (home == NULL) {
+               if (!home) {
 
                        char homepath[MAX_PATH];
                        char *drive = getenv("HOMEDRIVE");
@@ -173,7 +173,7 @@ char *get_home_dir(const char *append_path)
 #endif
        }
 
-       if (home == NULL)
+       if (!home)
                return home;
 
        char *home_path;
index 746af8e4cd6f2b9a7f2935527d6344e3bf450c46..580b079157f0b46f601c56fa0509031d60c31312 100644 (file)
@@ -199,7 +199,7 @@ int jim_getopt_obj(struct jim_getopt_info *goi, Jim_Obj **puthere)
        }
        if (puthere)
                *puthere = o;
-       if (o != NULL)
+       if (o)
                return JIM_OK;
        else
                return JIM_ERR;
@@ -227,7 +227,7 @@ int jim_getopt_double(struct jim_getopt_info *goi, double *puthere)
        Jim_Obj *o;
        double _safe;
 
-       if (puthere == NULL)
+       if (!puthere)
                puthere = &_safe;
 
        r = jim_getopt_obj(goi, &o);
@@ -245,7 +245,7 @@ int jim_getopt_wide(struct jim_getopt_info *goi, jim_wide *puthere)
        Jim_Obj *o;
        jim_wide _safe;
 
-       if (puthere == NULL)
+       if (!puthere)
                puthere = &_safe;
 
        r = jim_getopt_obj(goi, &o);
@@ -260,7 +260,7 @@ int jim_getopt_nvp(struct jim_getopt_info *goi, const struct jim_nvp *nvp, struc
        Jim_Obj *o;
        int e;
 
-       if (puthere == NULL)
+       if (!puthere)
                puthere = &_safe;
 
        e = jim_getopt_obj(goi, &o);
@@ -284,7 +284,7 @@ int jim_getopt_enum(struct jim_getopt_info *goi, const char *const *lookup, int
        Jim_Obj *o;
        int e;
 
-       if (puthere == NULL)
+       if (!puthere)
                puthere = &_safe;
        e = jim_getopt_obj(goi, &o);
        if (e == JIM_OK)
index b39cb9136ae70de8ea5c608c33e053dcaf66f1c4..a1b46efd0ee9ec2f0a797cd84864da3663c1bb49 100644 (file)
@@ -108,7 +108,7 @@ static void log_puts(enum log_levels level,
        }
 
        f = strrchr(file, '/');
-       if (f != NULL)
+       if (f)
                file = f + 1;
 
        if (strlen(string) > 0) {
@@ -163,7 +163,7 @@ void log_printf(enum log_levels level,
        va_start(ap, format);
 
        string = alloc_vprintf(format, ap);
-       if (string != NULL) {
+       if (string) {
                log_puts(level, file, line, function, string);
                free(string);
        }
@@ -240,7 +240,7 @@ COMMAND_HANDLER(handle_log_output_command)
        }
        if (CMD_ARGC == 1) {
                FILE *file = fopen(CMD_ARGV[0], "w");
-               if (file == NULL) {
+               if (!file) {
                        LOG_ERROR("failed to open output log '%s'", CMD_ARGV[0]);
                        return ERROR_FAIL;
                }
@@ -287,7 +287,7 @@ void log_init(void)
        /* set defaults for daemon configuration,
         * if not set by cmdline or cfgfile */
        char *debug_env = getenv("OPENOCD_DEBUG_LEVEL");
-       if (NULL != debug_env) {
+       if (debug_env) {
                int value;
                int retval = parse_int(debug_env, &value);
                if (retval == ERROR_OK &&
@@ -296,7 +296,7 @@ void log_init(void)
                                debug_level = value;
        }
 
-       if (log_output == NULL)
+       if (!log_output)
                log_output = stderr;
 
        start = last_time = timeval_ms();
@@ -322,7 +322,7 @@ int log_add_callback(log_callback_fn fn, void *priv)
        /* alloc memory, it is safe just to return in case of an error, no need for the caller to
         *check this */
        cb = malloc(sizeof(struct log_callback));
-       if (cb == NULL)
+       if (!cb)
                return ERROR_BUF_TOO_SMALL;
 
        /* add item to the beginning of the linked list */
@@ -367,7 +367,7 @@ char *alloc_vprintf(const char *fmt, va_list ap)
         * other code depend on that. They should be probably be fixed, but for
         * now reserve the extra byte. */
        string = malloc(len + 2);
-       if (string == NULL)
+       if (!string)
                return NULL;
 
        /* do the real work */
index f996749ea88bace77de5e2b830edd3857cb9a6ea..199672789b865e16185dfd2eee1da02df6a936b4 100644 (file)
@@ -75,7 +75,7 @@ static char *find_exe_path(void)
        do {
 #if IS_WIN32 && !IS_CYGWIN
                exepath = malloc(MAX_PATH);
-               if (exepath == NULL)
+               if (!exepath)
                        break;
                GetModuleFileName(NULL, exepath, MAX_PATH);
 
@@ -87,7 +87,7 @@ static char *find_exe_path(void)
 
 #elif IS_DARWIN
                exepath = malloc(PROC_PIDPATHINFO_MAXSIZE);
-               if (exepath == NULL)
+               if (!exepath)
                        break;
                if (proc_pidpath(getpid(), exepath, PROC_PIDPATHINFO_MAXSIZE) <= 0) {
                        free(exepath);
@@ -99,7 +99,7 @@ static char *find_exe_path(void)
 #define PATH_MAX 1024
 #endif
                char *path = malloc(PATH_MAX);
-               if (path == NULL)
+               if (!path)
                        break;
                int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
                size_t size = PATH_MAX;
@@ -117,14 +117,14 @@ static char *find_exe_path(void)
 #elif defined(HAVE_REALPATH) /* Assume POSIX.1-2008 */
                /* Try Unices in order of likelihood. */
                exepath = realpath("/proc/self/exe", NULL); /* Linux/Cygwin */
-               if (exepath == NULL)
+               if (!exepath)
                        exepath = realpath("/proc/self/path/a.out", NULL); /* Solaris */
-               if (exepath == NULL)
+               if (!exepath)
                        exepath = realpath("/proc/curproc/file", NULL); /* FreeBSD (Should be covered above) */
 #endif
        } while (0);
 
-       if (exepath != NULL) {
+       if (exepath) {
                /* Strip executable file name, leaving path */
                *strrchr(exepath, '/') = '\0';
        } else {
@@ -163,7 +163,7 @@ static char *find_relative_path(const char *from, const char *to)
                if (from[0] != '/')
                        i++;
                char *next = strchr(from, '/');
-               if (next == NULL)
+               if (!next)
                        break;
                from = next + 1;
        }
index f8989974f936143459b46b774d5c41b977b8ab00..68032b7fd5654a4ed47ea6360b05a6d35f60ff06 100644 (file)
@@ -33,7 +33,7 @@
 void *clear_malloc(size_t size)
 {
        void *t = malloc(size);
-       if (t != NULL)
+       if (t)
                memset(t, 0x00, size);
        return t;
 }
@@ -41,7 +41,7 @@ void *clear_malloc(size_t size)
 void *fill_malloc(size_t size)
 {
        void *t = malloc(size);
-       if (t != NULL) {
+       if (t) {
                /* We want to initialize memory to some known bad state.
                 * 0 and 0xff yields 0 and -1 as integers, which often
                 * have meaningful values. 0x5555... is not often a valid
@@ -124,7 +124,7 @@ char *strndup(const char *s, size_t n)
        size_t len = strnlen(s, n);
        char *new = malloc(len + 1);
 
-       if (new == NULL)
+       if (!new)
                return NULL;
 
        new[len] = '\0';
@@ -148,7 +148,7 @@ int win_select(int max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct time
 #define SAFE_FD_ISSET(fd, set)  (set != NULL && FD_ISSET(fd, set))
 
        /* calculate how long we need to wait in milliseconds */
-       if (tv == NULL)
+       if (!tv)
                ms_total = INFINITE;
        else {
                ms_total = tv->tv_sec * 1000;
index df399f816aadeef978c1e6894ee1b4806ab52e61..3e9d94219754e06f4c91937d3a75f90b8773bd66 100644 (file)
@@ -43,7 +43,7 @@ static int jim_newtap_expected_id(struct jim_nvp *n, struct jim_getopt_info *goi
 
        unsigned expected_len = sizeof(uint32_t) * tap->expected_ids_cnt;
        uint32_t *new_expected_ids = malloc(expected_len + sizeof(uint32_t));
-       if (new_expected_ids == NULL) {
+       if (!new_expected_ids) {
                Jim_SetResultFormatted(goi->interp, "no memory");
                return JIM_ERR;
        }
index f0bb6ccae51f1ef30c2a4add13c3c60eee6072e6..8d7f38bac1d0402b328062fa0851b48e620a3b21 100644 (file)
@@ -2215,24 +2215,24 @@ static int aice_execute_custom_script(const char *script)
        bool set_op;
 
        script_fd = fopen(script, "r");
-       if (script_fd == NULL) {
+       if (!script_fd) {
                return ERROR_FAIL;
        } else {
                while (fgets(line_buffer, LINE_BUFFER_SIZE, script_fd) != NULL) {
                        /* execute operations */
                        set_op = false;
                        op_str = strstr(line_buffer, "set");
-                       if (op_str != NULL) {
+                       if (op_str) {
                                set_op = true;
                                goto get_reset_type;
                        }
 
                        op_str = strstr(line_buffer, "clear");
-                       if (op_str == NULL)
+                       if (!op_str)
                                continue;
 get_reset_type:
                        reset_str = strstr(op_str, "srst");
-                       if (reset_str != NULL) {
+                       if (reset_str) {
                                if (set_op)
                                        write_ctrl_value = AICE_CUSTOM_DELAY_SET_SRST;
                                else
@@ -2240,7 +2240,7 @@ get_reset_type:
                                goto get_delay;
                        }
                        reset_str = strstr(op_str, "dbgi");
-                       if (reset_str != NULL) {
+                       if (reset_str) {
                                if (set_op)
                                        write_ctrl_value = AICE_CUSTOM_DELAY_SET_DBGI;
                                else
@@ -2248,7 +2248,7 @@ get_reset_type:
                                goto get_delay;
                        }
                        reset_str = strstr(op_str, "trst");
-                       if (reset_str != NULL) {
+                       if (reset_str) {
                                if (set_op)
                                        write_ctrl_value = AICE_CUSTOM_DELAY_SET_TRST;
                                else
@@ -2732,7 +2732,7 @@ static int aice_usb_reset(void)
                return ERROR_FAIL;
 
        /* issue TRST */
-       if (custom_trst_script == NULL) {
+       if (!custom_trst_script) {
                if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL,
                                        AICE_JTAG_PIN_CONTROL_TRST) != ERROR_OK)
                        return ERROR_FAIL;
@@ -2755,7 +2755,7 @@ static int aice_issue_srst(uint32_t coreid)
        /* After issuing srst, target will be running. So we need to restore EDM_CTL. */
        aice_restore_edm_registers(coreid);
 
-       if (custom_srst_script == NULL) {
+       if (!custom_srst_script) {
                if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL,
                                        AICE_JTAG_PIN_CONTROL_SRST) != ERROR_OK)
                        return ERROR_FAIL;
@@ -2799,7 +2799,7 @@ static int aice_issue_reset_hold(uint32_t coreid)
                aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_STATUS, pin_status & (~0x4));
 
        /* issue restart */
-       if (custom_restart_script == NULL) {
+       if (!custom_restart_script) {
                if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL,
                                        AICE_JTAG_PIN_CONTROL_RESTART) != ERROR_OK)
                        return ERROR_FAIL;
@@ -2819,7 +2819,7 @@ static int aice_issue_reset_hold(uint32_t coreid)
                aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_STATUS, pin_status | 0x4);
 
                /* issue restart again */
-               if (custom_restart_script == NULL) {
+               if (!custom_restart_script) {
                        if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL,
                                                AICE_JTAG_PIN_CONTROL_RESTART) != ERROR_OK)
                                return ERROR_FAIL;
@@ -3721,7 +3721,7 @@ static int aice_usb_program_edm(uint32_t coreid, char *command_sequence)
 
        /* init strtok() */
        command_str = strtok(command_sequence, ";");
-       if (command_str == NULL)
+       if (!command_str)
                return ERROR_OK;
 
        do {
@@ -3740,14 +3740,14 @@ static int aice_usb_program_edm(uint32_t coreid, char *command_sequence)
                        reg_name_0 = strstr(command_str, "gen_port0");
                        reg_name_1 = strstr(command_str, "gen_port1");
 
-                       if (reg_name_0 != NULL) {
+                       if (reg_name_0) {
                                data_value = strtoul(reg_name_0 + 9, NULL, 0);
 
                                if (aice_write_misc(coreid,
                                                        NDS_EDM_MISC_GEN_PORT0, data_value) != ERROR_OK)
                                        return ERROR_FAIL;
 
-                       } else if (reg_name_1 != NULL) {
+                       } else if (reg_name_1) {
                                data_value = strtoul(reg_name_1 + 9, NULL, 0);
 
                                if (aice_write_misc(coreid,
@@ -3763,7 +3763,7 @@ static int aice_usb_program_edm(uint32_t coreid, char *command_sequence)
                /* update command_str */
                command_str = strtok(NULL, ";");
 
-       } while (command_str != NULL);
+       } while (command_str);
 
        return ERROR_OK;
 }
index cafb05b5be9c59a2457685b46d79bc9dee00b233..aacedbd67513678f38fdd16e805be1bccb93ea0b 100644 (file)
@@ -66,7 +66,7 @@ void jtag_queue_command(struct jtag_command *cmd)
        cmd->next = NULL;
 
        struct jtag_command **last_cmd = next_command_pointer;
-       assert(NULL != last_cmd);
+       assert(last_cmd);
        assert(NULL == *last_cmd);
        *last_cmd = cmd;
 
index 4b902ca70e7174636799013b0aee8444d1998acd..3d63fddc835c31b0ac329c0e768ca09e61a167ba 100644 (file)
@@ -278,7 +278,7 @@ struct jtag_tap *jtag_tap_next_enabled(struct jtag_tap *p)
 
 const char *jtag_tap_name(const struct jtag_tap *tap)
 {
-       return (tap == NULL) ? "(unknown)" : tap->dotted_name;
+       return (!tap) ? "(unknown)" : tap->dotted_name;
 }
 
 
@@ -286,7 +286,7 @@ int jtag_register_event_callback(jtag_event_handler_t callback, void *priv)
 {
        struct jtag_event_callback **callbacks_p = &jtag_event_callbacks;
 
-       if (callback == NULL)
+       if (!callback)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        if (*callbacks_p) {
@@ -307,7 +307,7 @@ int jtag_unregister_event_callback(jtag_event_handler_t callback, void *priv)
 {
        struct jtag_event_callback **p = &jtag_event_callbacks, *temp;
 
-       if (callback == NULL)
+       if (!callback)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        while (*p) {
@@ -395,7 +395,7 @@ void jtag_add_ir_scan(struct jtag_tap *active, struct scan_field *in_fields, tap
 void jtag_add_plain_ir_scan(int num_bits, const uint8_t *out_bits, uint8_t *in_bits,
        tap_state_t state)
 {
-       assert(out_bits != NULL);
+       assert(out_bits);
        assert(state != TAP_RESET);
 
        jtag_prelude(state);
@@ -468,7 +468,7 @@ void jtag_add_dr_scan(struct jtag_tap *active,
 void jtag_add_plain_dr_scan(int num_bits, const uint8_t *out_bits, uint8_t *in_bits,
        tap_state_t state)
 {
-       assert(out_bits != NULL);
+       assert(out_bits);
        assert(state != TAP_RESET);
 
        jtag_prelude(state);
@@ -919,9 +919,9 @@ static int jtag_check_value_inner(uint8_t *captured, uint8_t *in_check_value,
 
 void jtag_check_value_mask(struct scan_field *field, uint8_t *value, uint8_t *mask)
 {
-       assert(field->in_value != NULL);
+       assert(field->in_value);
 
-       if (value == NULL) {
+       if (!value) {
                /* no checking to do */
                return;
        }
@@ -934,7 +934,7 @@ void jtag_check_value_mask(struct scan_field *field, uint8_t *value, uint8_t *ma
 
 int default_interface_jtag_execute_queue(void)
 {
-       if (NULL == jtag) {
+       if (!jtag) {
                LOG_ERROR("No JTAG interface configured yet.  "
                        "Issue 'init' command in startup scripts "
                        "before communicating with targets.");
@@ -1230,7 +1230,7 @@ static int jtag_examine_chain(void)
        max_taps++;
 
        uint8_t *idcode_buffer = calloc(4, max_taps);
-       if (idcode_buffer == NULL)
+       if (!idcode_buffer)
                return ERROR_JTAG_INIT_FAILED;
 
        /* DR scan to collect BYPASS or IDCODE register contents.
@@ -1255,7 +1255,7 @@ static int jtag_examine_chain(void)
                uint32_t idcode = buf_get_u32(idcode_buffer, bit_count, 32);
 
                /* No predefined TAP? Auto-probe. */
-               if (tap == NULL) {
+               if (!tap) {
                        /* Is there another TAP? */
                        if (jtag_idcode_is_final(idcode))
                                break;
@@ -1355,7 +1355,7 @@ static int jtag_validate_ircapture(void)
        total_ir_length += 2;
 
        ir_test = malloc(DIV_ROUND_UP(total_ir_length, 8));
-       if (ir_test == NULL)
+       if (!ir_test)
                return ERROR_FAIL;
 
        /* after this scan, all TAPs will capture BYPASS instructions */
@@ -1377,7 +1377,7 @@ static int jtag_validate_ircapture(void)
 
        for (;; ) {
                tap = jtag_tap_next_enabled(tap);
-               if (tap == NULL)
+               if (!tap)
                        break;
 
                /* If we're autoprobing, guess IR lengths.  They must be at
@@ -1528,7 +1528,7 @@ int adapter_init(struct command_context *cmd_ctx)
                return retval;
        jtag = adapter_driver;
 
-       if (jtag->speed == NULL) {
+       if (!jtag->speed) {
                LOG_INFO("This adapter doesn't support configurable speed");
                return ERROR_OK;
        }
@@ -1574,7 +1574,7 @@ int jtag_init_inner(struct command_context *cmd_ctx)
        LOG_DEBUG("Init JTAG chain");
 
        tap = jtag_tap_next_enabled(NULL);
-       if (tap == NULL) {
+       if (!tap) {
                /* Once JTAG itself is properly set up, and the scan chain
                 * isn't absurdly large, IDCODE autoprobe should work fine.
                 *
@@ -1885,7 +1885,7 @@ bool jtag_will_verify_capture_ir(void)
 
 int jtag_power_dropout(int *dropout)
 {
-       if (jtag == NULL) {
+       if (!jtag) {
                /* TODO: as the jtag interface is not valid all
                 * we can do at the moment is exit OpenOCD */
                LOG_ERROR("No Valid JTAG Interface Configured.");
index 62d863191c39be284e50b5a5001855c5384c11b9..5b5a9669e518246a26744985654e165450151ae3 100644 (file)
@@ -103,7 +103,7 @@ static int armjtagew_execute_queue(void)
        enum scan_type type;
        uint8_t *buffer;
 
-       while (cmd != NULL) {
+       while (cmd) {
                switch (cmd->type) {
                        case JTAG_RUNTEST:
                                LOG_DEBUG_IO("runtest %i cycles, end in %i",
index 97734a92e5ecc804345269d2af8ee57af9ed3df7..04fc78b586808fd2bf1b78ea5c8a80e63e8a1b1d 100644 (file)
@@ -168,7 +168,7 @@ static void bitq_scan_field(struct scan_field *field, int do_pause)
        else
                tdo_req = 0;
 
-       if (field->out_value == NULL) {
+       if (!field->out_value) {
                /* just send zeros and request data from TDO */
                for (bit_cnt = field->num_bits; bit_cnt > 1; bit_cnt--)
                        bitq_io(0, 0, tdo_req);
index 59819513b4af151d99b6dff8a9e62583a000ca5a..642ad12f44cedcb77e449e233e7f58bdb8ea669c 100644 (file)
@@ -285,7 +285,7 @@ static bool read_and_discard_all_data(const int fd)
 
 static int buspirate_init(void)
 {
-       if (buspirate_port == NULL) {
+       if (!buspirate_port) {
                LOG_ERROR("You need to specify the serial port!");
                return ERROR_JTAG_INIT_FAILED;
        }
@@ -466,7 +466,7 @@ COMMAND_HANDLER(buspirate_handle_port_command)
        if (CMD_ARGC < 1)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
-       if (buspirate_port == NULL)
+       if (!buspirate_port)
                buspirate_port = strdup(CMD_ARGV[0]);
 
        return ERROR_OK;
index e498ea8295496af7693ece0ec70af08929f905cc..68fd470a806c4483fc4a769ffa28dfba0fbaebfc 100644 (file)
@@ -269,7 +269,7 @@ static int cmsis_dap_open(void)
        const struct cmsis_dap_backend *backend = NULL;
 
        struct cmsis_dap *dap = calloc(1, sizeof(struct cmsis_dap));
-       if (dap == NULL) {
+       if (!dap) {
                LOG_ERROR("unable to allocate memory");
                return ERROR_FAIL;
        }
@@ -290,7 +290,7 @@ static int cmsis_dap_open(void)
                }
        }
 
-       if (backend == NULL) {
+       if (!backend) {
                LOG_ERROR("unable to find a matching CMSIS-DAP device");
                free(dap);
                return ERROR_FAIL;
@@ -1533,14 +1533,14 @@ static void cmsis_dap_add_jtag_sequence(int s_len, const uint8_t *sequence, int
                (tdo_buffer != NULL ? DAP_JTAG_SEQ_TDO : 0) |
                (s_len == 64 ? 0 : s_len);
 
-       if (sequence != NULL)
+       if (sequence)
                bit_copy(&queued_seq_buf[queued_seq_buf_end + 1], 0, sequence, s_offset, s_len);
        else
                memset(&queued_seq_buf[queued_seq_buf_end + 1], 0, DIV_ROUND_UP(s_len, 8));
 
        queued_seq_buf_end += cmd_len;
 
-       if (tdo_buffer != NULL) {
+       if (tdo_buffer) {
                struct pending_scan_result *scan = &pending_scan_results[pending_scan_result_count++];
                scan->first = queued_seq_tdo_ptr;
                queued_seq_tdo_ptr += DIV_ROUND_UP(s_len, 8);
@@ -1799,7 +1799,7 @@ static int cmsis_dap_execute_queue(void)
 {
        struct jtag_command *cmd = jtag_command_queue;
 
-       while (cmd != NULL) {
+       while (cmd) {
                cmsis_dap_execute_command(cmd);
                cmd = cmd->next;
        }
index c42bab28f5301559e193cdf0d86a273f87fbac10..cb3e02fe2be9c9c7d818d07e6e9413503dc82a98 100644 (file)
@@ -353,7 +353,7 @@ static int cmsis_dap_usb_open(struct cmsis_dap *dap, uint16_t vids[], uint16_t p
                                LOG_WARNING("could not claim interface: %s", libusb_strerror(err));
 
                        dap->bdata = malloc(sizeof(struct cmsis_dap_backend_data));
-                       if (dap->bdata == NULL) {
+                       if (!dap->bdata) {
                                LOG_ERROR("unable to allocate memory");
                                libusb_release_interface(dev_handle, interface_num);
                                libusb_close(dev_handle);
@@ -370,7 +370,7 @@ static int cmsis_dap_usb_open(struct cmsis_dap *dap, uint16_t vids[], uint16_t p
                        dap->bdata->interface = interface_num;
 
                        dap->packet_buffer = malloc(dap->packet_buffer_size);
-                       if (dap->packet_buffer == NULL) {
+                       if (!dap->packet_buffer) {
                                LOG_ERROR("unable to allocate memory");
                                cmsis_dap_usb_close(dap);
                                return ERROR_FAIL;
@@ -446,7 +446,7 @@ static int cmsis_dap_usb_write(struct cmsis_dap *dap, int txlen, int timeout_ms)
 static int cmsis_dap_usb_alloc(struct cmsis_dap *dap, unsigned int pkt_sz)
 {
        uint8_t *buf = malloc(pkt_sz);
-       if (buf == NULL) {
+       if (!buf) {
                LOG_ERROR("unable to allocate CMSIS-DAP packet buffer");
                return ERROR_FAIL;
        }
index 38069f8400fc0414f7162285619caf8cda695927..ff0ac78372a377b7ab1c234a6af79f8599965a5e 100644 (file)
@@ -70,11 +70,11 @@ static int cmsis_dap_hid_open(struct cmsis_dap *dap, uint16_t vids[], uint16_t p
         */
        devs = hid_enumerate(0x0, 0x0);
        cur_dev = devs;
-       while (NULL != cur_dev) {
+       while (cur_dev) {
                bool found = false;
 
                if (0 == vids[0]) {
-                       if (NULL == cur_dev->product_string) {
+                       if (!cur_dev->product_string) {
                                LOG_DEBUG("Cannot read product string of device 0x%x:0x%x",
                                          cur_dev->vendor_id, cur_dev->product_id);
                        } else if (wcsstr(cur_dev->product_string, L"CMSIS-DAP")) {
@@ -97,10 +97,10 @@ static int cmsis_dap_hid_open(struct cmsis_dap *dap, uint16_t vids[], uint16_t p
 
                if (found) {
                        /* check serial number matches if given */
-                       if (serial == NULL)
+                       if (!serial)
                                break;
 
-                       if (cur_dev->serial_number != NULL) {
+                       if (cur_dev->serial_number) {
                                size_t len = (strlen(serial) + 1) * sizeof(wchar_t);
                                wchar_t *wserial = malloc(len);
                                mbstowcs(wserial, serial, len);
@@ -118,7 +118,7 @@ static int cmsis_dap_hid_open(struct cmsis_dap *dap, uint16_t vids[], uint16_t p
                cur_dev = cur_dev->next;
        }
 
-       if (NULL != cur_dev) {
+       if (cur_dev) {
                target_vid = cur_dev->vendor_id;
                target_pid = cur_dev->product_id;
        }
@@ -129,7 +129,7 @@ static int cmsis_dap_hid_open(struct cmsis_dap *dap, uint16_t vids[], uint16_t p
        }
 
        dap->bdata = malloc(sizeof(struct cmsis_dap_backend_data));
-       if (dap->bdata == NULL) {
+       if (!dap->bdata) {
                LOG_ERROR("unable to allocate memory");
                return ERROR_FAIL;
        }
@@ -137,7 +137,7 @@ static int cmsis_dap_hid_open(struct cmsis_dap *dap, uint16_t vids[], uint16_t p
        dev = hid_open_path(cur_dev->path);
        hid_free_enumeration(devs);
 
-       if (dev == NULL) {
+       if (!dev) {
                LOG_ERROR("unable to open CMSIS-DAP device 0x%x:0x%x", target_vid, target_pid);
                return ERROR_FAIL;
        }
@@ -217,7 +217,7 @@ static int cmsis_dap_hid_alloc(struct cmsis_dap *dap, unsigned int pkt_sz)
 {
        unsigned int packet_buffer_size = pkt_sz + REPORT_ID_SIZE;
        uint8_t *buf = malloc(packet_buffer_size);
-       if (buf == NULL) {
+       if (!buf) {
                LOG_ERROR("unable to allocate CMSIS-DAP packet buffer");
                return ERROR_FAIL;
        }
index 4923f96eb879b1d9a42bb0fb194ff0106c3661f6..e73876c17eadb42c7737078839587d84c6622a3b 100644 (file)
@@ -235,7 +235,7 @@ int interface_add_tms_seq(unsigned num_bits, const uint8_t *seq, enum tap_state
        struct jtag_command *cmd;
 
        cmd = cmd_queue_alloc(sizeof(struct jtag_command));
-       if (cmd == NULL)
+       if (!cmd)
                return ERROR_FAIL;
 
        cmd->type = JTAG_TMS;
@@ -350,7 +350,7 @@ void interface_jtag_add_callback4(jtag_callback_t callback,
        entry->data2 = data2;
        entry->data3 = data3;
 
-       if (jtag_callback_queue_head == NULL) {
+       if (!jtag_callback_queue_head) {
                jtag_callback_queue_head = entry;
                jtag_callback_queue_tail = entry;
        } else {
index a63480c6e528350442784d1d21391d1ceacdd8b7..3c0292561170376c1f1dea2c35088c1f9cd1e8e1 100644 (file)
@@ -176,7 +176,7 @@ static void ft232r_increase_buf_size(size_t new_buf_size)
        if (new_buf_size >= ft232r_buf_size) {
                new_buf_size += FT232R_BUF_SIZE_EXTRA;
                new_buf_ptr = realloc(ft232r_output, new_buf_size);
-               if (new_buf_ptr != NULL) {
+               if (new_buf_ptr) {
                        ft232r_output = new_buf_ptr;
                        ft232r_buf_size = new_buf_size;
                }
@@ -259,7 +259,7 @@ static int ft232r_init(void)
        uint16_t apids[] = {ft232r_pid, 0};
        if (jtag_libusb_open(avids, apids, ft232r_serial_desc, &adapter, NULL)) {
                LOG_ERROR("ft232r not found: vid=%04x, pid=%04x, serial=%s\n",
-                       ft232r_vid, ft232r_pid, (ft232r_serial_desc == NULL) ? "[any]" : ft232r_serial_desc);
+                       ft232r_vid, ft232r_pid, (!ft232r_serial_desc) ? "[any]" : ft232r_serial_desc);
                return ERROR_JTAG_INIT_FAILED;
        }
 
@@ -310,7 +310,7 @@ static int ft232r_init(void)
        }
 
        ft232r_output = malloc(ft232r_buf_size);
-       if (ft232r_output == NULL) {
+       if (!ft232r_output) {
                LOG_ERROR("Unable to allocate memory for the buffer");
                return ERROR_JTAG_INIT_FAILED;
        }
index a3d6dacdafb14ab0c787c9c4719b03d04be4c229..f17cd9fd9b35e4dd77173a5a2462b296b1d0b558 100644 (file)
@@ -935,7 +935,7 @@ COMMAND_HANDLER(ftdi_handle_tdo_sample_edge_command)
 
        if (CMD_ARGC > 0) {
                n = jim_nvp_name2value_simple(nvp_ftdi_jtag_modes, CMD_ARGV[0]);
-               if (n->name == NULL)
+               if (!n->name)
                        return ERROR_COMMAND_SYNTAX_ERROR;
                ftdi_jtag_mode = n->value;
 
@@ -1168,7 +1168,7 @@ static void ftdi_swd_queue_cmd(uint8_t cmd, uint32_t *dst, uint32_t data, uint32
                 * pointers into the queue which may be invalid after the realloc. */
                queued_retval = ftdi_swd_run_queue();
                struct swd_cmd_queue_entry *q = realloc(swd_cmd_queue, swd_cmd_queue_alloced * 2 * sizeof(*swd_cmd_queue));
-               if (q != NULL) {
+               if (q) {
                        swd_cmd_queue = q;
                        swd_cmd_queue_alloced *= 2;
                        LOG_DEBUG("Increased SWD command queue to %zu elements", swd_cmd_queue_alloced);
index 7a2be61fe26ef83f69fdafdb8cb3b194aefe34bd..63bcda1f47ad31c323860a4a4644387fbf22b71c 100644 (file)
@@ -294,7 +294,7 @@ static int jlink_execute_queue(void)
        int ret;
        struct jtag_command *cmd = jtag_command_queue;
 
-       while (cmd != NULL) {
+       while (cmd) {
                ret = jlink_execute_command(cmd);
 
                if (ret != ERROR_OK)
index f5a67dd118227291c58db9486e63b300bfbb4a33..ceb6628bb5fd89f707fa0c098e5dcccf568e78fb 100644 (file)
@@ -49,7 +49,7 @@ static int last_ir_num_bits;
 
 static int write_sock(char *buf, size_t len)
 {
-       if (buf == NULL) {
+       if (!buf) {
                LOG_ERROR("%s: NULL 'buf' argument, file %s, line %d",
                        __func__, __FILE__, __LINE__);
                return ERROR_FAIL;
@@ -64,7 +64,7 @@ static int write_sock(char *buf, size_t len)
 
 static int read_sock(char *buf, size_t len)
 {
-       if (buf == NULL) {
+       if (!buf) {
                LOG_ERROR("%s: NULL 'buf' argument, file %s, line %d",
                        __func__, __FILE__, __LINE__);
                return ERROR_FAIL;
@@ -123,7 +123,7 @@ static int jtag_dpi_scan(struct scan_command *cmd)
        int ret = ERROR_OK;
 
        num_bits = jtag_build_buffer(cmd, &data_buf);
-       if (data_buf == NULL) {
+       if (!data_buf) {
                LOG_ERROR("jtag_build_buffer call failed, data_buf == NULL, "
                        "file %s, line %d", __FILE__, __LINE__);
                return ERROR_FAIL;
@@ -133,7 +133,7 @@ static int jtag_dpi_scan(struct scan_command *cmd)
        if (cmd->ir_scan) {
                free(last_ir_buf);
                last_ir_buf = (uint8_t *)malloc(bytes * sizeof(uint8_t));
-               if (last_ir_buf == NULL) {
+               if (!last_ir_buf) {
                        LOG_ERROR("%s: malloc fail, file %s, line %d",
                                __func__, __FILE__, __LINE__);
                        ret = ERROR_FAIL;
@@ -181,7 +181,7 @@ static int jtag_dpi_runtest(int cycles)
        int num_bits = last_ir_num_bits, bytes;
        int ret = ERROR_OK;
 
-       if (data_buf == NULL) {
+       if (!data_buf) {
                LOG_ERROR("%s: NULL 'data_buf' argument, file %s, line %d",
                        __func__, __FILE__, __LINE__);
                return ERROR_FAIL;
@@ -194,7 +194,7 @@ static int jtag_dpi_runtest(int cycles)
 
        bytes = DIV_ROUND_UP(num_bits, 8);
        read_scan = (uint8_t *)malloc(bytes * sizeof(uint8_t));
-       if (read_scan == NULL) {
+       if (!read_scan) {
                LOG_ERROR("%s: malloc fail, file %s, line %d",
                        __func__, __FILE__, __LINE__);
                return ERROR_FAIL;
@@ -289,9 +289,9 @@ static int jtag_dpi_init(void)
        serv_addr.sin_family = AF_INET;
        serv_addr.sin_port = htons(server_port);
 
-       if (server_address == NULL) {
+       if (!server_address) {
                server_address = strdup(SERVER_ADDRESS);
-               if (server_address == NULL) {
+               if (!server_address) {
                        LOG_ERROR("%s: strdup fail, file %s, line %d",
                                __func__, __FILE__, __LINE__);
                        return ERROR_FAIL;
@@ -350,9 +350,9 @@ COMMAND_HANDLER(jtag_dpi_set_address)
        if (CMD_ARGC > 1)
                return ERROR_COMMAND_SYNTAX_ERROR;
        else if (CMD_ARGC == 0) {
-               if (server_address == NULL) {
+               if (!server_address) {
                        server_address = strdup(SERVER_ADDRESS);
-                       if (server_address == NULL) {
+                       if (!server_address) {
                                LOG_ERROR("%s: strdup fail, file %s, line %d",
                                        __func__, __FILE__, __LINE__);
                                return ERROR_FAIL;
@@ -362,7 +362,7 @@ COMMAND_HANDLER(jtag_dpi_set_address)
        } else {
                free(server_address);
                server_address = strdup(CMD_ARGV[0]);
-               if (server_address == NULL) {
+               if (!server_address) {
                        LOG_ERROR("%s: strdup fail, file %s, line %d",
                                __func__, __FILE__, __LINE__);
                        return ERROR_FAIL;
index fdd7137834fe09b3826dd8f9610fe6c4c0d6b27c..94cd7e74df7f1ab884b83abc196c663c8991133d 100644 (file)
@@ -46,7 +46,7 @@ bool jtag_usb_location_equal(uint8_t dev_bus, uint8_t *port_path,
        string_length = strnlen(loc, JTAG_USB_MAX_LOCATION_LENGTH);
 
        ptr = strtok(loc, "-");
-       if (ptr == NULL) {
+       if (!ptr) {
                LOG_WARNING("no '-' in usb path\n");
                goto done;
        }
@@ -61,7 +61,7 @@ bool jtag_usb_location_equal(uint8_t dev_bus, uint8_t *port_path,
                ptr = strtok(NULL, ".");
 
                /* no more tokens in path */
-               if (ptr == NULL)
+               if (!ptr)
                        break;
 
                /* path mismatch at some step */
index 00d3f5881e5f0a82da588a933343cce206d0e73f..327bb572db055f03038c92fabcc3a984c7f4ff6f 100644 (file)
@@ -158,7 +158,7 @@ static int kitprog_init(void)
        int retval;
 
        kitprog_handle = malloc(sizeof(struct kitprog));
-       if (kitprog_handle == NULL) {
+       if (!kitprog_handle) {
                LOG_ERROR("Failed to allocate memory");
                return ERROR_FAIL;
        }
@@ -208,14 +208,14 @@ static int kitprog_init(void)
        /* Allocate packet buffers and queues */
        kitprog_handle->packet_size = SWD_MAX_BUFFER_LENGTH;
        kitprog_handle->packet_buffer = malloc(SWD_MAX_BUFFER_LENGTH);
-       if (kitprog_handle->packet_buffer == NULL) {
+       if (!kitprog_handle->packet_buffer) {
                LOG_ERROR("Failed to allocate memory for the packet buffer");
                return ERROR_FAIL;
        }
 
        pending_queue_len = SWD_MAX_BUFFER_LENGTH / 5;
        pending_transfers = malloc(pending_queue_len * sizeof(*pending_transfers));
-       if (pending_transfers == NULL) {
+       if (!pending_transfers) {
                LOG_ERROR("Failed to allocate memory for the SWD transfer queue");
                return ERROR_FAIL;
        }
@@ -256,7 +256,7 @@ static int kitprog_get_usb_serial(void)
 
        /* Allocate memory for the serial number */
        kitprog_handle->serial = calloc(retval + 1, sizeof(char));
-       if (kitprog_handle->serial == NULL) {
+       if (!kitprog_handle->serial) {
                LOG_ERROR("Failed to allocate memory for the serial number");
                return ERROR_FAIL;
        }
@@ -285,7 +285,7 @@ static int kitprog_usb_open(void)
        /* Convert the ASCII serial number into a (wchar_t *) */
        size_t len = strlen(kitprog_handle->serial);
        wchar_t *hid_serial = calloc(len + 1, sizeof(wchar_t));
-       if (hid_serial == NULL) {
+       if (!hid_serial) {
                LOG_ERROR("Failed to allocate memory for the serial number");
                return ERROR_FAIL;
        }
@@ -298,7 +298,7 @@ static int kitprog_usb_open(void)
        /* Use HID for the KitBridge interface */
        kitprog_handle->hid_handle = hid_open(VID, PID, hid_serial);
        free(hid_serial);
-       if (kitprog_handle->hid_handle == NULL) {
+       if (!kitprog_handle->hid_handle) {
                LOG_ERROR("Failed to open KitBridge (HID) interface");
                return ERROR_FAIL;
        }
@@ -314,7 +314,7 @@ static int kitprog_usb_open(void)
 
 static void kitprog_usb_close(void)
 {
-       if (kitprog_handle->hid_handle != NULL) {
+       if (kitprog_handle->hid_handle) {
                hid_close(kitprog_handle->hid_handle);
                hid_exit();
        }
@@ -855,7 +855,7 @@ COMMAND_HANDLER(kitprog_handle_serial_command)
 {
        if (CMD_ARGC == 1) {
                kitprog_serial = strdup(CMD_ARGV[0]);
-               if (kitprog_serial == NULL) {
+               if (!kitprog_serial) {
                        LOG_ERROR("Failed to allocate memory for the serial number");
                        return ERROR_FAIL;
                }
index e214eb701259e68d25a5977a00945ed7319818b4..33f680cc66cfc835c3c93fe182266860241a651d 100644 (file)
@@ -138,7 +138,7 @@ static bool jtag_libusb_match_serial(struct libusb_device_handle *device,
        char *alternate_serial = adapter_get_alternate_serial(device, dev_desc);
 
        /* check possible failures */
-       if (alternate_serial == NULL)
+       if (!alternate_serial)
                return false;
 
        /* then compare and free the alternate serial */
index 99422a1168313811b448dcbdd2c98f41a10d8d55..03afd3da75a913800eea8e1dd5344efc01670f83 100644 (file)
@@ -207,14 +207,14 @@ static int linuxgpiod_reset(int trst, int srst)
        LOG_DEBUG("linuxgpiod_reset");
 
        /* assume active low */
-       if (gpiod_srst != NULL) {
+       if (gpiod_srst) {
                retval1 = gpiod_line_set_value(gpiod_srst, srst ? 0 : 1);
                if (retval1 < 0)
                        LOG_WARNING("set srst value failed");
        }
 
        /* assume active low */
-       if (gpiod_trst != NULL) {
+       if (gpiod_trst) {
                retval2 = gpiod_line_set_value(gpiod_trst, trst ? 0 : 1);
                if (retval2 < 0)
                        LOG_WARNING("set trst value failed");
@@ -284,7 +284,7 @@ static struct gpiod_line *helper_get_input_line(const char *label, unsigned int
        int retval;
 
        line = gpiod_chip_get_line(gpiod_chip, offset);
-       if (line == NULL) {
+       if (!line) {
                LOG_ERROR("Error get line %s", label);
                return NULL;
        }
@@ -304,7 +304,7 @@ static struct gpiod_line *helper_get_output_line(const char *label, unsigned int
        int retval;
 
        line = gpiod_chip_get_line(gpiod_chip, offset);
-       if (line == NULL) {
+       if (!line) {
                LOG_ERROR("Error get line %s", label);
                return NULL;
        }
@@ -325,7 +325,7 @@ static int linuxgpiod_init(void)
        bitbang_interface = &linuxgpiod_bitbang;
 
        gpiod_chip = gpiod_chip_open_by_number(gpiochip);
-       if (gpiod_chip == NULL) {
+       if (!gpiod_chip) {
                LOG_ERROR("Cannot open LinuxGPIOD gpiochip %d", gpiochip);
                return ERROR_JTAG_INIT_FAILED;
        }
@@ -343,24 +343,24 @@ static int linuxgpiod_init(void)
                }
 
                gpiod_tdo = helper_get_input_line("tdo", tdo_gpio);
-               if (gpiod_tdo == NULL)
+               if (!gpiod_tdo)
                        goto out_error;
 
                gpiod_tdi = helper_get_output_line("tdi", tdi_gpio, 0);
-               if (gpiod_tdi == NULL)
+               if (!gpiod_tdi)
                        goto out_error;
 
                gpiod_tck = helper_get_output_line("tck", tck_gpio, 0);
-               if (gpiod_tck == NULL)
+               if (!gpiod_tck)
                        goto out_error;
 
                gpiod_tms = helper_get_output_line("tms", tms_gpio, 1);
-               if (gpiod_tms == NULL)
+               if (!gpiod_tms)
                        goto out_error;
 
                if (is_gpio_valid(trst_gpio)) {
                        gpiod_trst = helper_get_output_line("trst", trst_gpio, 1);
-                       if (gpiod_trst == NULL)
+                       if (!gpiod_trst)
                                goto out_error;
                }
        }
@@ -372,23 +372,23 @@ static int linuxgpiod_init(void)
                }
 
                gpiod_swclk = helper_get_output_line("swclk", swclk_gpio, 1);
-               if (gpiod_swclk == NULL)
+               if (!gpiod_swclk)
                        goto out_error;
 
                gpiod_swdio = helper_get_output_line("swdio", swdio_gpio, 1);
-               if (gpiod_swdio == NULL)
+               if (!gpiod_swdio)
                        goto out_error;
        }
 
        if (is_gpio_valid(srst_gpio)) {
                gpiod_srst = helper_get_output_line("srst", srst_gpio, 1);
-               if (gpiod_srst == NULL)
+               if (!gpiod_srst)
                        goto out_error;
        }
 
        if (is_gpio_valid(led_gpio)) {
                gpiod_led = helper_get_output_line("led", led_gpio, 0);
-               if (gpiod_led == NULL)
+               if (!gpiod_led)
                        goto out_error;
        }
 
index 9ba1e2502de746474cda4ef2aef27126c51a41b2..4e64fdbbfaaac0b7ec57ecaa5dec99c14894a54c 100644 (file)
@@ -119,7 +119,7 @@ static bool device_location_equal(struct libusb_device *device, const char *loca
        LOG_DEBUG("device path has %i steps", path_len);
 
        ptr = strtok(loc, "-:");
-       if (ptr == NULL) {
+       if (!ptr) {
                LOG_DEBUG("no ':' in path");
                goto done;
        }
@@ -131,7 +131,7 @@ static bool device_location_equal(struct libusb_device *device, const char *loca
        path_step = 0;
        while (path_step < 7) {
                ptr = strtok(NULL, ".,");
-               if (ptr == NULL) {
+               if (!ptr) {
                        LOG_DEBUG("no more tokens in path at step %i", path_step);
                        break;
                }
index 82fcbc11950315c759cc696b481f01f7ba20adec..6881959c33761a348ae410b8fcf71e0e14a8d1b0 100644 (file)
@@ -161,7 +161,7 @@ COMMAND_HANDLER(opendous_handle_opendous_type_command)
                return ERROR_OK;
 
        /* only if the cable name wasn't overwritten by cmdline */
-       if (opendous_type == NULL) {
+       if (!opendous_type) {
                /* REVISIT first verify that it's listed in cables[] ... */
                opendous_type = strdup(CMD_ARGV[0]);
        }
@@ -256,7 +256,7 @@ static int opendous_execute_queue(void)
        enum scan_type type;
        uint8_t *buffer;
 
-       while (cmd != NULL) {
+       while (cmd) {
                switch (cmd->type) {
                        case JTAG_RUNTEST:
                                LOG_DEBUG_IO("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles,
@@ -331,7 +331,7 @@ static int opendous_init(void)
 
        cur_opendous_probe = opendous_probes;
 
-       if (opendous_type == NULL) {
+       if (!opendous_type) {
                opendous_type = strdup("opendous");
                LOG_WARNING("No opendous_type specified, using default 'opendous'");
        }
index 6940c8870619a8f09352a4ad8d814a4b20c7c133..7efb0e5e01fa8133980c99ee3c904e286a3b7d6b 100644 (file)
@@ -397,7 +397,7 @@ static int openjtag_init_standard(void)
        uint8_t latency_timer;
 
        /* Open by device description */
-       if (openjtag_device_desc == NULL) {
+       if (!openjtag_device_desc) {
                LOG_WARNING("no openjtag device description specified, "
                                "using default 'Open JTAG Project'");
                openjtag_device_desc = "Open JTAG Project";
@@ -475,7 +475,7 @@ static int openjtag_init_cy7c65215(void)
        return ERROR_OK;
 
 err:
-       if (usbh != NULL)
+       if (usbh)
                jtag_libusb_close(usbh);
        return ERROR_JTAG_INIT_FAILED;
 }
@@ -803,7 +803,7 @@ static int openjtag_execute_queue(void)
 {
        struct jtag_command *cmd = jtag_command_queue;
 
-       while (cmd != NULL) {
+       while (cmd) {
                openjtag_execute_command(cmd);
                cmd = cmd->next;
        }
index e61b20b3af6569996d1e41ee5e9afd634506c7c2..1d7fcc44d77ea2267018e51308fb7d3a46a69771 100644 (file)
@@ -272,7 +272,7 @@ static int parport_init(void)
 
        cur_cable = cables;
 
-       if (parport_cable == NULL) {
+       if (!parport_cable) {
                parport_cable = strdup("wiggler");
                LOG_WARNING("No parport cable specified, using default 'wiggler'");
        }
index 43d669e3ee5b7960dcd796ecd80c64e776c54180..b6f110be8b3d5acff5c2422d0304c41302e6a803 100644 (file)
@@ -534,7 +534,7 @@ static int presto_jtag_init(void)
 {
        if (presto_open(presto_serial) != ERROR_OK) {
                presto_close();
-               if (presto_serial != NULL)
+               if (presto_serial)
                        LOG_ERROR("Cannot open PRESTO, serial number '%s'", presto_serial);
                else
                        LOG_ERROR("Cannot open PRESTO");
index 57f0c6e071a5c177f7fd42a64dea3ed5a0fb8351..ac1040e23cec254a9378d15f70828a7189a93048 100644 (file)
@@ -263,7 +263,7 @@ static int remote_bitbang_init_tcp(void)
 
        freeaddrinfo(result); /* No longer needed */
 
-       if (rp == NULL) { /* No address succeeded */
+       if (!rp) { /* No address succeeded */
                log_socket_error("Failed to connect");
                return ERROR_FAIL;
        }
@@ -273,7 +273,7 @@ static int remote_bitbang_init_tcp(void)
 
 static int remote_bitbang_init_unix(void)
 {
-       if (remote_bitbang_host == NULL) {
+       if (!remote_bitbang_host) {
                LOG_ERROR("host/socket not specified");
                return ERROR_FAIL;
        }
@@ -306,7 +306,7 @@ static int remote_bitbang_init(void)
        remote_bitbang_recv_buf_end = 0;
 
        LOG_INFO("Initializing remote_bitbang driver");
-       if (remote_bitbang_port == NULL)
+       if (!remote_bitbang_port)
                remote_bitbang_fd = remote_bitbang_init_unix();
        else
                remote_bitbang_fd = remote_bitbang_init_tcp();
index 07e22ffb79c37a63049621a1319952dc7bc88631..7a41a693d10232dc109d4a4d503513a4952a2488 100644 (file)
@@ -608,7 +608,7 @@ static inline struct dtc_reply_queue_entry *dtc_queue_enqueue_reply(
        struct dtc_reply_queue_entry *rq_entry;
 
        rq_entry = malloc(sizeof(struct dtc_reply_queue_entry));
-       if (rq_entry != NULL) {
+       if (rq_entry) {
                rq_entry->scan.type = type;
                rq_entry->scan.buffer = buffer;
                rq_entry->scan.size = size;
@@ -617,7 +617,7 @@ static inline struct dtc_reply_queue_entry *dtc_queue_enqueue_reply(
                rq_entry->cmd = cmd;
                rq_entry->next = NULL;
 
-               if (dtc_queue.rq_head == NULL)
+               if (!dtc_queue.rq_head)
                        dtc_queue.rq_head = rq_entry;
                else
                        dtc_queue.rq_tail->next = rq_entry;
@@ -665,7 +665,7 @@ static int dtc_queue_run(void)
                exit(1);
        }
 
-       if (dtc_queue.rq_head != NULL) {
+       if (dtc_queue.rq_head) {
                /* process the reply, which empties the reply queue and frees its entries */
                dtc_p = reply_buffer;
 
index 5d7ab6af3de0c488ccdce40d41583c0d4885a104..811ad5325275a7802e46c96233b7095d101c6c35 100644 (file)
@@ -475,7 +475,7 @@ static unsigned int stlink_usb_block(void *handle)
 {
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        if (h->version.flags & STLINK_F_HAS_RW8_512BYTES)
                return STLINKV3_MAX_RW8;
@@ -636,7 +636,7 @@ static int stlink_usb_xfer_v1_get_status(void *handle)
        struct stlink_usb_handle_s *h = handle;
        int tr, ret;
 
-       assert(handle != NULL);
+       assert(handle);
 
        /* read status */
        memset(h->cmdbuf, 0, STLINK_SG_SIZE);
@@ -670,7 +670,7 @@ static int stlink_usb_xfer_rw(void *handle, int cmdsize, const uint8_t *buf, int
 {
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        size_t n_transfers = 0;
        struct jtag_xfer transfers[2];
@@ -709,7 +709,7 @@ static int stlink_usb_xfer_rw(void *handle, int cmdsize, const uint8_t *buf, int
        struct stlink_usb_handle_s *h = handle;
        int tr, ret;
 
-       assert(handle != NULL);
+       assert(handle);
 
        ret = jtag_libusb_bulk_write(h->usb_backend_priv.fd, h->tx_ep, (char *)h->cmdbuf,
                                     cmdsize, STLINK_WRITE_TIMEOUT, &tr);
@@ -742,7 +742,7 @@ static int stlink_usb_xfer_v1_get_sense(void *handle)
        int res;
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        stlink_usb_init_buffer(handle, h->rx_ep, 16);
 
@@ -790,7 +790,7 @@ static int stlink_usb_usb_xfer_noerrcheck(void *handle, const uint8_t *buf, int
        int err, cmdsize = STLINK_CMD_SIZE_V2;
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        if (h->version.stlink == 1) {
                cmdsize = STLINK_SG_SIZE;
@@ -823,7 +823,7 @@ static int stlink_tcp_send_cmd(void *handle, int send_size, int recv_size, bool
 {
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        /* send the TCP command */
        int sent_size = send(h->tcp_backend_priv.fd, (void *)h->tcp_backend_priv.send_buf, send_size, 0);
@@ -868,7 +868,7 @@ static int stlink_tcp_xfer_noerrcheck(void *handle, const uint8_t *buf, int size
        int send_size = STLINK_TCP_USB_CMD_SIZE;
        int recv_size = STLINK_TCP_SS_SIZE;
 
-       assert(handle != NULL);
+       assert(handle);
 
        /* prepare the TCP command */
        h->tcp_backend_priv.send_buf[0] = STLINK_TCP_CMD_SEND_USB_CMD;
@@ -937,7 +937,7 @@ static int stlink_usb_error_check(void *handle)
 {
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        if (h->st_mode == STLINK_MODE_DEBUG_SWIM) {
                switch (h->databuf[0]) {
@@ -1076,7 +1076,7 @@ static int stlink_usb_read_trace(void *handle, const uint8_t *buf, int size)
 {
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        assert(h->version.flags & STLINK_F_HAS_TRACE);
 
@@ -1141,7 +1141,7 @@ static int stlink_usb_version(void *handle)
        char *p;
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        stlink_usb_init_buffer(handle, h->rx_ep, 6);
 
@@ -1355,7 +1355,7 @@ static int stlink_usb_set_swdclk(void *handle, uint16_t clk_divisor)
 {
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        if (!(h->version.flags & STLINK_F_HAS_SWD_SET_FREQ))
                return ERROR_COMMAND_NOTFOUND;
@@ -1379,7 +1379,7 @@ static int stlink_usb_set_jtagclk(void *handle, uint16_t clk_divisor)
 {
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        if (!(h->version.flags & STLINK_F_HAS_JTAG_SET_FREQ))
                return ERROR_COMMAND_NOTFOUND;
@@ -1405,7 +1405,7 @@ static int stlink_usb_current_mode(void *handle, uint8_t *mode)
        int res;
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        stlink_usb_init_buffer(handle, h->rx_ep, 2);
 
@@ -1427,7 +1427,7 @@ static int stlink_usb_mode_enter(void *handle, enum stlink_mode type)
        int rx_size = 0;
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        /* on api V2 we are able the read the latest command
         * status
@@ -1475,7 +1475,7 @@ static int stlink_usb_mode_leave(void *handle, enum stlink_mode type)
        int res;
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        /* command with no reply, use a valid endpoint but zero size */
        stlink_usb_init_buffer(handle, h->rx_ep, 0);
@@ -1528,7 +1528,7 @@ static int stlink_usb_exit_mode(void *handle)
        uint8_t mode;
        enum stlink_mode emode;
 
-       assert(handle != NULL);
+       assert(handle);
 
        res = stlink_usb_current_mode(handle, &mode);
 
@@ -1569,7 +1569,7 @@ static int stlink_usb_init_mode(void *handle, bool connect_under_reset, int init
        enum stlink_mode emode;
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        res = stlink_usb_exit_mode(handle);
        if (res != ERROR_OK)
@@ -1867,7 +1867,7 @@ static int stlink_usb_idcode(void *handle, uint32_t *idcode)
        int res, offset;
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        /* there is no swim read core id cmd */
        if (h->st_mode == STLINK_MODE_DEBUG_SWIM) {
@@ -1905,7 +1905,7 @@ static int stlink_usb_v2_read_debug_reg(void *handle, uint32_t addr, uint32_t *v
        struct stlink_usb_handle_s *h = handle;
        int res;
 
-       assert(handle != NULL);
+       assert(handle);
 
        stlink_usb_init_buffer(handle, h->rx_ep, 8);
 
@@ -1926,7 +1926,7 @@ static int stlink_usb_write_debug_reg(void *handle, uint32_t addr, uint32_t val)
 {
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        stlink_usb_init_buffer(handle, h->rx_ep, 2);
 
@@ -1948,7 +1948,7 @@ static int stlink_usb_trace_read(void *handle, uint8_t *buf, size_t *size)
 {
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        if (h->trace.enabled && (h->version.flags & STLINK_F_HAS_TRACE)) {
                int res;
@@ -1999,7 +1999,7 @@ static enum target_state stlink_usb_state(void *handle)
        int res;
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        if (h->reconnect_pending) {
                LOG_INFO("Previous state query failed, trying to reconnect");
@@ -2041,7 +2041,7 @@ static int stlink_usb_assert_srst(void *handle, int srst)
 {
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        if (h->st_mode == STLINK_MODE_DEBUG_SWIM)
                return stlink_swim_assert_reset(handle, srst);
@@ -2064,7 +2064,7 @@ static void stlink_usb_trace_disable(void *handle)
        int res = ERROR_OK;
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        assert(h->version.flags & STLINK_F_HAS_TRACE);
 
@@ -2086,7 +2086,7 @@ static int stlink_usb_trace_enable(void *handle)
        int res;
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        if (h->version.flags & STLINK_F_HAS_TRACE) {
                stlink_usb_init_buffer(handle, h->rx_ep, 10);
@@ -2118,7 +2118,7 @@ static int stlink_usb_reset(void *handle)
        struct stlink_usb_handle_s *h = handle;
        int retval;
 
-       assert(handle != NULL);
+       assert(handle);
 
        stlink_usb_init_buffer(handle, h->rx_ep, 2);
 
@@ -2147,7 +2147,7 @@ static int stlink_usb_run(void *handle)
        int res;
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        if (h->version.jtag_api != STLINK_JTAG_API_V1) {
                res = stlink_usb_write_debug_reg(handle, DCB_DHCSR, DBGKEY|C_DEBUGEN);
@@ -2169,7 +2169,7 @@ static int stlink_usb_halt(void *handle)
        int res;
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        if (h->version.jtag_api != STLINK_JTAG_API_V1) {
                res = stlink_usb_write_debug_reg(handle, DCB_DHCSR, DBGKEY|C_HALT|C_DEBUGEN);
@@ -2190,7 +2190,7 @@ static int stlink_usb_step(void *handle)
 {
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        if (h->version.jtag_api != STLINK_JTAG_API_V1) {
                /* TODO: this emulates the v1 api, it should really use a similar auto mask isr
@@ -2214,7 +2214,7 @@ static int stlink_usb_read_regs(void *handle)
        int res;
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        stlink_usb_init_buffer(handle, h->rx_ep, 88);
 
@@ -2239,7 +2239,7 @@ static int stlink_usb_read_reg(void *handle, unsigned int regsel, uint32_t *val)
        int res;
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        if (STLINK_REGSEL_IS_FPU(regsel) && !(h->version.flags & STLINK_F_HAS_FPU_REG)) {
                res = stlink_usb_write_debug_reg(h, DCB_DCRSR, regsel & 0x7f);
@@ -2279,7 +2279,7 @@ static int stlink_usb_write_reg(void *handle, unsigned int regsel, uint32_t val)
 {
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        if (STLINK_REGSEL_IS_FPU(regsel) && !(h->version.flags & STLINK_F_HAS_FPU_REG)) {
                int res = stlink_usb_write_debug_reg(h, DCB_DCRDR, val);
@@ -2308,7 +2308,7 @@ static int stlink_usb_get_rw_status(void *handle)
 {
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        if (h->version.jtag_api == STLINK_JTAG_API_V1)
                return ERROR_OK;
@@ -2333,7 +2333,7 @@ static int stlink_usb_read_mem8(void *handle, uint32_t addr, uint16_t len,
        uint16_t read_len = len;
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        /* max 8 bit read/write is 64 bytes or 512 bytes for v3 */
        if (len > stlink_usb_block(h)) {
@@ -2371,7 +2371,7 @@ static int stlink_usb_write_mem8(void *handle, uint32_t addr, uint16_t len,
        int res;
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        /* max 8 bit read/write is 64 bytes or 512 bytes for v3 */
        if (len > stlink_usb_block(h)) {
@@ -2403,7 +2403,7 @@ static int stlink_usb_read_mem16(void *handle, uint32_t addr, uint16_t len,
        int res;
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        if (!(h->version.flags & STLINK_F_HAS_MEM_16BIT))
                return ERROR_COMMAND_NOTFOUND;
@@ -2440,7 +2440,7 @@ static int stlink_usb_write_mem16(void *handle, uint32_t addr, uint16_t len,
        int res;
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        if (!(h->version.flags & STLINK_F_HAS_MEM_16BIT))
                return ERROR_COMMAND_NOTFOUND;
@@ -2475,7 +2475,7 @@ static int stlink_usb_read_mem32(void *handle, uint32_t addr, uint16_t len,
        int res;
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        /* data must be a multiple of 4 and word aligned */
        if (len % 4 || addr % 4) {
@@ -2509,7 +2509,7 @@ static int stlink_usb_write_mem32(void *handle, uint32_t addr, uint16_t len,
        int res;
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        /* data must be a multiple of 4 and word aligned */
        if (len % 4 || addr % 4) {
@@ -2985,7 +2985,7 @@ static int stlink_tcp_close(void *handle)
 /** */
 static int stlink_close(void *handle)
 {
-       if (handle != NULL) {
+       if (handle) {
                struct stlink_usb_handle_s *h = handle;
 
                stlink_usb_close(handle);
@@ -3064,7 +3064,7 @@ static char *stlink_usb_get_alternate_serial(struct libusb_device_handle *device
        /* else (len == 26) => buggy ST-Link */
 
        char *alternate_serial = malloc((STLINK_SERIAL_LEN + 1) * sizeof(char));
-       if (alternate_serial == NULL)
+       if (!alternate_serial)
                return NULL;
 
        for (unsigned int i = 0; i < STLINK_SERIAL_LEN; i += 2)
@@ -3307,7 +3307,7 @@ static int stlink_tcp_open(void *handle, struct hl_interface_param_s *param)
        char serial[STLINK_TCP_SERIAL_SIZE + 1] = {0};
        uint8_t stlink_used;
        bool stlink_id_matched = false;
-       bool stlink_serial_matched = (param->serial == NULL);
+       bool stlink_serial_matched = (!param->serial);
 
        for (uint32_t stlink_id = 0; stlink_id < connected_stlinks; stlink_id++) {
                /* get the stlink info */
@@ -3534,8 +3534,8 @@ static int stlink_config_trace(void *handle, bool enabled,
                return ERROR_OK;
        }
 
-       assert(trace_freq != NULL);
-       assert(prescaler != NULL);
+       assert(trace_freq);
+       assert(prescaler);
 
        if (pin_protocol != TPIU_PIN_PROTOCOL_ASYNC_UART) {
                LOG_ERROR("The attached ST-LINK version doesn't support this trace mode");
@@ -3585,7 +3585,7 @@ static int stlink_usb_init_access_port(void *handle, unsigned char ap_num)
 {
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        if (!(h->version.flags & STLINK_F_HAS_AP_INIT))
                return ERROR_COMMAND_NOTFOUND;
@@ -3604,7 +3604,7 @@ static int stlink_usb_close_access_port(void *handle, unsigned char ap_num)
 {
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        if (!(h->version.flags & STLINK_F_HAS_AP_INIT))
                return ERROR_COMMAND_NOTFOUND;
@@ -3630,7 +3630,7 @@ static int stlink_read_dap_register(void *handle, unsigned short dap_port,
        struct stlink_usb_handle_s *h = handle;
        int retval;
 
-       assert(handle != NULL);
+       assert(handle);
 
        if (!(h->version.flags & STLINK_F_HAS_DAP_REG))
                return ERROR_COMMAND_NOTFOUND;
@@ -3653,7 +3653,7 @@ static int stlink_write_dap_register(void *handle, unsigned short dap_port,
 {
        struct stlink_usb_handle_s *h = handle;
 
-       assert(handle != NULL);
+       assert(handle);
 
        if (!(h->version.flags & STLINK_F_HAS_DAP_REG))
                return ERROR_COMMAND_NOTFOUND;
index 00b2f9675e0b77e08defcc8f88e2e8aa9408e9a0..d911fdacbfe225c0c3268dd2595a9fa3f2b035ed 100644 (file)
@@ -122,7 +122,7 @@ static int icdi_send_packet(void *handle, int len)
        int result, retry = 0;
        int transferred = 0;
 
-       assert(handle != NULL);
+       assert(handle);
 
        /* check we have a large enough buffer for checksum "#00" */
        if (len + 3 > h->max_packet) {
@@ -253,7 +253,7 @@ static int icdi_get_cmd_result(void *handle)
        int offset = 0;
        char ch;
 
-       assert(handle != NULL);
+       assert(handle);
 
        do {
                ch = h->read_buffer[offset++];
index fe95e7d18b9c03e3883e3a6a114683be633b12ed..b2fedbefd04e60d26e714365f241fc1009967425 100644 (file)
@@ -531,14 +531,14 @@ static int ulink_allocate_payload(struct ulink_cmd *ulink_cmd, int size,
 
        payload = calloc(size, sizeof(uint8_t));
 
-       if (payload == NULL) {
+       if (!payload) {
                LOG_ERROR("Could not allocate OpenULINK command payload: out of memory");
                return ERROR_FAIL;
        }
 
        switch (direction) {
            case PAYLOAD_DIRECTION_OUT:
-                   if (ulink_cmd->payload_out != NULL) {
+                   if (ulink_cmd->payload_out) {
                            LOG_ERROR("BUG: Duplicate payload allocation for OpenULINK command");
                            free(payload);
                            return ERROR_FAIL;
@@ -548,7 +548,7 @@ static int ulink_allocate_payload(struct ulink_cmd *ulink_cmd, int size,
                    }
                    break;
            case PAYLOAD_DIRECTION_IN:
-                   if (ulink_cmd->payload_in_start != NULL) {
+                   if (ulink_cmd->payload_in_start) {
                            LOG_ERROR("BUG: Duplicate payload allocation for OpenULINK command");
                            free(payload);
                            return ERROR_FAIL;
@@ -584,7 +584,7 @@ static int ulink_get_queue_size(struct ulink *device,
        struct ulink_cmd *current = device->queue_start;
        int sum = 0;
 
-       while (current != NULL) {
+       while (current) {
                switch (direction) {
                    case PAYLOAD_DIRECTION_OUT:
                            sum += current->payload_out_size + 1;       /* + 1 byte for Command ID */
@@ -612,7 +612,7 @@ static void ulink_clear_queue(struct ulink *device)
        struct ulink_cmd *current = device->queue_start;
        struct ulink_cmd *next = NULL;
 
-       while (current != NULL) {
+       while (current) {
                /* Save pointer to next element */
                next = current->next;
 
@@ -673,7 +673,7 @@ static int ulink_append_queue(struct ulink *device, struct ulink_cmd *ulink_cmd)
                        ulink_clear_queue(device);
        }
 
-       if (device->queue_start == NULL) {
+       if (!device->queue_start) {
                /* Queue was empty */
                device->commands_in_queue = 1;
 
@@ -877,7 +877,7 @@ static int ulink_append_scan_cmd(struct ulink *device, enum scan_type scan_type,
        int ret, i, scan_size_bytes;
        uint8_t bits_last_byte;
 
-       if (cmd == NULL)
+       if (!cmd)
                return ERROR_FAIL;
 
        /* Check size of command. USB buffer can hold 64 bytes, 1 byte is command ID,
@@ -975,7 +975,7 @@ static int ulink_append_clock_tms_cmd(struct ulink *device, uint8_t count,
        struct ulink_cmd *cmd = calloc(1, sizeof(struct ulink_cmd));
        int ret;
 
-       if (cmd == NULL)
+       if (!cmd)
                return ERROR_FAIL;
 
        if (device->delay_clock_tms < 0)
@@ -1011,7 +1011,7 @@ static int ulink_append_clock_tck_cmd(struct ulink *device, uint16_t count)
        struct ulink_cmd *cmd = calloc(1, sizeof(struct ulink_cmd));
        int ret;
 
-       if (cmd == NULL)
+       if (!cmd)
                return ERROR_FAIL;
 
        if (device->delay_clock_tck < 0)
@@ -1044,7 +1044,7 @@ static int ulink_append_get_signals_cmd(struct ulink *device)
        struct ulink_cmd *cmd = calloc(1, sizeof(struct ulink_cmd));
        int ret;
 
-       if (cmd == NULL)
+       if (!cmd)
                return ERROR_FAIL;
 
        cmd->id = CMD_GET_SIGNALS;
@@ -1084,7 +1084,7 @@ static int ulink_append_set_signals_cmd(struct ulink *device, uint8_t low,
        struct ulink_cmd *cmd = calloc(1, sizeof(struct ulink_cmd));
        int ret;
 
-       if (cmd == NULL)
+       if (!cmd)
                return ERROR_FAIL;
 
        cmd->id = CMD_SET_SIGNALS;
@@ -1116,7 +1116,7 @@ static int ulink_append_sleep_cmd(struct ulink *device, uint32_t us)
        struct ulink_cmd *cmd = calloc(1, sizeof(struct ulink_cmd));
        int ret;
 
-       if (cmd == NULL)
+       if (!cmd)
                return ERROR_FAIL;
 
        cmd->id = CMD_SLEEP_US;
@@ -1153,7 +1153,7 @@ static int ulink_append_configure_tck_cmd(struct ulink *device, int delay_scan_i
        struct ulink_cmd *cmd = calloc(1, sizeof(struct ulink_cmd));
        int ret;
 
-       if (cmd == NULL)
+       if (!cmd)
                return ERROR_FAIL;
 
        cmd->id = CMD_CONFIGURE_TCK_FREQ;
@@ -1214,7 +1214,7 @@ static int ulink_append_led_cmd(struct ulink *device, uint8_t led_state)
        struct ulink_cmd *cmd = calloc(1, sizeof(struct ulink_cmd));
        int ret;
 
-       if (cmd == NULL)
+       if (!cmd)
                return ERROR_FAIL;
 
        cmd->id = CMD_SET_LEDS;
@@ -1244,7 +1244,7 @@ static int ulink_append_test_cmd(struct ulink *device)
        struct ulink_cmd *cmd = calloc(1, sizeof(struct ulink_cmd));
        int ret;
 
-       if (cmd == NULL)
+       if (!cmd)
                return ERROR_FAIL;
 
        cmd->id = CMD_TEST;
@@ -1491,7 +1491,7 @@ static int ulink_queue_scan(struct ulink *device, struct jtag_command *cmd)
        if ((type == SCAN_IN) || (type == SCAN_IO)) {
                tdo_buffer_start = calloc(sizeof(uint8_t), scan_size_bytes);
 
-               if (tdo_buffer_start == NULL)
+               if (!tdo_buffer_start)
                        return ERROR_FAIL;
 
                tdo_buffer = tdo_buffer_start;
@@ -1569,9 +1569,9 @@ static int ulink_queue_scan(struct ulink *device, struct jtag_command *cmd)
                        bytecount -= 58;
 
                        /* Update TDI and TDO buffer pointers */
-                       if (tdi_buffer_start != NULL)
+                       if (tdi_buffer_start)
                                tdi_buffer += 58;
-                       if (tdo_buffer_start != NULL)
+                       if (tdo_buffer_start)
                                tdo_buffer += 58;
                } else if (bytecount == 58) {   /* Full scan, no further scans */
                        tms_count_end = last_tms_count;
@@ -1871,12 +1871,12 @@ static int ulink_post_process_queue(struct ulink *device)
 
        current = device->queue_start;
 
-       while (current != NULL) {
+       while (current) {
                openocd_cmd = current->cmd_origin;
 
                /* Check if a corresponding OpenOCD command is stored for this
                 * OpenULINK command */
-               if ((current->needs_postprocessing == true) && (openocd_cmd != NULL)) {
+               if ((current->needs_postprocessing == true) && (openocd_cmd)) {
                        switch (openocd_cmd->type) {
                            case JTAG_SCAN:
                                    ret = ulink_post_process_scan(current);
@@ -2122,7 +2122,7 @@ static int ulink_init(void)
        uint8_t input_signals, output_signals;
 
        ulink_handle = calloc(1, sizeof(struct ulink));
-       if (ulink_handle == NULL)
+       if (!ulink_handle)
                return ERROR_FAIL;
 
        libusb_init(&ulink_handle->libusb_ctx);
index cb4862fbf1258837b4ce6307bae6d5eb790f0967..23a5097c208108e0c6e9c6b43e6eb4b5ab5cdcbf 100644 (file)
@@ -32,7 +32,7 @@ static RESULT usbtoswd_read_callback(void *p, uint8_t *src, uint8_t *processed)
 {
        struct versaloon_pending_t *pending = (struct versaloon_pending_t *)p;
 
-       if (pending->extra_data != NULL)
+       if (pending->extra_data)
                *((uint8_t *)pending->extra_data) = src[0];
 
        return ERROR_OK;
@@ -42,7 +42,7 @@ static RESULT usbtoswd_write_callback(void *p, uint8_t *src, uint8_t *processed)
 {
        struct versaloon_pending_t *pending = (struct versaloon_pending_t *)p;
 
-       if (pending->extra_data != NULL)
+       if (pending->extra_data)
                *((uint8_t *)pending->extra_data) = src[0];
 
        /* mark it processed to ignore other input data */
@@ -135,7 +135,7 @@ RESULT usbtoswd_transact(uint8_t interface_index, uint8_t request,
        parity += (request >> 4) & 1;
        parity &= 1;
        buff[0] = (request | 0x81 | (parity << 5)) & ~0x40;
-       if (data != NULL)
+       if (data)
                SET_LE_U32(&buff[1], *data);
        else
                memset(buff + 1, 0, 4);
index b46bbe0e0f2839fc6479aba800af91a7f205ec8b..ee3b72463736f01ef934561c3fc74fc157c1be60 100644 (file)
@@ -90,7 +90,7 @@ static RESULT usbtoxxx_validate_current_command_type(void)
 {
        if (type_pre > 0) {
                /* not the first command */
-               if (NULL == usbtoxxx_buffer) {
+               if (!usbtoxxx_buffer) {
                        LOG_BUG(ERRMSG_INVALID_BUFFER, TO_STR(usbtoxxx_buffer));
                        return ERRCODE_INVALID_BUFFER;
                }
@@ -182,8 +182,8 @@ RESULT usbtoxxx_execute_command(void)
                                struct versaloon_want_pos_t *tmp;
 
                                tmp = versaloon_pending[i].pos;
-                               while (tmp != NULL) {
-                                       if ((tmp->buff != NULL) && (tmp->size > 0)) {
+                               while (tmp) {
+                                       if ((tmp->buff) && (tmp->size > 0)) {
                                                memcpy(tmp->buff,
                                                        versaloon_buf + usbtoxxx_buffer_index
                                                        + tmp->offset,
@@ -332,7 +332,7 @@ RESULT usbtoxxx_add_command(uint8_t type, uint8_t cmd, uint8_t *cmdbuf,
        if (ERROR_OK != usbtoxxx_ensure_buffer_size(cmdlen + 6))
                return ERROR_FAIL;
 
-       if ((type_pre != type) || (NULL == usbtoxxx_buffer)) {
+       if ((type_pre != type) || (!usbtoxxx_buffer)) {
                if (ERROR_OK != usbtoxxx_validate_current_command_type()) {
                        LOG_BUG(ERRMSG_FAILURE_OPERATION, "validate previous commands");
                        return ERRCODE_FAILURE_OPERATION;
@@ -357,7 +357,7 @@ RESULT usbtoxxx_add_command(uint8_t type, uint8_t cmd, uint8_t *cmdbuf,
                SET_LE_U16(&usbtoxxx_buffer[collect_index], len_tmp);
        }
 
-       if (cmdbuf != NULL) {
+       if (cmdbuf) {
                memcpy(usbtoxxx_buffer + usbtoxxx_current_cmd_index, cmdbuf, cmdlen);
                usbtoxxx_current_cmd_index += cmdlen;
        }
index c6e390c931e969067bcea3475616953e704d7c79..199c8981818afe4c24b1e0cea256f1960e139e7c 100644 (file)
@@ -117,7 +117,7 @@ void versaloon_free_want_pos(void)
        struct versaloon_want_pos_t *tmp, *free_tmp;
 
        tmp = versaloon_want_pos;
-       while (tmp != NULL) {
+       while (tmp) {
                free_tmp = tmp;
                tmp = tmp->next;
                free(free_tmp);
@@ -126,7 +126,7 @@ void versaloon_free_want_pos(void)
 
        for (i = 0; i < ARRAY_SIZE(versaloon_pending); i++) {
                tmp = versaloon_pending[i].pos;
-               while (tmp != NULL) {
+               while (tmp) {
                        free_tmp = tmp;
                        tmp = tmp->next;
                        free(free_tmp);
@@ -140,7 +140,7 @@ RESULT versaloon_add_want_pos(uint16_t offset, uint16_t size, uint8_t *buff)
        struct versaloon_want_pos_t *new_pos = NULL;
 
        new_pos = malloc(sizeof(*new_pos));
-       if (NULL == new_pos) {
+       if (!new_pos) {
                LOG_ERROR(ERRMSG_NOT_ENOUGH_MEMORY);
                return ERRCODE_NOT_ENOUGH_MEMORY;
        }
@@ -149,12 +149,12 @@ RESULT versaloon_add_want_pos(uint16_t offset, uint16_t size, uint8_t *buff)
        new_pos->buff = buff;
        new_pos->next = NULL;
 
-       if (NULL == versaloon_want_pos)
+       if (!versaloon_want_pos)
                versaloon_want_pos = new_pos;
        else {
                struct versaloon_want_pos_t *tmp = versaloon_want_pos;
 
-               while (tmp->next != NULL)
+               while (tmp->next)
                        tmp = tmp->next;
                tmp->next = new_pos;
        }
@@ -199,7 +199,7 @@ RESULT versaloon_send_command(uint16_t out_len, uint16_t *inlen)
        int transferred;
 
 #if PARAM_CHECK
-       if (NULL == versaloon_buf) {
+       if (!versaloon_buf) {
                LOG_BUG(ERRMSG_INVALID_BUFFER, TO_STR(versaloon_buf));
                return ERRCODE_INVALID_BUFFER;
        }
@@ -217,7 +217,7 @@ RESULT versaloon_send_command(uint16_t out_len, uint16_t *inlen)
                return ERRCODE_FAILURE_OPERATION;
        }
 
-       if (inlen != NULL) {
+       if (inlen) {
                ret = libusb_bulk_transfer(versaloon_usb_device_handle,
                        versaloon_interface.usb_setting.ep_in,
                        versaloon_buf, versaloon_interface.usb_setting.buf_size,
@@ -242,7 +242,7 @@ static RESULT versaloon_init(void)
 
        /* malloc temporary buffer */
        versaloon_buf = malloc(versaloon_interface.usb_setting.buf_size);
-       if (NULL == versaloon_buf) {
+       if (!versaloon_buf) {
                LOG_ERROR(ERRMSG_NOT_ENOUGH_MEMORY);
                return ERRCODE_NOT_ENOUGH_MEMORY;
        }
@@ -274,13 +274,13 @@ static RESULT versaloon_init(void)
        versaloon_buf = NULL;
 
        versaloon_buf = malloc(versaloon_interface.usb_setting.buf_size);
-       if (NULL == versaloon_buf) {
+       if (!versaloon_buf) {
                versaloon_fini();
                LOG_ERROR(ERRMSG_NOT_ENOUGH_MEMORY);
                return ERRCODE_NOT_ENOUGH_MEMORY;
        }
        versaloon_cmd_buf = malloc(versaloon_interface.usb_setting.buf_size - 3);
-       if (NULL == versaloon_cmd_buf) {
+       if (!versaloon_cmd_buf) {
                versaloon_fini();
                LOG_ERROR(ERRMSG_NOT_ENOUGH_MEMORY);
                return ERRCODE_NOT_ENOUGH_MEMORY;
@@ -294,7 +294,7 @@ static RESULT versaloon_init(void)
 
 static RESULT versaloon_fini(void)
 {
-       if (versaloon_usb_device_handle != NULL) {
+       if (versaloon_usb_device_handle) {
                usbtoxxx_fini();
                versaloon_free_want_pos();
 
@@ -325,11 +325,11 @@ static RESULT versaloon_get_target_voltage(uint16_t *voltage)
        uint16_t inlen;
 
 #if PARAM_CHECK
-       if (NULL == versaloon_buf) {
+       if (!versaloon_buf) {
                LOG_BUG(ERRMSG_INVALID_BUFFER, TO_STR(versaloon_buf));
                return ERRCODE_INVALID_BUFFER;
        }
-       if (NULL == voltage) {
+       if (!voltage) {
                LOG_BUG(ERRMSG_INVALID_PARAMETER, __func__);
                return ERRCODE_INVALID_PARAMETER;
        }
index 6a592bcfb35882d98d041bbac63cdbf562d4d378..b4597b788dce87d376b1e23bece146d2d5377093 100644 (file)
@@ -105,7 +105,7 @@ static int vsllink_execute_queue(void)
                " vsllink "
                "-------------------------------------");
 
-       while (cmd != NULL) {
+       while (cmd) {
                switch (cmd->type) {
                        case JTAG_RUNTEST:
                                LOG_DEBUG_IO("runtest %i cycles, end in %s",
@@ -280,7 +280,7 @@ static int vsllink_quit(void)
 static int vsllink_interface_init(void)
 {
        vsllink_handle = malloc(sizeof(struct vsllink));
-       if (NULL == vsllink_handle) {
+       if (!vsllink_handle) {
                LOG_ERROR("unable to allocate memory");
                return ERROR_FAIL;
        }
@@ -333,7 +333,7 @@ static int vsllink_init(void)
                tdi_buffer = malloc(tap_buffer_size);
                tdo_buffer = malloc(tap_buffer_size);
                tms_buffer = malloc(tap_buffer_size);
-               if ((NULL == tdi_buffer) || (NULL == tdo_buffer) || (NULL == tms_buffer)) {
+               if ((!tdi_buffer) || (!tdo_buffer) || (!tms_buffer)) {
                        vsllink_quit();
                        return ERROR_FAIL;
                }
index 1a17f70cc882fb00697d2e2d0ee0b2d091a992e6..e89cfe589d36f687da12d7a2afcb6d68c17b6f41 100644 (file)
@@ -400,7 +400,7 @@ static bool usb_connect(void)
         * 2) didn't find the XDS110, and no devices are currently open
         */
 
-       if (NULL != list) {
+       if (list) {
                /* Free the device list, we're done with it */
                libusb_free_device_list(list, 1);
        }
@@ -431,12 +431,12 @@ static bool usb_connect(void)
 
        /* On an error, clean up what we can */
        if (0 != result) {
-               if (NULL != dev) {
+               if (dev) {
                        /* Release the debug and data interface on the XDS110 */
                        (void)libusb_release_interface(dev, xds110.interface);
                        libusb_close(dev);
                }
-               if (NULL != ctx)
+               if (ctx)
                        libusb_exit(ctx);
                xds110.ctx = NULL;
                xds110.dev = NULL;
@@ -453,13 +453,13 @@ static bool usb_connect(void)
 
 static void usb_disconnect(void)
 {
-       if (NULL != xds110.dev) {
+       if (xds110.dev) {
                /* Release the debug and data interface on the XDS110 */
                (void)libusb_release_interface(xds110.dev, xds110.interface);
                libusb_close(xds110.dev);
                xds110.dev = NULL;
        }
-       if (NULL != xds110.ctx) {
+       if (xds110.ctx) {
                libusb_exit(xds110.ctx);
                xds110.ctx = NULL;
        }
@@ -505,7 +505,7 @@ static bool usb_write(unsigned char *buffer, int size, int *written)
                retries++;
        }
 
-       if (NULL != written)
+       if (written)
                *written = bytes_written;
 
        return (result == 0 && size == bytes_written) ? true : false;
@@ -550,7 +550,7 @@ static bool usb_get_response(uint32_t *total_bytes_read, uint32_t timeout)
 
        /* Abort now if we didn't receive a valid response */
        if (!success) {
-               if (NULL != total_bytes_read)
+               if (total_bytes_read)
                        *total_bytes_read = 0;
                return false;
        }
@@ -587,7 +587,7 @@ static bool usb_get_response(uint32_t *total_bytes_read, uint32_t timeout)
 
        if (!success)
                count = 0;
-       if (NULL != total_bytes_read)
+       if (total_bytes_read)
                *total_bytes_read = count;
 
        return success;
@@ -636,7 +636,7 @@ static bool xds_execute(uint32_t out_length, uint32_t in_length,
        int error = 0;
        uint32_t bytes_read = 0;
 
-       if (NULL == xds110.dev)
+       if (!xds110.dev)
                return false;
 
        while (!done && attempts > 0) {
@@ -714,9 +714,9 @@ static bool xds_version(uint32_t *firmware_id, uint16_t *hardware_id)
                                DEFAULT_TIMEOUT);
 
        if (success) {
-               if (NULL != firmware_id)
+               if (firmware_id)
                        *firmware_id = xds110_get_u32(fw_id_pntr);
-               if (NULL != hardware_id)
+               if (hardware_id)
                        *hardware_id = xds110_get_u16(hw_id_pntr);
        }
 
@@ -863,7 +863,7 @@ static bool cmapi_connect(uint32_t *idcode)
                                DEFAULT_TIMEOUT);
 
        if (success) {
-               if (NULL != idcode)
+               if (idcode)
                        *idcode = xds110_get_u32(idcode_pntr);
        }
 
@@ -926,7 +926,7 @@ static bool cmapi_read_dap_reg(uint32_t type, uint32_t ap_num,
                                DEFAULT_TIMEOUT);
 
        if (success) {
-               if (NULL != value)
+               if (value)
                        *value = xds110_get_u32(value_pntr);
        }
 
@@ -943,7 +943,7 @@ static bool cmapi_write_dap_reg(uint32_t type, uint32_t ap_num,
 
        bool success;
 
-       if (NULL == value)
+       if (!value)
                return false;
 
        xds110.write_payload[0] = CMAPI_REG_WRITE;
@@ -1086,7 +1086,7 @@ static bool ocd_pathmove(uint32_t num_states, uint8_t *path)
 
        bool success;
 
-       if (NULL == path)
+       if (!path)
                return false;
 
        xds110.write_payload[0] = OCD_PATHMOVE;
@@ -1209,7 +1209,7 @@ static bool xds110_legacy_read_reg(uint8_t cmd, uint32_t *value)
        /* Handle result of read attempt */
        if (!success)
                LOG_ERROR("XDS110: failed to read DAP register");
-       else if (NULL != value)
+       else if (value)
                *value = reg_value;
 
        if (success && DAP_AP == type) {
@@ -1867,7 +1867,7 @@ static int xds110_execute_queue(void)
 {
        struct jtag_command *cmd = jtag_command_queue;
 
-       while (cmd != NULL) {
+       while (cmd) {
                xds110_execute_command(cmd);
                cmd = cmd->next;
        }
index 15651763da8eb9bdb36a3021a383180acc3e4a7b..0aaf22f98ef096845a2d2f86e5fd1bbf6ae522a8 100644 (file)
@@ -165,7 +165,7 @@ static int hl_interface_speed(int speed)
        if (hl_if.layout->api->speed == NULL)
                return ERROR_OK;
 
-       if (hl_if.handle == NULL) {
+       if (!hl_if.handle) {
                /* pass speed as initial param as interface not open yet */
                hl_if.param.initial_interface_speed = speed;
                return ERROR_OK;
index cf51a671330889a8274e72c19344393ba5056c75..16b2217976a6ceafff66686f36825883e1e507cd 100644 (file)
@@ -94,7 +94,7 @@ int hl_layout_init(struct hl_interface_s *adapter)
 {
        LOG_DEBUG("hl_layout_init");
 
-       if (adapter->layout == NULL) {
+       if (!adapter->layout) {
                LOG_ERROR("no layout specified");
                return ERROR_FAIL;
        }
index 2355babf0602a9c71d53d9d13ba48aa341ab9934..af2f149b09d9627453a01adf5a8b01039817a4e8 100644 (file)
@@ -62,9 +62,9 @@ struct jtag_tap *jtag_tap_by_jim_obj(Jim_Interp *interp, Jim_Obj *o)
 {
        const char *cp = Jim_GetString(o, NULL);
        struct jtag_tap *t = cp ? jtag_tap_by_string(cp) : NULL;
-       if (NULL == cp)
+       if (!cp)
                cp = "(unknown)";
-       if (NULL == t)
+       if (!t)
                Jim_SetResultFormatted(interp, "Tap '%s' could not be found", cp);
        return t;
 }
@@ -162,7 +162,7 @@ static int jim_command_drscan(Jim_Interp *interp, int argc, Jim_Obj * const *arg
        assert(e == JIM_OK);
 
        tap = jtag_tap_by_jim_obj(interp, args[1]);
-       if (tap == NULL)
+       if (!tap)
                return JIM_ERR;
 
        num_fields = (argc-2)/2;
@@ -362,7 +362,7 @@ static int jtag_tap_configure_event(struct jim_getopt_info *goi, struct jtag_tap
        if (goi->isconfigure) {
                if (!found)
                        jteap = calloc(1, sizeof(*jteap));
-               else if (NULL != jteap->body)
+               else if (jteap->body)
                        Jim_DecrRefCount(goi->interp, jteap->body);
 
                jteap->interp = goi->interp;
@@ -769,7 +769,7 @@ int jim_jtag_tap_enabler(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
        struct jtag_tap *t;
 
        t = jtag_tap_by_jim_obj(goi.interp, goi.argv[0]);
-       if (t == NULL)
+       if (!t)
                return JIM_ERR;
 
        if (strcasecmp(cmd_name, "tapisenabled") == 0) {
@@ -811,7 +811,7 @@ int jim_jtag_configure(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
        Jim_Obj *o;
        jim_getopt_obj(&goi, &o);
        t = jtag_tap_by_jim_obj(goi.interp, o);
-       if (t == NULL)
+       if (!t)
                return JIM_ERR;
 
        return jtag_tap_configure_cmd(&goi, t);
@@ -1122,7 +1122,7 @@ COMMAND_HANDLER(handle_irscan_command)
        int retval;
        for (i = 0; i < num_fields; i++) {
                tap = jtag_tap_by_string(CMD_ARGV[i*2]);
-               if (tap == NULL) {
+               if (!tap) {
                        free(fields);
                        command_print(CMD, "Tap: %s unknown", CMD_ARGV[i*2]);
 
index 934a6807c39c57112d4e70532c337ea7387106c1..a2de8ccf55603fe3a19f5ae5a8877807649917da 100644 (file)
@@ -26,7 +26,7 @@
 
 static int virtex2_set_instr(struct jtag_tap *tap, uint32_t new_instr)
 {
-       if (tap == NULL)
+       if (!tap)
                return ERROR_FAIL;
 
        if (buf_get_u32(tap->cur_instr, 0, tap->ir_length) != new_instr) {
@@ -204,7 +204,7 @@ PLD_DEVICE_COMMAND_HANDLER(virtex2_pld_device_command)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        tap = jtag_tap_by_string(CMD_ARGV[1]);
-       if (tap == NULL) {
+       if (!tap) {
                command_print(CMD, "Tap: %s does not exist", CMD_ARGV[1]);
                return ERROR_OK;
        }
index a530ee776db52b3d34b12dc1833fd44bd34436cb..fe3faefc9ea8141312754515d53e0246b007c8bd 100644 (file)
@@ -93,7 +93,7 @@ int xilinx_read_bit_file(struct xilinx_bit_file *bit_file, const char *filename)
        }
 
        input_file = fopen(filename, "rb");
-       if (input_file == NULL) {
+       if (!input_file) {
                LOG_ERROR("couldn't open %s: %s", filename, strerror(errno));
                return ERROR_PLD_FILE_LOAD_FAILED;
        }
index a480c44619ee7d1e213f61681dadcad8543a11c0..87b168177c1ade093794f54a2f9fdafe993d8cce 100644 (file)
@@ -160,12 +160,12 @@ static int freertos_update_threads(struct rtos *rtos)
        unsigned int tasks_found = 0;
        const struct freertos_params *param;
 
-       if (rtos->rtos_specific_params == NULL)
+       if (!rtos->rtos_specific_params)
                return -1;
 
        param = (const struct freertos_params *) rtos->rtos_specific_params;
 
-       if (rtos->symbols == NULL) {
+       if (!rtos->symbols) {
                LOG_ERROR("No symbols for FreeRTOS");
                return -3;
        }
@@ -403,13 +403,13 @@ static int freertos_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
        const struct freertos_params *param;
        int64_t stack_ptr = 0;
 
-       if (rtos == NULL)
+       if (!rtos)
                return -1;
 
        if (thread_id == 0)
                return -2;
 
-       if (rtos->rtos_specific_params == NULL)
+       if (!rtos->rtos_specific_params)
                return -1;
 
        param = (const struct freertos_params *) rtos->rtos_specific_params;
@@ -494,13 +494,13 @@ static int freertos_get_thread_ascii_info(struct rtos *rtos, threadid_t thread_i
        int retval;
        const struct freertos_params *param;
 
-       if (rtos == NULL)
+       if (!rtos)
                return -1;
 
        if (thread_id == 0)
                return -2;
 
-       if (rtos->rtos_specific_params == NULL)
+       if (!rtos->rtos_specific_params)
                return -3;
 
        param = (const struct freertos_params *) rtos->rtos_specific_params;
index 5eadce9cada553c0a6ba6fa5e1839db0dfa7ee23..c7effe79f961345d1486187a761e722fc8616989 100644 (file)
@@ -206,7 +206,7 @@ static const struct rtos_register_stacking *get_stacking_info(const struct rtos
 {
        const struct threadx_params *param = (const struct threadx_params *) rtos->rtos_specific_params;
 
-       if (param->fn_get_stacking_info != NULL)
+       if (param->fn_get_stacking_info)
                return param->fn_get_stacking_info(rtos, stack_ptr);
 
        return param->stacking_info + 0;
@@ -216,12 +216,12 @@ static int is_thread_id_valid(const struct rtos *rtos, int64_t thread_id)
 {
        const struct threadx_params *param;
 
-       if (rtos->rtos_specific_params == NULL)
+       if (!rtos->rtos_specific_params)
                return 0; /* invalid */
 
        param = (const struct threadx_params *) rtos->rtos_specific_params;
 
-       if (param->fn_is_thread_id_valid != NULL)
+       if (param->fn_is_thread_id_valid)
                return param->fn_is_thread_id_valid(rtos, thread_id);
 
        return (thread_id != 0);
@@ -263,15 +263,15 @@ static int threadx_update_threads(struct rtos *rtos)
        int thread_list_size = 0;
        const struct threadx_params *param;
 
-       if (rtos == NULL)
+       if (!rtos)
                return -1;
 
-       if (rtos->rtos_specific_params == NULL)
+       if (!rtos->rtos_specific_params)
                return -3;
 
        param = (const struct threadx_params *) rtos->rtos_specific_params;
 
-       if (rtos->symbols == NULL) {
+       if (!rtos->symbols) {
                LOG_ERROR("No symbols for ThreadX");
                return -4;
        }
@@ -437,13 +437,13 @@ static int threadx_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
        int retval;
        const struct threadx_params *param;
 
-       if (rtos == NULL)
+       if (!rtos)
                return -1;
 
        if (!is_thread_id_valid(rtos, thread_id))
                return -2;
 
-       if (rtos->rtos_specific_params == NULL)
+       if (!rtos->rtos_specific_params)
                return -3;
 
        param = (const struct threadx_params *) rtos->rtos_specific_params;
@@ -469,7 +469,7 @@ static int threadx_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
        const struct rtos_register_stacking *stacking_info =
                        get_stacking_info(rtos, stack_ptr);
 
-       if (stacking_info == NULL) {
+       if (!stacking_info) {
                LOG_ERROR("Unknown stacking info for thread id=0x%" PRIx64, (uint64_t)thread_id);
                return -6;
        }
@@ -518,18 +518,18 @@ static int threadx_get_thread_detail(struct rtos *rtos,
 
        const struct threadx_params *param;
 
-       if (rtos == NULL)
+       if (!rtos)
                return -1;
 
        if (thread_id == 0)
                return -2;
 
-       if (rtos->rtos_specific_params == NULL)
+       if (!rtos->rtos_specific_params)
                return -3;
 
        param = (const struct threadx_params *) rtos->rtos_specific_params;
 
-       if (rtos->symbols == NULL) {
+       if (!rtos->symbols) {
                LOG_ERROR("No symbols for ThreadX");
                return -3;
        }
index cb471b4859d41b1dc176e8c276aed2baec6c29c7..6539a78cdbbabb57aa99b1c2df6a14474a5bfeb2 100644 (file)
@@ -469,8 +469,8 @@ static int chibios_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
        const struct chibios_params *param;
        uint32_t stack_ptr = 0;
 
-       if ((rtos == NULL) || (thread_id == 0) ||
-                       (rtos->rtos_specific_params == NULL))
+       if ((!rtos) || (thread_id == 0) ||
+                       (!rtos->rtos_specific_params))
                return -1;
 
        param = (const struct chibios_params *) rtos->rtos_specific_params;
index b060a812acef6ceacc6afbd3c83a276c3c9c6a49..c6b26285521cce8378064b8016098f1c550a41c1 100644 (file)
@@ -102,15 +102,15 @@ static int ecos_update_threads(struct rtos *rtos)
        int thread_list_size = 0;
        const struct ecos_params *param;
 
-       if (rtos == NULL)
+       if (!rtos)
                return -1;
 
-       if (rtos->rtos_specific_params == NULL)
+       if (!rtos->rtos_specific_params)
                return -3;
 
        param = (const struct ecos_params *) rtos->rtos_specific_params;
 
-       if (rtos->symbols == NULL) {
+       if (!rtos->symbols) {
                LOG_ERROR("No symbols for eCos");
                return -4;
        }
@@ -289,13 +289,13 @@ static int ecos_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
        int retval;
        const struct ecos_params *param;
 
-       if (rtos == NULL)
+       if (!rtos)
                return -1;
 
        if (thread_id == 0)
                return -2;
 
-       if (rtos->rtos_specific_params == NULL)
+       if (!rtos->rtos_specific_params)
                return -3;
 
        param = (const struct ecos_params *) rtos->rtos_specific_params;
index 259399bc335b5a827253990e133b208ce3708b54..1987fd59c65c3e032d6a4ffb43fbb3177917df0a 100644 (file)
@@ -187,13 +187,13 @@ static int embkernel_update_threads(struct rtos *rtos)
        int retval;
        const struct embkernel_params *param;
 
-       if (rtos == NULL)
+       if (!rtos)
                return -1;
 
-       if (rtos->rtos_specific_params == NULL)
+       if (!rtos->rtos_specific_params)
                return -3;
 
-       if (rtos->symbols == NULL) {
+       if (!rtos->symbols) {
                LOG_ERROR("No symbols for embKernel");
                return -4;
        }
@@ -308,13 +308,13 @@ static int embkernel_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
        const struct embkernel_params *param;
        int64_t stack_ptr = 0;
 
-       if (rtos == NULL)
+       if (!rtos)
                return -1;
 
        if (thread_id == 0)
                return -2;
 
-       if (rtos->rtos_specific_params == NULL)
+       if (!rtos->rtos_specific_params)
                return -1;
 
        param = (const struct embkernel_params *) rtos->rtos_specific_params;
index dfa247f2c0a5551ac610bfa107103df28efaa4bc..5732ac2e9de84d0b6cda51c60760d412d0aa8ec9 100644 (file)
@@ -97,7 +97,7 @@ static int hwthread_update_threads(struct rtos *rtos)
        int64_t current_thread = 0;
        enum target_debug_reason current_reason = DBG_REASON_UNDEFINED;
 
-       if (rtos == NULL)
+       if (!rtos)
                return -1;
 
        target = rtos->target;
@@ -215,7 +215,7 @@ static int hwthread_smp_init(struct target *target)
 static struct target *hwthread_find_thread(struct target *target, int64_t thread_id)
 {
        /* Find the thread with that thread_id */
-       if (target == NULL)
+       if (!target)
                return NULL;
        if (target->smp) {
                for (struct target_list *head = target->head; head != NULL; head = head->next) {
@@ -231,13 +231,13 @@ static struct target *hwthread_find_thread(struct target *target, int64_t thread
 static int hwthread_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
                struct rtos_reg **rtos_reg_list, int *rtos_reg_list_size)
 {
-       if (rtos == NULL)
+       if (!rtos)
                return ERROR_FAIL;
 
        struct target *target = rtos->target;
 
        struct target *curr = hwthread_find_thread(target, thread_id);
-       if (curr == NULL)
+       if (!curr)
                return ERROR_FAIL;
 
        if (!target_was_examined(curr))
@@ -281,13 +281,13 @@ static int hwthread_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
 static int hwthread_get_thread_reg(struct rtos *rtos, int64_t thread_id,
                uint32_t reg_num, struct rtos_reg *rtos_reg)
 {
-       if (rtos == NULL)
+       if (!rtos)
                return ERROR_FAIL;
 
        struct target *target = rtos->target;
 
        struct target *curr = hwthread_find_thread(target, thread_id);
-       if (curr == NULL) {
+       if (!curr) {
                LOG_ERROR("Couldn't find RTOS thread for id %" PRId64 ".", thread_id);
                return ERROR_FAIL;
        }
@@ -318,13 +318,13 @@ static int hwthread_get_thread_reg(struct rtos *rtos, int64_t thread_id,
 
 static int hwthread_set_reg(struct rtos *rtos, uint32_t reg_num, uint8_t *reg_value)
 {
-       if (rtos == NULL)
+       if (!rtos)
                return ERROR_FAIL;
 
        struct target *target = rtos->target;
 
        struct target *curr = hwthread_find_thread(target, rtos->current_thread);
-       if (curr == NULL)
+       if (!curr)
                return ERROR_FAIL;
 
        struct reg *reg = register_get_by_number(curr->reg_cache, reg_num, true);
@@ -347,7 +347,7 @@ static int hwthread_target_for_threadid(struct connection *connection, int64_t t
        struct target *target = get_target_from_connection(connection);
 
        struct target *curr = hwthread_find_thread(target, thread_id);
-       if (curr == NULL)
+       if (!curr)
                return ERROR_FAIL;
 
        *p_target = curr;
index 0a15efaaca31c9ebd31a015a4d09b3136877b936..b9749b5612abb3dc44c68a06e3d4f6d126233e12 100644 (file)
@@ -181,7 +181,7 @@ static int linux_os_thread_reg_list(struct rtos *rtos,
                        found = 1;
                else
                        next = next->next;
-       } while ((found == 0) && (next != tmp) && (next != NULL));
+       } while ((found == 0) && (next != tmp) && (next));
 
        if (found == 0) {
                LOG_ERROR("could not find thread: %" PRIx64, thread_id);
@@ -408,7 +408,7 @@ static int get_current(struct target *target, int create)
        struct current_thread *ctt = linux_os->current_threads;
 
        /*  invalid current threads content */
-       while (ctt != NULL) {
+       while (ctt) {
                ctt->threadid = -1;
                ctt->TS = 0xdeadbeef;
                ctt = ctt->next;
@@ -445,10 +445,10 @@ static int get_current(struct target *target, int create)
                                        linux_os->current_threads;
                                cpu = head->target->coreid;
 
-                               while ((ct != NULL) && (ct->core_id != (int32_t) cpu))
+                               while ((ct) && (ct->core_id != (int32_t) cpu))
                                        ct = ct->next;
 
-                               if ((ct != NULL) && (ct->TS == 0xdeadbeef))
+                               if ((ct) && (ct->TS == 0xdeadbeef))
                                        ct->TS = TS;
                                else
                                        LOG_ERROR
@@ -603,13 +603,13 @@ static struct current_thread *add_current_thread(struct current_thread *currents
 {
        ct->next = NULL;
 
-       if (currents == NULL) {
+       if (!currents) {
                currents = ct;
                return currents;
        } else {
                struct current_thread *temp = currents;
 
-               while (temp->next != NULL)
+               while (temp->next)
                        temp = temp->next;
 
                temp->next = ct;
@@ -640,13 +640,13 @@ static struct threads *liste_add_task(struct threads *task_list, struct threads
        t->next = NULL;
 
        if (*last == NULL)
-               if (task_list == NULL) {
+               if (!task_list) {
                        task_list = t;
                        return task_list;
                } else {
                        struct threads *temp = task_list;
 
-                       while (temp->next != NULL)
+                       while (temp->next)
                                temp = temp->next;
 
                        temp->next = t;
@@ -668,15 +668,15 @@ static int current_base_addr(struct linux_os *linux_os, uint32_t base_addr)
        struct current_thread *ct = linux_os->current_threads;
 #ifdef PID_CHECK
 
-       while ((ct != NULL) && (ct->pid != pid))
+       while ((ct) && (ct->pid != pid))
 #else
-       while ((ct != NULL) && (ct->TS != base_addr))
+       while ((ct) && (ct->TS != base_addr))
 #endif
                ct = ct->next;
 #ifdef PID_CHECK
-       if ((ct != NULL) && (ct->pid == pid))
+       if ((ct) && (ct->pid == pid))
 #else
-       if ((ct != NULL) && (ct->TS == base_addr))
+       if ((ct) && (ct->TS == base_addr))
 #endif
                return 1;
 
@@ -777,7 +777,7 @@ static int clean_threadlist(struct target *target)
                target->rtos->rtos_specific_params;
        struct threads *old, *temp = linux_os->thread_list;
 
-       while (temp != NULL) {
+       while (temp) {
                old = temp;
 
                free(temp->context);
@@ -815,10 +815,10 @@ static int insert_into_threadlist(struct target *target, struct threads *t)
        t->status = 1;
        t->next = NULL;
 
-       if (temp == NULL)
+       if (!temp)
                linux_os->thread_list = t;
        else {
-               while (temp->next != NULL)
+               while (temp->next)
                        temp = temp->next;
 
                t->next = NULL;
@@ -836,7 +836,7 @@ static void linux_identify_current_threads(struct target *target)
        struct current_thread *ct = linux_os->current_threads;
        struct threads *t = NULL;
 
-       while ((ct != NULL)) {
+       while ((ct)) {
                if (ct->threadid == -1) {
 
                        /*  un-identified thread */
@@ -856,7 +856,7 @@ error_handling:
 
                        /* search in the list of threads if pid
                           already present */
-                       while ((thread_list != NULL) && (found == 0)) {
+                       while ((thread_list) && (found == 0)) {
 #ifdef PID_CHECK
                                if (thread_list->pid == t->pid) {
 #else
@@ -926,7 +926,7 @@ static int linux_task_update(struct target *target, int context)
        linux_os->thread_count = 0;
 
        /*thread_list = thread_list->next; skip init_task*/
-       while (thread_list != NULL) {
+       while (thread_list) {
                thread_list->status = 0;        /*setting all tasks to dead state*/
 
                free(thread_list->context);
@@ -967,7 +967,7 @@ static int linux_task_update(struct target *target, int context)
 
                thread_list = linux_os->thread_list;
 
-               while (thread_list != NULL) {
+               while (thread_list) {
 #ifdef PID_CHECK
                        if (t->pid == thread_list->pid) {
 #else
@@ -1058,7 +1058,7 @@ static int linux_gdb_thread_packet(struct target *target,
        tmp_str += sprintf(tmp_str, "m");
        struct threads *temp = linux_os->thread_list;
 
-       while (temp != NULL) {
+       while (temp) {
                tmp_str += sprintf(tmp_str, "%016" PRIx64, temp->threadid);
                temp = temp->next;
                if (temp)
@@ -1079,7 +1079,7 @@ static int linux_gdb_thread_update(struct target *target,
                target->rtos->rtos_specific_params;
        struct threads *temp = linux_os->thread_list;
 
-       while (temp != NULL) {
+       while (temp) {
                if (temp->threadid == linux_os->preupdtate_threadid_count + 1) {
                        /*LOG_INFO("FOUND");*/
                        found = 1;
@@ -1098,7 +1098,7 @@ static int linux_gdb_thread_update(struct target *target,
 
                temp = temp->next;
 
-               while (temp != NULL) {
+               while (temp) {
                        /*LOG_INFO("INTO GDB THREAD UPDATE WHILE");*/
                        tmp_strr += sprintf(tmp_strr, ",");
                        tmp_strr +=
@@ -1128,7 +1128,7 @@ static int linux_thread_extra_info(struct target *target,
        /*LOG_INFO("lookup extra info for thread %" SCNx64, threadid);*/
        struct threads *temp = linux_os->thread_list;
 
-       while (temp != NULL) {
+       while (temp) {
                if (temp->threadid == threadid) {
                        char *pid = " PID: ";
                        char *pid_current = "*PID: ";
@@ -1176,7 +1176,7 @@ static int linux_gdb_t_packet(struct connection *connection,
                struct threads *temp = linux_os->thread_list;
                struct threads *prev = NULL;
 
-               while (temp != NULL) {
+               while (temp) {
                        if (temp->threadid == threadid) {
                                if (temp->status != 0) {
                                        gdb_put_packet(connection, "OK", 2);
@@ -1205,7 +1205,7 @@ static int linux_gdb_t_packet(struct connection *connection,
                retval = linux_task_update(target, 1);
                struct threads *temp = linux_os->thread_list;
 
-               while (temp != NULL) {
+               while (temp) {
                        if (temp->threadid == threadid) {
                                if (temp->status == 1) {
                                        gdb_put_packet(connection, "OK", 2);
@@ -1231,20 +1231,20 @@ static int linux_gdb_h_packet(struct connection *connection,
        struct current_thread *ct = linux_os->current_threads;
 
        /* select to display the current thread of the selected target */
-       while ((ct != NULL) && (ct->core_id != target->coreid))
+       while ((ct) && (ct->core_id != target->coreid))
                ct = ct->next;
 
        int64_t current_gdb_thread_rq;
 
        if (linux_os->threads_lookup == 1) {
-               if ((ct != NULL) && (ct->threadid == -1)) {
+               if ((ct) && (ct->threadid == -1)) {
                        ct = linux_os->current_threads;
 
-                       while ((ct != NULL) && (ct->threadid == -1))
+                       while ((ct) && (ct->threadid == -1))
                                ct = ct->next;
                }
 
-               if (ct == NULL) {
+               if (!ct) {
                        /*  no current thread can be identified
                         *  any way with smp  */
                        LOG_INFO("no current thread identified");
@@ -1253,7 +1253,7 @@ static int linux_gdb_h_packet(struct connection *connection,
                        struct threads t;
                        ct = linux_os->current_threads;
 
-                       while ((ct != NULL) && (ct->threadid == -1)) {
+                       while ((ct) && (ct->threadid == -1)) {
                                t.base_addr = ct->TS;
                                get_name(target, &t);
                                LOG_INFO("name of unidentified thread %s",
@@ -1321,7 +1321,7 @@ static int linux_thread_packet(struct connection *connection, char const *packet
 
                                break;
                        } else if (strncmp(packet, "qfThreadInfo", 12) == 0) {
-                               if (linux_os->thread_list == NULL) {
+                               if (!linux_os->thread_list) {
                                        retval = linux_gdb_thread_packet(target,
                                                        connection,
                                                        packet,
@@ -1356,17 +1356,17 @@ static int linux_thread_packet(struct connection *connection, char const *packet
                        if (linux_os->threads_lookup == 1) {
                                ct = linux_os->current_threads;
 
-                               while ((ct != NULL) && (ct->core_id) != target->coreid)
+                               while ((ct) && (ct->core_id) != target->coreid)
                                        ct = ct->next;
 
-                               if ((ct != NULL) && (ct->threadid == -1)) {
+                               if ((ct) && (ct->threadid == -1)) {
                                        ct = linux_os->current_threads;
 
-                                       while ((ct != NULL) && (ct->threadid == -1))
+                                       while ((ct) && (ct->threadid == -1))
                                                ct = ct->next;
                                }
 
-                               if ((ct != NULL) && (ct->threadid !=
+                               if ((ct) && (ct->threadid !=
                                                 target->rtos->current_threadid)
                                && (target->rtos->current_threadid != -1))
                                        LOG_WARNING("WARNING! current GDB thread do not match "
@@ -1478,7 +1478,7 @@ static char *linux_ps_command(struct target *target)
                tmp += sprintf(tmp, "PID\t\tCPU\t\tASID\t\tNAME\n");
                tmp += sprintf(tmp, "---\t\t---\t\t----\t\t----\n");
 
-               while (temp != NULL) {
+               while (temp) {
                        if (temp->status) {
                                if (temp->context)
                                        tmp +=
index 9f59c6d7ccd1a26b68dce5e457b9cb23b375bfcd..f6be35b6cc57ed6aa2f5b70b854c9bbd543ea3f5 100644 (file)
@@ -318,7 +318,7 @@ static int mqx_update_threads(
        rtos->thread_count = task_queue_size;
        rtos->current_thread = 0;
        rtos->thread_details = calloc(rtos->thread_count, sizeof(struct thread_detail));
-       if (NULL == rtos->thread_details)
+       if (!rtos->thread_details)
                return ERROR_FAIL;
 
        /*      loop over each task and setup thread details,
index c52547120c1383688324520d6c9819bbab2fdada..00fec7fb764580d6ef5f5b7c95d5dc7572d700a0 100644 (file)
@@ -259,7 +259,7 @@ static int nuttx_update_threads(struct rtos *rtos)
        uint32_t i;
        uint8_t state;
 
-       if (rtos->symbols == NULL) {
+       if (!rtos->symbols) {
                LOG_ERROR("No symbols for NuttX");
                return -3;
        }
index 9165fe11b341bf46edc93062c872614d87bf7ccb..2316f17b5440e0a9e1de0334b51fd0c191b585eb 100644 (file)
@@ -121,15 +121,15 @@ static int riot_update_threads(struct rtos *rtos)
        unsigned int tasks_found = 0;
        const struct riot_params *param;
 
-       if (rtos == NULL)
+       if (!rtos)
                return ERROR_FAIL;
 
-       if (rtos->rtos_specific_params == NULL)
+       if (!rtos->rtos_specific_params)
                return ERROR_FAIL;
 
        param = (const struct riot_params *)rtos->rtos_specific_params;
 
-       if (rtos->symbols == NULL) {
+       if (!rtos->symbols) {
                LOG_ERROR("No symbols for RIOT");
                return ERROR_FAIL;
        }
@@ -202,7 +202,7 @@ static int riot_update_threads(struct rtos *rtos)
 
        /* Allocate memory for thread description */
        rtos->thread_details = calloc(thread_count, sizeof(struct thread_detail));
-       if (rtos->thread_details == NULL) {
+       if (!rtos->thread_details) {
                LOG_ERROR("RIOT: out of memory");
                return ERROR_FAIL;
        }
@@ -321,13 +321,13 @@ static int riot_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
        int retval;
        const struct riot_params *param;
 
-       if (rtos == NULL)
+       if (!rtos)
                return ERROR_FAIL;
 
        if (thread_id == 0)
                return ERROR_FAIL;
 
-       if (rtos->rtos_specific_params == NULL)
+       if (!rtos->rtos_specific_params)
                return ERROR_FAIL;
 
        param = (const struct riot_params *)rtos->rtos_specific_params;
index 7d96825b975749f95ced4c0460ca29fd4e151c47..54e9926f1cc222f3da9e3da98cf278e8cd6fa63a 100644 (file)
@@ -172,7 +172,7 @@ void rtos_destroy(struct target *target)
 int gdb_thread_packet(struct connection *connection, char const *packet, int packet_size)
 {
        struct target *target = get_target_from_connection(connection);
-       if (target->rtos == NULL)
+       if (!target->rtos)
                return rtos_thread_packet(connection, packet, packet_size);     /* thread not
                                                                                 *found*/
        return target->rtos->gdb_thread_packet(connection, packet, packet_size);
@@ -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 != NULL) && (target->rtos->thread_details != NULL) &&
+               if ((target->rtos) && (target->rtos->thread_details != NULL) &&
                                (target->rtos->thread_count != 0)) {
                        threadid_t threadid = 0;
                        int found = -1;
                        sscanf(packet, "qThreadExtraInfo,%" SCNx64, &threadid);
 
-                       if ((target->rtos != NULL) && (target->rtos->thread_details != NULL)) {
+                       if ((target->rtos) && (target->rtos->thread_details != NULL)) {
                                int thread_num;
                                for (thread_num = 0; thread_num < target->rtos->thread_count; thread_num++) {
                                        if (target->rtos->thread_details[thread_num].threadid == threadid) {
@@ -329,17 +329,17 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa
                        struct thread_detail *detail = &target->rtos->thread_details[found];
 
                        int str_size = 0;
-                       if (detail->thread_name_str != NULL)
+                       if (detail->thread_name_str)
                                str_size += strlen(detail->thread_name_str);
-                       if (detail->extra_info_str != NULL)
+                       if (detail->extra_info_str)
                                str_size += strlen(detail->extra_info_str);
 
                        char *tmp_str = calloc(str_size + 9, sizeof(char));
                        char *tmp_str_ptr = tmp_str;
 
-                       if (detail->thread_name_str != NULL)
+                       if (detail->thread_name_str)
                                tmp_str_ptr += sprintf(tmp_str_ptr, "Name: %s", detail->thread_name_str);
-                       if (detail->extra_info_str != NULL) {
+                       if (detail->extra_info_str) {
                                if (tmp_str_ptr != tmp_str)
                                        tmp_str_ptr += sprintf(tmp_str_ptr, ", ");
                                tmp_str_ptr += sprintf(tmp_str_ptr, "%s", detail->extra_info_str);
@@ -371,7 +371,7 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa
                return ERROR_OK;
        } else if (strncmp(packet, "qfThreadInfo", 12) == 0) {
                int i;
-               if (target->rtos != NULL) {
+               if (target->rtos) {
                        if (target->rtos->thread_count == 0) {
                                gdb_put_packet(connection, "l", 1);
                        } else {
@@ -404,7 +404,7 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa
                 * otherwise it gets incorrectly handled */
                return GDB_THREAD_PACKET_NOT_CONSUMED;
        } else if (strncmp(packet, "qC", 2) == 0) {
-               if (target->rtos != NULL) {
+               if (target->rtos) {
                        char buffer[19];
                        int size;
                        size = snprintf(buffer, 19, "QC%016" PRIx64, target->rtos->current_thread);
@@ -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 != NULL) && (target->rtos->thread_details != NULL)) {
+               if ((target->rtos) && (target->rtos->thread_details != NULL)) {
                        int thread_num;
                        for (thread_num = 0; thread_num < target->rtos->thread_count; thread_num++) {
                                if (target->rtos->thread_details[thread_num].threadid == threadid) {
@@ -432,7 +432,7 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa
                return ERROR_OK;
        } else if (packet[0] == 'H') {  /* Set current thread ( 'c' for step and continue, 'g' for
                                         * all other operations ) */
-               if ((packet[1] == 'g') && (target->rtos != NULL)) {
+               if ((packet[1] == 'g') && (target->rtos)) {
                        threadid_t threadid;
                        sscanf(packet, "Hg%16" SCNx64, &threadid);
                        LOG_DEBUG("RTOS: GDB requested to set current thread to 0x%" PRIx64, threadid);
@@ -477,7 +477,7 @@ int rtos_get_gdb_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 != NULL) && (current_threadid != -1) &&
+       if ((target->rtos) && (current_threadid != -1) &&
                        (current_threadid != 0) &&
                        ((current_threadid != target->rtos->current_thread) ||
                        (target->smp))) {       /* in smp several current thread are possible */
@@ -529,7 +529,7 @@ int rtos_get_gdb_reg_list(struct connection *connection)
 {
        struct target *target = get_target_from_connection(connection);
        int64_t current_threadid = target->rtos->current_threadid;
-       if ((target->rtos != NULL) && (current_threadid != -1) &&
+       if ((target->rtos) && (current_threadid != -1) &&
                        (current_threadid != 0) &&
                        ((current_threadid != target->rtos->current_thread) ||
                        (target->smp))) {       /* in smp several current thread are possible */
@@ -563,7 +563,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 != NULL) &&
+       if ((target->rtos) &&
                        (target->rtos->type->set_reg != NULL) &&
                        (current_threadid != -1) &&
                        (current_threadid != 0)) {
@@ -606,7 +606,7 @@ int rtos_generic_stack_read(struct target *target,
 #endif
 
        int64_t new_stack_ptr;
-       if (stacking->calculate_process_stack != NULL) {
+       if (stacking->calculate_process_stack) {
                new_stack_ptr = stacking->calculate_process_stack(target,
                                stack_data, stacking, stack_ptr);
        } else {
@@ -657,7 +657,7 @@ static int rtos_try_next(struct target *target)
 
 int rtos_update_threads(struct target *target)
 {
-       if ((target->rtos != NULL) && (target->rtos->type != NULL))
+       if ((target->rtos) && (target->rtos->type != NULL))
                target->rtos->type->update_threads(target->rtos);
        return ERROR_OK;
 }
index 26b53a9271dda022bdc29526a1790b6b73885f6d..4cdf72de9c8527e3ee3f2be822f9eb0f30250983 100644 (file)
@@ -278,7 +278,7 @@ static int ucos_iii_create(struct target *target)
        for (size_t i = 0; i < ARRAY_SIZE(ucos_iii_params_list); i++)
                if (strcmp(ucos_iii_params_list[i].target_name, target->type->name) == 0) {
                        params = malloc(sizeof(*params) + (UCOS_III_MAX_THREADS * sizeof(*params->threads)));
-                       if (params == NULL) {
+                       if (!params) {
                                LOG_ERROR("uCOS-III: out of memory");
                                return ERROR_FAIL;
                        }
@@ -300,7 +300,7 @@ static int ucos_iii_update_threads(struct rtos *rtos)
        struct ucos_iii_params *params = rtos->rtos_specific_params;
        int retval;
 
-       if (rtos->symbols == NULL) {
+       if (!rtos->symbols) {
                LOG_ERROR("uCOS-III: symbol list not loaded");
                return ERROR_FAIL;
        }
@@ -326,7 +326,7 @@ static int ucos_iii_update_threads(struct rtos *rtos)
 
        if (!rtos_running) {
                rtos->thread_details = calloc(1, sizeof(struct thread_detail));
-               if (rtos->thread_details == NULL) {
+               if (!rtos->thread_details) {
                        LOG_ERROR("uCOS-III: out of memory");
                        return ERROR_FAIL;
                }
@@ -369,7 +369,7 @@ static int ucos_iii_update_threads(struct rtos *rtos)
        }
 
        rtos->thread_details = calloc(rtos->thread_count, sizeof(struct thread_detail));
-       if (rtos->thread_details == NULL) {
+       if (!rtos->thread_details) {
                LOG_ERROR("uCOS-III: out of memory");
                return ERROR_FAIL;
        }
index b594b2b531366f3f487d3a2f1e037e8745c3caec..ef5ff5879158ff40a775316383b1841f6bfb4a1f 100644 (file)
@@ -745,14 +745,14 @@ static int zephyr_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
 
        LOG_INFO("Getting thread %" PRId64 " reg list", thread_id);
 
-       if (rtos == NULL)
+       if (!rtos)
                return ERROR_FAIL;
 
        if (thread_id == 0)
                return ERROR_FAIL;
 
        params = rtos->rtos_specific_params;
-       if (params == NULL)
+       if (!params)
                return ERROR_FAIL;
 
        addr = thread_id + params->offsets[OFFSET_T_STACK_POINTER]
index 2853f05d9d452927d087ebb8990e42d760f366fc..bc3a675cf682f3be5e52a1b3f0a8d0b97aeca3b7 100644 (file)
@@ -177,7 +177,7 @@ static int check_pending(struct connection *connection,
        fd_set read_fds;
        struct gdb_connection *gdb_con = connection->priv;
        int t;
-       if (got_data == NULL)
+       if (!got_data)
                got_data = &t;
        *got_data = 0;
 
@@ -369,7 +369,7 @@ static void gdb_log_incoming_packet(char *packet)
                /* Does packet at least have a prefix that is printable?
                 * Look within the first 50 chars of the packet. */
                const char *colon = memchr(packet, ':', MIN(50, packet_len));
-               const bool packet_has_prefix = (colon != NULL);
+               const bool packet_has_prefix = (colon);
                const bool packet_prefix_printable = (packet_has_prefix && nonprint > colon);
 
                if (packet_prefix_printable) {
@@ -737,7 +737,7 @@ static int gdb_output_con(struct connection *connection, const char *line)
        bin_size = strlen(line);
 
        hex_buffer = malloc(bin_size * 2 + 2);
-       if (hex_buffer == NULL)
+       if (!hex_buffer)
                return ERROR_GDB_BUFFER_TOO_SMALL;
 
        hex_buffer[0] = 'O';
@@ -771,7 +771,7 @@ static void gdb_signal_reply(struct target *target, struct connection *connectio
                sig_reply_len = snprintf(sig_reply, sizeof(sig_reply), "W00");
        } else {
                struct target *ct;
-               if (target->rtos != NULL) {
+               if (target->rtos) {
                        target->rtos->current_threadid = target->rtos->current_thread;
                        target->rtos->gdb_target_for_threadid(connection, target->rtos->current_threadid, &ct);
                } else {
@@ -810,7 +810,7 @@ static void gdb_signal_reply(struct target *target, struct connection *connectio
                }
 
                current_thread[0] = '\0';
-               if (target->rtos != NULL)
+               if (target->rtos)
                        snprintf(current_thread, sizeof(current_thread), "thread:%" PRIx64 ";",
                                        target->rtos->current_thread);
 
@@ -1212,7 +1212,7 @@ static int gdb_get_registers_packet(struct connection *connection,
        LOG_DEBUG("-");
 #endif
 
-       if ((target->rtos != NULL) && (ERROR_OK == rtos_get_gdb_reg_list(connection)))
+       if ((target->rtos) && (ERROR_OK == rtos_get_gdb_reg_list(connection)))
                return ERROR_OK;
 
        retval = target_get_gdb_reg_list(target, &reg_list, &reg_list_size,
@@ -1229,7 +1229,7 @@ static int gdb_get_registers_packet(struct connection *connection,
        assert(reg_packet_size > 0);
 
        reg_packet = malloc(reg_packet_size + 1); /* plus one for string termination null */
-       if (reg_packet == NULL)
+       if (!reg_packet)
                return ERROR_FAIL;
 
        reg_packet_p = reg_packet;
@@ -1342,7 +1342,7 @@ static int gdb_get_register_packet(struct connection *connection,
        LOG_DEBUG("-");
 #endif
 
-       if ((target->rtos != NULL) && (ERROR_OK == rtos_get_gdb_reg(connection, reg_num)))
+       if ((target->rtos) && (ERROR_OK == rtos_get_gdb_reg(connection, reg_num)))
                return ERROR_OK;
 
        retval = target_get_gdb_reg_list_noread(target, &reg_list, &reg_list_size,
@@ -1398,7 +1398,7 @@ static int gdb_set_register_packet(struct connection *connection,
        uint8_t *bin_buf = malloc(chars / 2);
        gdb_target_to_reg(target, separator + 1, chars, bin_buf);
 
-       if ((target->rtos != NULL) &&
+       if ((target->rtos) &&
                        (ERROR_OK == rtos_set_reg(connection, reg_num, bin_buf))) {
                free(bin_buf);
                gdb_put_packet(connection, "OK", 2);
@@ -1824,7 +1824,7 @@ static int decode_xfer_read(char const *buf, char **annex, int *ofs, unsigned in
 {
        /* Locate the annex. */
        const char *annex_end = strchr(buf, ':');
-       if (annex_end == NULL)
+       if (!annex_end)
                return ERROR_FAIL;
 
        /* After the read marker and annex, qXfer looks like a
@@ -1838,7 +1838,7 @@ static int decode_xfer_read(char const *buf, char **annex, int *ofs, unsigned in
        *len = strtoul(separator + 1, NULL, 16);
 
        /* Extract the annex if needed */
-       if (annex != NULL) {
+       if (annex) {
                *annex = strndup(buf, annex_end - buf);
                if (*annex == NULL)
                        return ERROR_FAIL;
@@ -2102,7 +2102,7 @@ static int gdb_generate_reg_type_description(struct target *target,
        } else if (type->type_class == REG_TYPE_CLASS_UNION) {
                struct reg_data_type_union_field *field;
                field = type->reg_type_union->fields;
-               while (field != NULL) {
+               while (field) {
                        struct reg_data_type *data_type = field->type;
                        if (data_type->type == REG_TYPE_ARCH_DEFINED) {
                                if (lookup_add_arch_defined_types(arch_defined_types_list, data_type->id,
@@ -2122,7 +2122,7 @@ static int gdb_generate_reg_type_description(struct target *target,
                                type->id);
 
                field = type->reg_type_union->fields;
-               while (field != NULL) {
+               while (field) {
                        xml_printf(&retval, tdesc, pos, size,
                                        "<field name=\"%s\" type=\"%s\"/>\n",
                                        field->name, field->type->id);
@@ -2144,7 +2144,7 @@ static int gdb_generate_reg_type_description(struct target *target,
                        xml_printf(&retval, tdesc, pos, size,
                                        "<struct id=\"%s\" size=\"%" PRIu32 "\">\n",
                                        type->id, type->reg_type_struct->size);
-                       while (field != NULL) {
+                       while (field) {
                                xml_printf(&retval, tdesc, pos, size,
                                                "<field name=\"%s\" start=\"%" PRIu32 "\" end=\"%" PRIu32 "\" type=\"%s\" />\n",
                                                field->name, field->bitfield->start, field->bitfield->end,
@@ -2153,7 +2153,7 @@ static int gdb_generate_reg_type_description(struct target *target,
                                field = field->next;
                        }
                } else {
-                       while (field != NULL) {
+                       while (field) {
                                struct reg_data_type *data_type = field->type;
                                if (data_type->type == REG_TYPE_ARCH_DEFINED) {
                                        if (lookup_add_arch_defined_types(arch_defined_types_list, data_type->id,
@@ -2170,7 +2170,7 @@ static int gdb_generate_reg_type_description(struct target *target,
                        xml_printf(&retval, tdesc, pos, size,
                                        "<struct id=\"%s\">\n",
                                        type->id);
-                       while (field != NULL) {
+                       while (field) {
                                xml_printf(&retval, tdesc, pos, size,
                                                "<field name=\"%s\" type=\"%s\"/>\n",
                                                field->name, field->type->id);
@@ -2192,7 +2192,7 @@ static int gdb_generate_reg_type_description(struct target *target,
 
                struct reg_data_type_flags_field *field;
                field = type->reg_type_flags->fields;
-               while (field != NULL) {
+               while (field) {
                        xml_printf(&retval, tdesc, pos, size,
                                        "<field name=\"%s\" start=\"%" PRIu32 "\" end=\"%" PRIu32 "\" type=\"%s\" />\n",
                                        field->name, field->bitfield->start, field->bitfield->end,
@@ -2297,12 +2297,12 @@ static int gdb_generate_target_description(struct target *target, char **tdesc_o
 
        /* generate architecture element if supported by target */
        architecture = target_get_gdb_arch(target);
-       if (architecture != NULL)
+       if (architecture)
                xml_printf(&retval, &tdesc, &pos, &size,
                                "<architecture>%s</architecture>\n", architecture);
 
        /* generate target description according to register list */
-       if (features != NULL) {
+       if (features) {
                while (features[current_feature]) {
                        char const **arch_defined_types = NULL;
                        int num_arch_defined_types = 0;
@@ -2394,7 +2394,7 @@ error:
 static int gdb_get_target_description_chunk(struct target *target, struct target_desc_format *target_desc,
                char **chunk, int32_t offset, uint32_t length)
 {
-       if (target_desc == NULL) {
+       if (!target_desc) {
                LOG_ERROR("Unable to Generate Target Description");
                return ERROR_FAIL;
        }
@@ -2402,7 +2402,7 @@ static int gdb_get_target_description_chunk(struct target *target, struct target
        char *tdesc = target_desc->tdesc;
        uint32_t tdesc_length = target_desc->tdesc_length;
 
-       if (tdesc == NULL) {
+       if (!tdesc) {
                int retval = gdb_generate_target_description(target, &tdesc);
                if (retval != ERROR_OK) {
                        LOG_ERROR("Unable to Generate Target Description");
@@ -2502,7 +2502,7 @@ static int gdb_generate_thread_list(struct target *target, char **thread_list_ou
                   "<?xml version=\"1.0\"?>\n"
                   "<threads>\n");
 
-       if (rtos != NULL) {
+       if (rtos) {
                for (int i = 0; i < rtos->thread_count; i++) {
                        struct thread_detail *thread_detail = &rtos->thread_details[i];
 
@@ -2512,12 +2512,12 @@ static int gdb_generate_thread_list(struct target *target, char **thread_list_ou
                        xml_printf(&retval, &thread_list, &pos, &size,
                                   "<thread id=\"%" PRIx64 "\">", thread_detail->threadid);
 
-                       if (thread_detail->thread_name_str != NULL)
+                       if (thread_detail->thread_name_str)
                                xml_printf(&retval, &thread_list, &pos, &size,
                                           "Name: %s", thread_detail->thread_name_str);
 
-                       if (thread_detail->extra_info_str != NULL) {
-                               if (thread_detail->thread_name_str != NULL)
+                       if (thread_detail->extra_info_str) {
+                               if (thread_detail->thread_name_str)
                                        xml_printf(&retval, &thread_list, &pos, &size,
                                                   ", ");
                                xml_printf(&retval, &thread_list, &pos, &size,
@@ -2825,12 +2825,12 @@ static bool gdb_handle_vcont_packet(struct connection *connection, const char *p
                        packet_size -= 2;
 
                        thread_id = strtoll(parse, &endp, 16);
-                       if (endp != NULL) {
+                       if (endp) {
                                packet_size -= endp - parse;
                                parse = endp;
                        }
 
-                       if (target->rtos != NULL) {
+                       if (target->rtos) {
                                /* FIXME: why is this necessary? rtos state should be up-to-date here already! */
                                rtos_update_threads(target);
 
@@ -2948,7 +2948,7 @@ static char *next_hex_encoded_field(const char **str, char sep)
                return NULL;
 
        const char *end = strchr(hex, sep);
-       if (end == NULL)
+       if (!end)
                hexlen = strlen(hex);
        else
                hexlen = end - hex;
@@ -2961,7 +2961,7 @@ static char *next_hex_encoded_field(const char **str, char sep)
 
        size_t count = hexlen / 2;
        char *decoded = malloc(count + 1);
-       if (decoded == NULL)
+       if (!decoded)
                return NULL;
 
        size_t converted = unhexify((void *)decoded, hex, count);
@@ -3014,8 +3014,8 @@ static bool gdb_handle_vrun_packet(struct connection *connection, const char *pa
                cmdline = new_cmdline;
        }
 
-       if (cmdline != NULL) {
-               if (target->semihosting != NULL) {
+       if (cmdline) {
+               if (target->semihosting) {
                        LOG_INFO("GDB set inferior command line to '%s'", cmdline);
                        free(target->semihosting->cmdline);
                        target->semihosting->cmdline = cmdline;
@@ -3142,7 +3142,7 @@ static int gdb_v_packet(struct connection *connection,
                length = packet_size - (parse - packet);
 
                /* create a new image if there isn't already one */
-               if (gdb_connection->vflash_image == NULL) {
+               if (!gdb_connection->vflash_image) {
                        gdb_connection->vflash_image = malloc(sizeof(struct image));
                        image_open(gdb_connection->vflash_image, "", "build");
                }
@@ -3531,7 +3531,7 @@ static int gdb_target_start(struct target *target, const char *port)
        int ret;
        gdb_service = malloc(sizeof(struct gdb_service));
 
-       if (NULL == gdb_service)
+       if (!gdb_service)
                return -ENOMEM;
 
        LOG_INFO("starting gdb server for %s on %s", target_name(target), port);
@@ -3615,12 +3615,12 @@ static int gdb_target_add_one(struct target *target)
 
 int gdb_target_add_all(struct target *target)
 {
-       if (NULL == target) {
+       if (!target) {
                LOG_WARNING("gdb services need one or more targets defined");
                return ERROR_OK;
        }
 
-       while (NULL != target) {
+       while (target) {
                int retval = gdb_target_add_one(target);
                if (retval != ERROR_OK)
                        return retval;
@@ -3636,7 +3636,7 @@ COMMAND_HANDLER(handle_gdb_sync_command)
        if (CMD_ARGC != 0)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
-       if (current_gdb_connection == NULL) {
+       if (!current_gdb_connection) {
                command_print(CMD,
                        "gdb_sync command can only be run from within gdb using \"monitor gdb_sync\"");
                return ERROR_FAIL;
@@ -3745,7 +3745,7 @@ COMMAND_HANDLER(handle_gdb_save_tdesc_command)
        size_t size_written;
 
        char *tdesc_filename = alloc_printf("%s.xml", target_type_name(target));
-       if (tdesc_filename == NULL) {
+       if (!tdesc_filename) {
                retval = ERROR_FAIL;
                goto out;
        }
index 5f18efce3ec13aa6f84159d6434ef5a67d8ab52d..6f0b23caac407cc092112480bb2ccb2cf580a3b9 100644 (file)
@@ -263,11 +263,11 @@ int add_service(char *name,
                memset(&c->sin, 0, sizeof(c->sin));
                c->sin.sin_family = AF_INET;
 
-               if (bindto_name == NULL)
+               if (!bindto_name)
                        c->sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
                else {
                        hp = gethostbyname(bindto_name);
-                       if (hp == NULL) {
+                       if (!hp) {
                                LOG_ERROR("couldn't resolve bindto address: %s", bindto_name);
                                close_socket(c->fd);
                                free_service(c);
index 1ecb827a1ab007325d9ec5fa4c41c5b6f20eadbc..92a8026cf346c924fc680a9fd2254a66ed5d441d 100644 (file)
@@ -145,12 +145,12 @@ static int tcl_new_connection(struct connection *connection)
        struct tcl_connection *tclc;
 
        tclc = calloc(1, sizeof(struct tcl_connection));
-       if (tclc == NULL)
+       if (!tclc)
                return ERROR_CONNECTION_REJECTED;
 
        tclc->tc_line_size = TCL_LINE_INITIAL;
        tclc->tc_line = malloc(tclc->tc_line_size);
-       if (tclc->tc_line == NULL) {
+       if (!tclc->tc_line) {
                free(tclc);
                return ERROR_CONNECTION_REJECTED;
        }
@@ -158,7 +158,7 @@ static int tcl_new_connection(struct connection *connection)
        connection->priv = tclc;
 
        struct target *target = get_current_target_or_null(connection->cmd_ctx);
-       if (target != NULL)
+       if (target)
                tclc->tc_laststate = target->state;
 
        /* store the connection object on cmd_ctx so we can access it from command handlers */
@@ -192,7 +192,7 @@ static int tcl_input(struct connection *connection)
        }
 
        tclc = connection->priv;
-       if (tclc == NULL)
+       if (!tclc)
                return ERROR_CONNECTION_REJECTED;
 
        /* push as much data into the line as possible */
@@ -215,7 +215,7 @@ static int tcl_input(struct connection *connection)
                                tc_line_size_new = TCL_LINE_MAX;
 
                        tc_line_new = realloc(tclc->tc_line, tc_line_size_new);
-                       if (tc_line_new == NULL) {
+                       if (!tc_line_new) {
                                tclc->tc_linedrop = 1;
                        } else {
                                tclc->tc_line = tc_line_new;
index 2ad3791d708d0b05c5ba628f8ddca0a456d089bf..b01046d9adfe18084422dc069ae15defcaa3328f 100644 (file)
@@ -150,7 +150,7 @@ static void telnet_load_history(struct telnet_connection *t_con)
 
        char *history = get_home_dir(TELNET_HISTORY);
 
-       if (history == NULL) {
+       if (!history) {
                LOG_INFO("unable to get user home directory, telnet history will be disabled");
                return;
        }
@@ -186,7 +186,7 @@ static void telnet_save_history(struct telnet_connection *t_con)
 
        char *history = get_home_dir(TELNET_HISTORY);
 
-       if (history == NULL) {
+       if (!history) {
                LOG_INFO("unable to get user home directory, telnet history will be disabled");
                return;
        }
index 10ad7e7136dd324cfd7e566792d922b4e830b435..e12fbce23cc5913eac488da9614c5045b06b3603 100644 (file)
@@ -302,7 +302,7 @@ static int svf_realloc_buffers(size_t len)
 
 static void svf_free_xxd_para(struct svf_xxr_para *para)
 {
-       if (NULL != para) {
+       if (para) {
                free(para->tdi);
                para->tdi = NULL;
 
@@ -395,7 +395,7 @@ COMMAND_HANDLER(handle_svf_command)
                        svf_ignore_error = 1;
                else {
                        svf_fd = fopen(CMD_ARGV[i], "r");
-                       if (svf_fd == NULL) {
+                       if (!svf_fd) {
                                int err = errno;
                                command_print(CMD, "open(\"%s\"): %s", CMD_ARGV[i], strerror(err));
                                /* no need to free anything now */
@@ -405,7 +405,7 @@ COMMAND_HANDLER(handle_svf_command)
                }
        }
 
-       if (svf_fd == NULL)
+       if (!svf_fd)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        /* get time */
@@ -417,7 +417,7 @@ COMMAND_HANDLER(handle_svf_command)
 
        svf_check_tdo_para_index = 0;
        svf_check_tdo_para = malloc(sizeof(struct svf_check_tdo_para) * SVF_CHECK_TDO_PARA_SIZE);
-       if (NULL == svf_check_tdo_para) {
+       if (!svf_check_tdo_para) {
                LOG_ERROR("not enough memory");
                ret = ERROR_FAIL;
                goto free_all;
@@ -675,7 +675,7 @@ static int svf_read_command_from_file(FILE *fd)
                                if (cmd_pos + 3 > svf_command_buffer_size) {
                                        svf_command_buffer = realloc(svf_command_buffer, cmd_pos + 3);
                                        svf_command_buffer_size = cmd_pos + 3;
-                                       if (svf_command_buffer == NULL) {
+                                       if (!svf_command_buffer) {
                                                LOG_ERROR("not enough memory");
                                                return ERROR_FAIL;
                                        }
@@ -1091,7 +1091,7 @@ xxr_common:
                        }
                        /* If TDO is absent, no comparison is needed, set the mask to 0 */
                        if (!(xxr_para_tmp->data_mask & XXR_TDO)) {
-                               if (NULL == xxr_para_tmp->tdo) {
+                               if (!xxr_para_tmp->tdo) {
                                        if (ERROR_OK !=
                                        svf_adjust_array_length(&xxr_para_tmp->tdo, i_tmp,
                                                xxr_para_tmp->len)) {
@@ -1099,7 +1099,7 @@ xxr_common:
                                                return ERROR_FAIL;
                                        }
                                }
-                               if (NULL == xxr_para_tmp->mask) {
+                               if (!xxr_para_tmp->mask) {
                                        if (ERROR_OK !=
                                        svf_adjust_array_length(&xxr_para_tmp->mask, i_tmp,
                                                xxr_para_tmp->len)) {
@@ -1420,7 +1420,7 @@ xxr_common:
                        if (num_of_argu > 2) {
                                /* STATE pathstate1 ... stable_state */
                                path = malloc((num_of_argu - 1) * sizeof(tap_state_t));
-                               if (NULL == path) {
+                               if (!path) {
                                        LOG_ERROR("not enough memory");
                                        return ERROR_FAIL;
                                }
index 87c6bceb7681b99ce3444d6864ef6b1c32543bfc..43a13aa9c30fafd9cca8f84632ab21ea47835b23 100644 (file)
@@ -335,7 +335,7 @@ static int aarch64_prepare_halt_smp(struct target *target, bool exc_target, stru
 
        LOG_DEBUG("target %s exc %i", target_name(target), exc_target);
 
-       while (head != NULL) {
+       while (head) {
                struct target *curr = head->target;
                struct armv8_common *armv8 = target_to_armv8(curr);
                head = head->next;
@@ -359,7 +359,7 @@ static int aarch64_prepare_halt_smp(struct target *target, bool exc_target, stru
 
                LOG_DEBUG("target %s prepared", target_name(curr));
 
-               if (first == NULL)
+               if (!first)
                        first = curr;
        }
 
@@ -488,7 +488,7 @@ static int update_halt_gdb(struct target *target, enum target_debug_reason debug
                if (curr->state == TARGET_HALTED)
                        continue;
                /* remember the gdb_service->target */
-               if (curr->gdb_service != NULL)
+               if (curr->gdb_service)
                        gdb_target = curr->gdb_service->target;
                /* skip it */
                if (curr == gdb_target)
@@ -762,7 +762,7 @@ static int aarch64_prep_restart_smp(struct target *target, int handle_breakpoint
                        break;
                }
                /* remember the first valid target in the group */
-               if (first == NULL)
+               if (!first)
                        first = curr;
        }
 
@@ -785,7 +785,7 @@ static int aarch64_step_restart_smp(struct target *target)
        if (retval != ERROR_OK)
                return retval;
 
-       if (first != NULL)
+       if (first)
                retval = aarch64_do_restart_one(first, RESTART_LAZY);
        if (retval != ERROR_OK) {
                LOG_DEBUG("error restarting target %s", target_name(first));
@@ -2548,7 +2548,7 @@ static int aarch64_examine_first(struct target *target)
        uint32_t tmp0, tmp1, tmp2, tmp3;
        debug = ttypr = cpuid = 0;
 
-       if (pc == NULL)
+       if (!pc)
                return ERROR_FAIL;
 
        if (pc->adiv5_config.ap_num == DP_APSEL_INVALID) {
@@ -2634,7 +2634,7 @@ static int aarch64_examine_first(struct target *target)
        LOG_DEBUG("ttypr = 0x%08" PRIx64, ttypr);
        LOG_DEBUG("debug = 0x%08" PRIx64, debug);
 
-       if (pc->cti == NULL)
+       if (!pc->cti)
                return ERROR_FAIL;
 
        armv8->cti = pc->cti;
@@ -2739,7 +2739,7 @@ static int aarch64_target_create(struct target *target, Jim_Interp *interp)
                return ERROR_FAIL;
 
        aarch64 = calloc(1, sizeof(struct aarch64_common));
-       if (aarch64 == NULL) {
+       if (!aarch64) {
                LOG_ERROR("Out of memory");
                return ERROR_FAIL;
        }
@@ -2797,7 +2797,7 @@ static int aarch64_jim_configure(struct target *target, struct jim_getopt_info *
        int e;
 
        pc = (struct aarch64_private_config *)target->private_config;
-       if (pc == NULL) {
+       if (!pc) {
                        pc = calloc(1, sizeof(struct aarch64_private_config));
                        pc->adiv5_config.ap_num = DP_APSEL_INVALID;
                        target->private_config = pc;
@@ -2842,7 +2842,7 @@ static int aarch64_jim_configure(struct target *target, struct jim_getopt_info *
                                if (e != JIM_OK)
                                        return e;
                                cti = cti_instance_by_jim_obj(goi->interp, o_cti);
-                               if (cti == NULL) {
+                               if (!cti) {
                                        Jim_SetResultString(goi->interp, "CTI name invalid!", -1);
                                        return JIM_ERR;
                                }
@@ -2896,7 +2896,7 @@ COMMAND_HANDLER(aarch64_handle_disassemble_command)
 {
        struct target *target = get_current_target(CMD_CTX);
 
-       if (target == NULL) {
+       if (!target) {
                LOG_ERROR("No target selected");
                return ERROR_FAIL;
        }
@@ -2939,7 +2939,7 @@ COMMAND_HANDLER(aarch64_mask_interrupts_command)
 
        if (CMD_ARGC > 0) {
                n = jim_nvp_name2value_simple(nvp_maskisr_modes, CMD_ARGV[0]);
-               if (n->name == NULL) {
+               if (!n->name) {
                        LOG_ERROR("Unknown parameter: %s - should be off or on", CMD_ARGV[0]);
                        return ERROR_COMMAND_SYNTAX_ERROR;
                }
@@ -2971,10 +2971,10 @@ static int jim_mcrmrc(Jim_Interp *interp, int argc, Jim_Obj * const *argv)
        }
 
        context = current_command_context(interp);
-       assert(context != NULL);
+       assert(context);
 
        target = get_current_target(context);
-       if (target == NULL) {
+       if (!target) {
                LOG_ERROR("%s: no current target", __func__);
                return JIM_ERR;
        }
index 29bc04f6df572d11ac1626f6953f75e7599f2b66..998c51cfb2ddc94ae7f51cb9bf81c37ef91fb14b 100644 (file)
@@ -179,7 +179,7 @@ static struct dap_cmd *dap_cmd_new(struct adiv5_dap *dap, uint8_t instr,
 
        if (list_empty(&dap->cmd_pool)) {
                pool = calloc(1, sizeof(struct dap_cmd_pool));
-               if (pool == NULL)
+               if (!pool)
                        return NULL;
        } else {
                pool = list_first_entry(&dap->cmd_pool, struct dap_cmd_pool, lh);
@@ -194,9 +194,9 @@ static struct dap_cmd *dap_cmd_new(struct adiv5_dap *dap, uint8_t instr,
        cmd->instr = instr;
        cmd->reg_addr = reg_addr;
        cmd->rnw = rnw;
-       if (outvalue != NULL)
+       if (outvalue)
                memcpy(cmd->outvalue_buf, outvalue, 4);
-       cmd->invalue = (invalue != NULL) ? invalue : cmd->invalue_buf;
+       cmd->invalue = (invalue) ? invalue : cmd->invalue_buf;
        cmd->memaccess_tck = memaccess_tck;
 
        return cmd;
@@ -255,7 +255,7 @@ static int adi_jtag_dp_scan_cmd(struct adiv5_dap *dap, struct dap_cmd *cmd, uint
        cmd->fields[0].num_bits = 3;
        buf_set_u32(&cmd->out_addr_buf, 0, 3, ((cmd->reg_addr >> 1) & 0x6) | (cmd->rnw & 0x1));
        cmd->fields[0].out_value = &cmd->out_addr_buf;
-       cmd->fields[0].in_value = (ack != NULL) ? ack : &cmd->ack;
+       cmd->fields[0].in_value = (ack) ? ack : &cmd->ack;
 
        /* NOTE: if we receive JTAG_ACK_WAIT, the previous operation did not
         * complete; data we write is discarded, data we read is unpredictable.
@@ -323,7 +323,7 @@ static int adi_jtag_dp_scan(struct adiv5_dap *dap,
        int retval;
 
        cmd = dap_cmd_new(dap, instr, reg_addr, rnw, outvalue, invalue, memaccess_tck);
-       if (cmd != NULL)
+       if (cmd)
                cmd->dp_select = dap->select;
        else
                return ERROR_JTAG_DEVICE_ERROR;
@@ -367,7 +367,7 @@ static int adi_jtag_finish_read(struct adiv5_dap *dap)
 {
        int retval = ERROR_OK;
 
-       if (dap->last_read != NULL) {
+       if (dap->last_read) {
                retval = adi_jtag_dp_scan_u32(dap, JTAG_DP_DPACC,
                                DP_RDBUFF, DPAP_READ, 0, dap->last_read, 0, NULL);
                dap->last_read = NULL;
@@ -391,7 +391,7 @@ static int adi_jtag_scan_inout_check_u32(struct adiv5_dap *dap,
        /* For reads,  collect posted value; RDBUFF has no other effect.
         * Assumes read gets acked with OK/FAULT, and CTRL_STAT says "OK".
         */
-       if ((rnw == DPAP_READ) && (invalue != NULL)) {
+       if ((rnw == DPAP_READ) && (invalue)) {
                retval = adi_jtag_dp_scan_u32(dap, JTAG_DP_DPACC,
                                DP_RDBUFF, DPAP_READ, 0, invalue, 0, NULL);
                if (retval != ERROR_OK)
@@ -453,7 +453,7 @@ static int jtagdp_overrun_check(struct adiv5_dap *dap)
                                }
                        }
 
-                       if (prev != NULL) {
+                       if (prev) {
                                log_dap_cmd("LST", el);
 
                                /*
@@ -466,7 +466,7 @@ static int jtagdp_overrun_check(struct adiv5_dap *dap)
                                */
                                tmp = dap_cmd_new(dap, JTAG_DP_DPACC,
                                                DP_RDBUFF, DPAP_READ, NULL, NULL, 0);
-                               if (tmp == NULL) {
+                               if (!tmp) {
                                        retval = ERROR_JTAG_DEVICE_ERROR;
                                        goto done;
                                }
@@ -545,7 +545,7 @@ static int jtagdp_overrun_check(struct adiv5_dap *dap)
                        el = list_first_entry(&replay_list, struct dap_cmd, lh);
                        tmp = dap_cmd_new(dap, JTAG_DP_DPACC,
                                          DP_SELECT, DPAP_WRITE, (uint8_t *)&el->dp_select, NULL, 0);
-                       if (tmp == NULL) {
+                       if (!tmp) {
                                retval = ERROR_JTAG_DEVICE_ERROR;
                                goto done;
                        }
index f1fca40aed37832c853d610f8d023d3768226d75..a21bf25b9174c4e87b706470765bdb515068c848 100644 (file)
@@ -58,7 +58,7 @@ static bool do_sync;
 static void swd_finish_read(struct adiv5_dap *dap)
 {
        const struct swd_driver *swd = adiv5_dap_swd_driver(dap);
-       if (dap->last_read != NULL) {
+       if (dap->last_read) {
                swd->read_reg(swd_cmd(true, false, DP_RDBUFF), dap->last_read, 0);
                dap->last_read = NULL;
        }
index 77c9090f09e678b8e6fac67436096ae51cd2c3f1..1e8a515192147737b133b96c27dbacd0b679fac2 100644 (file)
@@ -931,8 +931,8 @@ exit:
 static int get_current_actionpoint(struct target *target,
                struct arc_actionpoint **actionpoint)
 {
-       assert(target != NULL);
-       assert(actionpoint != NULL);
+       assert(target);
+       assert(actionpoint);
 
        uint32_t debug_ah;
        /* Check if actionpoint caused halt */
@@ -981,7 +981,7 @@ static int arc_examine_debug_reason(struct target *target)
                struct arc_actionpoint *actionpoint = NULL;
                CHECK_RETVAL(get_current_actionpoint(target, &actionpoint));
 
-               if (actionpoint != NULL) {
+               if (actionpoint) {
                        if (!actionpoint->used)
                                LOG_WARNING("Target halted by an unused actionpoint.");
 
@@ -1940,7 +1940,7 @@ static int arc_hit_watchpoint(struct target *target, struct watchpoint **hit_wat
        struct arc_actionpoint *actionpoint = NULL;
        CHECK_RETVAL(get_current_actionpoint(target, &actionpoint));
 
-       if (actionpoint != NULL) {
+       if (actionpoint) {
                if (!actionpoint->used)
                        LOG_WARNING("Target halted by unused actionpoint.");
 
index 2f3573415e79356b1824e1548ec1742ddaadd04c..17327899b3003e2dce86edaf23b13db68613a50f 100644 (file)
@@ -252,13 +252,13 @@ struct arm {
 /** Convert target handle to generic ARM target state handle. */
 static inline struct arm *target_to_arm(struct target *target)
 {
-       assert(target != NULL);
+       assert(target);
        return target->arch_info;
 }
 
 static inline bool is_arm(struct arm *arm)
 {
-       assert(arm != NULL);
+       assert(arm);
        return arm->common_magic == ARM_COMMON_MAGIC;
 }
 
index 81409cbe8eb3ffb737743b6ae5c8dd5621266764..e3b0975fb38b228e56fa8d9f687c2d02ec6f1071 100644 (file)
@@ -1096,7 +1096,7 @@ static int arm11_target_create(struct target *target, Jim_Interp *interp)
 {
        struct arm11_common *arm11;
 
-       if (target->tap == NULL)
+       if (!target->tap)
                return ERROR_FAIL;
 
        if (target->tap->ir_length != 5) {
index 0200647c11d35da9e96e129e9f6f7b16975164ad..fc35414df446de0be9b5f62706275cb339b4b323 100644 (file)
@@ -586,7 +586,7 @@ static int arm11_run_instr_data_to_core_noack_inner(struct jtag_tap *tap,
        unsigned bytes = sizeof(*readies)*readies_num;
 
        readies = malloc(bytes);
-       if (readies == NULL) {
+       if (!readies) {
                LOG_ERROR("Out of memory allocating %u bytes", bytes);
                return ERROR_FAIL;
        }
index 36ca5b930143235ead03ed55b0469cc9ecb0bfad..cf77a81a7a50c0405f5ad33c3700afc9011f2466 100644 (file)
@@ -1740,7 +1740,7 @@ int arm7_9_resume(struct target *target,
                struct breakpoint *breakpoint;
                breakpoint = breakpoint_find(target,
                                buf_get_u32(arm->pc->value, 0, 32));
-               if (breakpoint != NULL) {
+               if (breakpoint) {
                        LOG_DEBUG("unset breakpoint at 0x%8.8" TARGET_PRIxADDR " (id: %" PRIu32,
                                breakpoint->address,
                                breakpoint->unique_id);
@@ -1932,7 +1932,7 @@ int arm7_9_step(struct target *target, int current, target_addr_t address, int h
        /* the front-end may request us not to handle breakpoints */
        if (handle_breakpoints)
                breakpoint = breakpoint_find(target, current_pc);
-       if (breakpoint != NULL) {
+       if (breakpoint) {
                retval = arm7_9_unset_breakpoint(target, breakpoint);
                if (retval != ERROR_OK)
                        return retval;
@@ -2675,7 +2675,7 @@ int arm7_9_examine(struct target *target)
                struct reg_cache *t, **cache_p;
 
                t = embeddedice_build_reg_cache(target, arm7_9);
-               if (t == NULL)
+               if (!t)
                        return ERROR_FAIL;
 
                cache_p = register_get_last_cache_p(&target->reg_cache);
index c8842da0391d19ac3f5ff2f2a3556e31193efd26..a6d626eeea58e0dd543a1a62f5a3a8a2292f7d56 100644 (file)
@@ -887,7 +887,7 @@ COMMAND_HANDLER(arm920t_handle_read_cache_command)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        output = fopen(CMD_ARGV[0], "w");
-       if (output == NULL) {
+       if (!output) {
                LOG_DEBUG("error opening cache content file");
                return ERROR_OK;
        }
@@ -1169,7 +1169,7 @@ COMMAND_HANDLER(arm920t_handle_read_mmu_command)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        output = fopen(CMD_ARGV[0], "w");
-       if (output == NULL) {
+       if (!output) {
                LOG_DEBUG("error opening mmu content file");
                return ERROR_OK;
        }
index 65ac053516e8171edb8dba1645bdc8029b0bbba1..c458ffd46c83756c72dfd8105ea2c31ec18c6bad 100644 (file)
@@ -505,7 +505,7 @@ static int mem_ap_read(struct adiv5_ap *ap, uint8_t *buffer, uint32_t size, uint
        uint32_t *read_buf = calloc(count, sizeof(uint32_t));
        /* Multiplication count * sizeof(uint32_t) may overflow, calloc() is safe */
        uint32_t *read_ptr = read_buf;
-       if (read_buf == NULL) {
+       if (!read_buf) {
                LOG_ERROR("Failed to allocate read buffer");
                return ERROR_FAIL;
        }
@@ -1653,7 +1653,7 @@ int adiv5_jim_configure(struct target *target, struct jim_getopt_info *goi)
        int e;
 
        pc = (struct adiv5_private_config *)target->private_config;
-       if (pc == NULL) {
+       if (!pc) {
                pc = calloc(1, sizeof(struct adiv5_private_config));
                pc->ap_num = DP_APSEL_INVALID;
                target->private_config = pc;
@@ -1681,10 +1681,10 @@ int adiv5_jim_configure(struct target *target, struct jim_getopt_info *goi)
 
 int adiv5_verify_config(struct adiv5_private_config *pc)
 {
-       if (pc == NULL)
+       if (!pc)
                return ERROR_FAIL;
 
-       if (pc->dap == NULL)
+       if (!pc->dap)
                return ERROR_FAIL;
 
        return ERROR_OK;
index 7eb44f2ed5ff82ab31f88949c4dd1d0afcba1b64..8ebe96301319917182c7955d3c77060aa16a6bb3 100644 (file)
@@ -392,7 +392,7 @@ static inline bool is_64bit_ap(struct adiv5_ap *ap)
 static inline int dap_send_sequence(struct adiv5_dap *dap,
                enum swd_special_seq seq)
 {
-       assert(dap->ops != NULL);
+       assert(dap->ops);
        return dap->ops->send_sequence(dap, seq);
 }
 
@@ -411,7 +411,7 @@ static inline int dap_send_sequence(struct adiv5_dap *dap,
 static inline int dap_queue_dp_read(struct adiv5_dap *dap,
                unsigned reg, uint32_t *data)
 {
-       assert(dap->ops != NULL);
+       assert(dap->ops);
        return dap->ops->queue_dp_read(dap, reg, data);
 }
 
@@ -429,7 +429,7 @@ static inline int dap_queue_dp_read(struct adiv5_dap *dap,
 static inline int dap_queue_dp_write(struct adiv5_dap *dap,
                unsigned reg, uint32_t data)
 {
-       assert(dap->ops != NULL);
+       assert(dap->ops);
        return dap->ops->queue_dp_write(dap, reg, data);
 }
 
@@ -479,7 +479,7 @@ static inline int dap_queue_ap_write(struct adiv5_ap *ap,
  */
 static inline int dap_queue_ap_abort(struct adiv5_dap *dap, uint8_t *ack)
 {
-       assert(dap->ops != NULL);
+       assert(dap->ops);
        return dap->ops->queue_ap_abort(dap, ack);
 }
 
@@ -495,13 +495,13 @@ static inline int dap_queue_ap_abort(struct adiv5_dap *dap, uint8_t *ack)
  */
 static inline int dap_run(struct adiv5_dap *dap)
 {
-       assert(dap->ops != NULL);
+       assert(dap->ops);
        return dap->ops->run(dap);
 }
 
 static inline int dap_sync(struct adiv5_dap *dap)
 {
-       assert(dap->ops != NULL);
+       assert(dap->ops);
        if (dap->ops->sync)
                return dap->ops->sync(dap);
        return ERROR_OK;
index c168245a24f120a1740a8ef0c90578c94ac6b3f0..7d005e2b127752d4387eba40423333ff06122e23 100644 (file)
@@ -143,7 +143,7 @@ int arm_cti_read_reg(struct arm_cti *self, unsigned int reg, uint32_t *p_value)
 {
        struct adiv5_ap *ap = dap_ap(self->spot.dap, self->spot.ap_num);
 
-       if (p_value == NULL)
+       if (!p_value)
                return ERROR_COMMAND_ARGUMENT_INVALID;
 
        return mem_ap_read_atomic_u32(ap, self->spot.base + reg, p_value);
@@ -456,7 +456,7 @@ static int cti_create(struct jim_getopt_info *goi)
        int e;
 
        cmd_ctx = current_command_context(goi->interp);
-       assert(cmd_ctx != NULL);
+       assert(cmd_ctx);
 
        if (goi->argc < 3) {
                Jim_WrongNumArgs(goi->interp, 1, goi->argv, "?name? ..options...");
@@ -474,7 +474,7 @@ static int cti_create(struct jim_getopt_info *goi)
 
        /* Create it */
        cti = calloc(1, sizeof(*cti));
-       if (cti == NULL)
+       if (!cti)
                return JIM_ERR;
 
        adiv5_mem_ap_spot_init(&cti->spot);
index 68297b956b2d7232dfbac99d44b5be9192292f95..a399c51dec540396b17c6727ea6fc9616c62faa0 100644 (file)
@@ -187,7 +187,7 @@ static int dap_configure(struct jim_getopt_info *goi, struct arm_dap_object *dap
                        if (e != JIM_OK)
                                return e;
                        tap = jtag_tap_by_jim_obj(goi->interp, o_t);
-                       if (tap == NULL) {
+                       if (!tap) {
                                Jim_SetResultString(goi->interp, "-chain-position is invalid", -1);
                                return JIM_ERR;
                        }
@@ -202,7 +202,7 @@ static int dap_configure(struct jim_getopt_info *goi, struct arm_dap_object *dap
                }
        }
 
-       if (tap == NULL) {
+       if (!tap) {
                Jim_SetResultString(goi->interp, "-chain-position required when creating DAP", -1);
                return JIM_ERR;
        }
@@ -223,7 +223,7 @@ static int dap_create(struct jim_getopt_info *goi)
        int e;
 
        cmd_ctx = current_command_context(goi->interp);
-       assert(cmd_ctx != NULL);
+       assert(cmd_ctx);
 
        if (goi->argc < 3) {
                Jim_WrongNumArgs(goi->interp, 1, goi->argv, "?name? ..options...");
@@ -241,7 +241,7 @@ static int dap_create(struct jim_getopt_info *goi)
 
        /* Create it */
        dap = calloc(1, sizeof(struct arm_dap_object));
-       if (dap == NULL)
+       if (!dap)
                return JIM_ERR;
 
        e = dap_configure(goi, dap);
@@ -317,7 +317,7 @@ COMMAND_HANDLER(handle_dap_info_command)
        struct adiv5_dap *dap = arm->dap;
        uint32_t apsel;
 
-       if (dap == NULL) {
+       if (!dap) {
                LOG_ERROR("DAP instance not available. Probably a HLA target...");
                return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
        }
index 276e90d89689b8cfad96e8e9b981fbc68ab0000f..3e55e2e3aa3ad819c565769f07508c6ea81f1ccb 100644 (file)
@@ -1070,7 +1070,7 @@ int arm_dpm_setup(struct arm_dpm *dpm)
        arm->read_core_reg = arm_dpm_read_core_reg;
        arm->write_core_reg = arm_dpm_write_core_reg;
 
-       if (arm->core_cache == NULL) {
+       if (!arm->core_cache) {
                cache = arm_build_reg_cache(target, arm);
                if (!cache)
                        return ERROR_FAIL;
index f9605acb16a562b1013eb514fb0d0228f69d358c..6a27e323f8d08f3538de1371cf7e99eea986b416 100644 (file)
@@ -40,7 +40,7 @@ int arm_jtag_set_instr_inner(struct jtag_tap *tap,
        buf_set_u32(t, 0, field.num_bits, new_instr);
        field.in_value = NULL;
 
-       if (no_verify_capture == NULL)
+       if (!no_verify_capture)
                jtag_add_ir_scan(tap, &field, end_state);
        else {
                /* FIX!!!! this is a kludge!!! arm926ejs.c should reimplement this arm_jtag_set_instr to
index 66fd7483bae98efef7abdeb5cd4fa7bd2788e6f1..746ab393ee0acca0070468da6a1f49cccb5a7791 100644 (file)
@@ -351,7 +351,7 @@ static const struct jim_nvp nvp_arm_tpiu_swo_bool_opts[] = {
 
 static int arm_tpiu_swo_configure(struct jim_getopt_info *goi, struct arm_tpiu_swo_object *obj)
 {
-       assert(obj != NULL);
+       assert(obj);
 
        if (goi->isconfigure && obj->enabled) {
                Jim_SetResultFormatted(goi->interp, "Cannot configure TPIU/SWO; %s is enabled!", obj->name);
@@ -866,7 +866,7 @@ static int arm_tpiu_swo_create(Jim_Interp *interp, struct arm_tpiu_swo_object *o
        int e;
 
        cmd_ctx = current_command_context(interp);
-       assert(cmd_ctx != NULL);
+       assert(cmd_ctx);
 
        /* does this command exist? */
        cmd = Jim_GetCommand(interp, Jim_NewStringObj(interp, obj->name, -1), JIM_ERRMSG);
index 636cb1840505827121215be185cf92149e6b828d..b861cf5dbdb0684e9d07a23bf15f7ab779f882de 100644 (file)
@@ -949,7 +949,7 @@ COMMAND_HANDLER(handle_arm_disassemble_command)
 #if HAVE_CAPSTONE
        struct target *target = get_current_target(CMD_CTX);
 
-       if (target == NULL) {
+       if (!target) {
                LOG_ERROR("No target selected");
                return ERROR_FAIL;
        }
@@ -1007,10 +1007,10 @@ static int jim_mcrmrc(Jim_Interp *interp, int argc, Jim_Obj * const *argv)
        int retval;
 
        context = current_command_context(interp);
-       assert(context != NULL);
+       assert(context);
 
        target = get_current_target(context);
-       if (target == NULL) {
+       if (!target) {
                LOG_ERROR("%s: no current target", __func__);
                return JIM_ERR;
        }
index 98baaf190eaa2518c0f11f8954e6ce101683cdd6..cc8c19a9b837484899c5ab52684a61ec14332fbb 100644 (file)
@@ -282,7 +282,7 @@ int armv7a_handle_cache_info_command(struct command_invocation *cmd,
                }
        }
 
-       if (l2x_cache != NULL)
+       if (l2x_cache)
                command_print(cmd, "Outer unified cache Base Address 0x%" PRIx32 ", %" PRIu32 " ways",
                        l2x_cache->base, l2x_cache->way);
 
index b4234b24e6fdded1644354db4ea4433592bc14bf..98a0065083e7fd93338b5ae933f0acb86ad5ccb4 100644 (file)
@@ -245,7 +245,7 @@ COMMAND_HANDLER(armv7a_mmu_dump_table)
        LOG_USER("Page Directory at (phys): %8.8" TARGET_PRIxADDR, ttb);
 
        first_lvl_ptbl = malloc(sizeof(uint32_t)*(max_pt_idx+1));
-       if (first_lvl_ptbl == NULL)
+       if (!first_lvl_ptbl)
                return ERROR_FAIL;
 
        /*
index a9a5a381d694541120aed3344bab601ad89208ac..ee05e47299a0ba22c3adc7ddbf6b983124c5dadc 100644 (file)
@@ -967,7 +967,7 @@ int armv7m_blank_check_memory(struct target *target,
                blocks_to_check = num_blocks;
 
        struct algo_block *params = malloc((blocks_to_check+1)*sizeof(struct algo_block));
-       if (params == NULL) {
+       if (!params) {
                retval = ERROR_FAIL;
                goto cleanup1;
        }
index 49e8b10b7b9994bc22ef246db0d8ebc70a8a38b5..86c0ebf3c822d10bc2f7ab4d25d1402d065d4fb3 100644 (file)
@@ -1046,11 +1046,11 @@ COMMAND_HANDLER(armv8_handle_exception_catch_command)
                        return retval;
 
                n = jim_nvp_value2name_simple(nvp_ecatch_modes, edeccr & 0x0f);
-               if (n->name != NULL)
+               if (n->name)
                        sec = n->name;
 
                n = jim_nvp_value2name_simple(nvp_ecatch_modes, edeccr & 0xf0);
-               if (n->name != NULL)
+               if (n->name)
                        nsec = n->name;
 
                if (sec == NULL || nsec == NULL) {
@@ -1064,7 +1064,7 @@ COMMAND_HANDLER(armv8_handle_exception_catch_command)
 
        while (CMD_ARGC > argp) {
                n = jim_nvp_name2value_simple(nvp_ecatch_modes, CMD_ARGV[argp]);
-               if (n->name == NULL) {
+               if (!n->name) {
                        LOG_ERROR("Unknown option: %s", CMD_ARGV[argp]);
                        return ERROR_FAIL;
                }
@@ -1730,7 +1730,7 @@ void armv8_free_reg_cache(struct target *target)
        struct reg_cache *cache = NULL, *cache32 = NULL;
 
        cache = arm->core_cache;
-       if (cache != NULL)
+       if (cache)
                cache32 = cache->next;
        armv8_free_cache(cache32, true);
        armv8_free_cache(cache, false);
index c9206acfba049ee8d5d4d6cd0768bc8551594588..188e58822a24afa34fbdd7f0a42d75d4b3f3f467 100644 (file)
@@ -1410,7 +1410,7 @@ int armv8_dpm_setup(struct arm_dpm *dpm)
        arm->read_core_reg = armv8_dpm_read_core_reg;
        arm->write_core_reg = armv8_dpm_write_core_reg;
 
-       if (arm->core_cache == NULL) {
+       if (!arm->core_cache) {
                cache = armv8_build_reg_cache(target);
                if (!cache)
                        return ERROR_FAIL;
index 62c8f98ca4433959a0f3fae47919cceacc62c2a5..a23ddf7b1c70a9f473897958c6e200c083126498 100644 (file)
@@ -29,7 +29,7 @@ static int avr32_jtag_set_instr(struct avr32_jtag *jtag_info, int new_instr)
        int busy = 0;
 
        tap = jtag_info->tap;
-       if (tap == NULL)
+       if (!tap)
                return ERROR_FAIL;
 
        if (buf_get_u32(tap->cur_instr, 0, tap->ir_length) != (uint32_t)new_instr) {
index eb8d000c4299f566ba4b1f172660f3fa7859d4be..feceec636378f8d0c826e2957501dc35c7262c06 100644 (file)
@@ -160,7 +160,7 @@ int avr_jtag_sendinstr(struct jtag_tap *tap, uint8_t *ir_in, uint8_t ir_out)
 static int mcu_write_ir(struct jtag_tap *tap, uint8_t *ir_in, uint8_t *ir_out,
                int ir_len, int rti)
 {
-       if (NULL == tap) {
+       if (!tap) {
                LOG_ERROR("invalid tap");
                return ERROR_FAIL;
        }
@@ -179,7 +179,7 @@ static int mcu_write_ir(struct jtag_tap *tap, uint8_t *ir_in, uint8_t *ir_out,
 static int mcu_write_dr(struct jtag_tap *tap, uint8_t *dr_in, uint8_t *dr_out,
                int dr_len, int rti)
 {
-       if (NULL == tap) {
+       if (!tap) {
                LOG_ERROR("invalid tap");
                return ERROR_FAIL;
        }
index dc8f3c5730a38e37fa255a9ba003ba2100ef299b..4ba9d6b4606c291c7b9040323b4e4de23dc98aca 100644 (file)
@@ -377,7 +377,7 @@ static void breakpoint_clear_target_internal(struct target *target)
 {
        LOG_DEBUG("Delete all breakpoints for target: %s",
                target_name(target));
-       while (target->breakpoints != NULL)
+       while (target->breakpoints)
                breakpoint_free(target, target->breakpoints);
 }
 
@@ -517,7 +517,7 @@ void watchpoint_clear_target(struct target *target)
 {
        LOG_DEBUG("Delete all watchpoints for target: %s",
                target_name(target));
-       while (target->watchpoints != NULL)
+       while (target->watchpoints)
                watchpoint_free(target, target->watchpoints);
 }
 
index faed2d531360c341296b37b97c4d5472b7f4848c..f41f39d0e2732ad5663309fc98fa3af3d7683ad2 100644 (file)
@@ -3126,13 +3126,13 @@ static int cortex_a_target_create(struct target *target, Jim_Interp *interp)
        struct cortex_a_common *cortex_a;
        struct adiv5_private_config *pc;
 
-       if (target->private_config == NULL)
+       if (!target->private_config)
                return ERROR_FAIL;
 
        pc = (struct adiv5_private_config *)target->private_config;
 
        cortex_a = calloc(1, sizeof(struct cortex_a_common));
-       if (cortex_a == NULL) {
+       if (!cortex_a) {
                LOG_ERROR("Out of memory");
                return ERROR_FAIL;
        }
@@ -3153,7 +3153,7 @@ static int cortex_r4_target_create(struct target *target, Jim_Interp *interp)
                return ERROR_FAIL;
 
        cortex_a = calloc(1, sizeof(struct cortex_a_common));
-       if (cortex_a == NULL) {
+       if (!cortex_a) {
                LOG_ERROR("Out of memory");
                return ERROR_FAIL;
        }
@@ -3268,7 +3268,7 @@ COMMAND_HANDLER(handle_cortex_a_mask_interrupts_command)
 
        if (CMD_ARGC > 0) {
                n = jim_nvp_name2value_simple(nvp_maskisr_modes, CMD_ARGV[0]);
-               if (n->name == NULL) {
+               if (!n->name) {
                        LOG_ERROR("Unknown parameter: %s - should be off or on", CMD_ARGV[0]);
                        return ERROR_COMMAND_SYNTAX_ERROR;
                }
@@ -3296,7 +3296,7 @@ COMMAND_HANDLER(handle_cortex_a_dacrfixup_command)
 
        if (CMD_ARGC > 0) {
                n = jim_nvp_name2value_simple(nvp_dacrfixup_modes, CMD_ARGV[0]);
-               if (n->name == NULL)
+               if (!n->name)
                        return ERROR_COMMAND_SYNTAX_ERROR;
                cortex_a->dacrfixup_mode = n->value;
 
index bd68fe868c48c548facc4c7002deecb8c580dfbc..9f035a0930232416031810ab33cb40b4b86363fb 100644 (file)
@@ -2318,7 +2318,7 @@ static int cortex_m_target_create(struct target *target, Jim_Interp *interp)
                return ERROR_FAIL;
 
        struct cortex_m_common *cortex_m = calloc(1, sizeof(struct cortex_m_common));
-       if (cortex_m == NULL) {
+       if (!cortex_m) {
                LOG_ERROR("No memory creating target");
                return ERROR_FAIL;
        }
@@ -2465,7 +2465,7 @@ COMMAND_HANDLER(handle_cortex_m_mask_interrupts_command)
 
        if (CMD_ARGC > 0) {
                n = jim_nvp_name2value_simple(nvp_maskisr_modes, CMD_ARGV[0]);
-               if (n->name == NULL)
+               if (!n->name)
                        return ERROR_COMMAND_SYNTAX_ERROR;
                cortex_m->isrmasking_mode = n->value;
                cortex_m_set_maskints_for_halt(target);
index 71bf6f184bba23cc51a046669d618a4d7a4938b5..939b09d36af839bd5cffe9e5d9f94baa463ea1b3 100644 (file)
@@ -85,7 +85,7 @@ static int dsp5680xx_drscan(struct target *target, uint8_t *d_in,
         */
        int retval = ERROR_OK;
 
-       if (NULL == target->tap) {
+       if (!target->tap) {
                retval = ERROR_FAIL;
                err_check(retval, DSP5680XX_ERROR_JTAG_INVALID_TAP,
                          "Invalid tap");
@@ -104,7 +104,7 @@ static int dsp5680xx_drscan(struct target *target, uint8_t *d_in,
                err_check(retval, DSP5680XX_ERROR_JTAG_DRSCAN,
                          "drscan failed!");
        }
-       if (d_out != NULL)
+       if (d_out)
                LOG_DEBUG("Data read (%d bits): 0x%04X", len, *d_out);
        else
                LOG_DEBUG("Data read was discarded.");
@@ -127,7 +127,7 @@ static int dsp5680xx_irscan(struct target *target, uint32_t *d_in,
 
        uint16_t tap_ir_len = DSP5680XX_JTAG_MASTER_TAP_IRLEN;
 
-       if (NULL == target->tap) {
+       if (!target->tap) {
                retval = ERROR_FAIL;
                err_check(retval, DSP5680XX_ERROR_JTAG_INVALID_TAP,
                          "Invalid tap");
@@ -140,7 +140,7 @@ static int dsp5680xx_irscan(struct target *target, uint32_t *d_in,
                } else {
                        struct jtag_tap *t =
                                jtag_tap_by_string("dsp568013.chp");
-                       if ((t == NULL)
+                       if ((!t)
                            || ((t->enabled) && (ir_len != tap_ir_len))) {
                                retval = ERROR_FAIL;
                                err_check(retval,
@@ -172,7 +172,7 @@ static int dsp5680xx_jtag_status(struct target *target, uint8_t *status)
                dsp5680xx_irscan(target, &instr, &read_from_ir,
                                 DSP5680XX_JTAG_CORE_TAP_IRLEN);
        err_check_propagate(retval);
-       if (status != NULL)
+       if (status)
                *status = (uint8_t) read_from_ir;
        return ERROR_OK;
 }
@@ -205,7 +205,7 @@ static int jtag_data_write(struct target *target, uint32_t instr, int num_bits,
                dsp5680xx_drscan(target, (uint8_t *) &instr,
                                 (uint8_t *) &data_read_dummy, num_bits);
        err_check_propagate(retval);
-       if (data_read != NULL)
+       if (data_read)
                *data_read = data_read_dummy;
        return retval;
 }
@@ -239,7 +239,7 @@ static int eonce_instruction_exec_single(struct target *target, uint8_t instr,
 
        retval = jtag_data_write(target, instr_with_flags, 8, &dr_out_tmp);
        err_check_propagate(retval);
-       if (eonce_status != NULL)
+       if (eonce_status)
                *eonce_status = (uint8_t) dr_out_tmp;
        return retval;
 }
@@ -577,9 +577,9 @@ static int switch_tap(struct target *target, struct jtag_tap *master_tap,
 
        uint32_t ir_out;        /* not used, just to make jtag happy. */
 
-       if (master_tap == NULL) {
+       if (!master_tap) {
                master_tap = jtag_tap_by_string("dsp568013.chp");
-               if (master_tap == NULL) {
+               if (!master_tap) {
                        retval = ERROR_FAIL;
                        const char *msg = "Failed to get master tap.";
 
@@ -587,9 +587,9 @@ static int switch_tap(struct target *target, struct jtag_tap *master_tap,
                                  msg);
                }
        }
-       if (core_tap == NULL) {
+       if (!core_tap) {
                core_tap = jtag_tap_by_string("dsp568013.cpu");
-               if (core_tap == NULL) {
+               if (!core_tap) {
                        retval = ERROR_FAIL;
                        err_check(retval, DSP5680XX_ERROR_JTAG_TAP_FIND_CORE,
                                  "Failed to get core tap.");
@@ -695,7 +695,7 @@ static int eonce_enter_debug_mode_without_reset(struct target *target,
                 */
                err_check_propagate(retval);
        }
-       if (eonce_status != NULL)
+       if (eonce_status)
                *eonce_status = data_read_from_dr;
        return retval;
 }
@@ -731,13 +731,13 @@ static int eonce_enter_debug_mode(struct target *target,
        struct jtag_tap *tap_cpu;
 
        tap_chp = jtag_tap_by_string("dsp568013.chp");
-       if (tap_chp == NULL) {
+       if (!tap_chp) {
                retval = ERROR_FAIL;
                err_check(retval, DSP5680XX_ERROR_JTAG_TAP_FIND_MASTER,
                          "Failed to get master tap.");
        }
        tap_cpu = jtag_tap_by_string("dsp568013.cpu");
-       if (tap_cpu == NULL) {
+       if (!tap_cpu) {
                retval = ERROR_FAIL;
                err_check(retval, DSP5680XX_ERROR_JTAG_TAP_FIND_CORE,
                          "Failed to get master tap.");
@@ -833,7 +833,7 @@ static int eonce_enter_debug_mode(struct target *target,
                retval = ERROR_TARGET_FAILURE;
                err_check(retval, DSP5680XX_ERROR_ENTER_DEBUG_MODE, msg);
        }
-       if (eonce_status != NULL)
+       if (eonce_status)
                *eonce_status = data_read_from_dr;
        return retval;
 }
@@ -1585,7 +1585,7 @@ int dsp5680xx_f_protect_check(struct target *target, uint16_t *protected)
        int retval;
 
        check_halt_and_debug(target);
-       if (protected == NULL) {
+       if (!protected) {
                const char *msg = "NULL pointer not valid.";
 
                err_check(ERROR_FAIL,
@@ -1829,7 +1829,7 @@ int dsp5680xx_f_erase_check(struct target *target, uint8_t *erased,
        retval =
                dsp5680xx_f_ex(target, HFM_ERASE_VERIFY, tmp, 0, &hfm_ustat, 1);
        err_check_propagate(retval);
-       if (erased != NULL)
+       if (erased)
                *erased = (uint8_t) (hfm_ustat & HFM_USTAT_MASK_BLANK);
        return retval;
 }
@@ -2118,13 +2118,13 @@ int dsp5680xx_f_unlock(struct target *target)
        struct jtag_tap *tap_cpu;
 
        tap_chp = jtag_tap_by_string("dsp568013.chp");
-       if (tap_chp == NULL) {
+       if (!tap_chp) {
                retval = ERROR_FAIL;
                err_check(retval, DSP5680XX_ERROR_JTAG_TAP_ENABLE_MASTER,
                          "Failed to get master tap.");
        }
        tap_cpu = jtag_tap_by_string("dsp568013.cpu");
-       if (tap_cpu == NULL) {
+       if (!tap_cpu) {
                retval = ERROR_FAIL;
                err_check(retval, DSP5680XX_ERROR_JTAG_TAP_ENABLE_CORE,
                          "Failed to get master tap.");
@@ -2226,13 +2226,13 @@ int dsp5680xx_f_lock(struct target *target)
        jtag_add_sleep(TIME_DIV_FREESCALE * 300 * 1000);
 
        tap_chp = jtag_tap_by_string("dsp568013.chp");
-       if (tap_chp == NULL) {
+       if (!tap_chp) {
                retval = ERROR_FAIL;
                err_check(retval, DSP5680XX_ERROR_JTAG_TAP_ENABLE_MASTER,
                          "Failed to get master tap.");
        }
        tap_cpu = jtag_tap_by_string("dsp568013.cpu");
-       if (tap_cpu == NULL) {
+       if (!tap_cpu) {
                retval = ERROR_FAIL;
                err_check(retval, DSP5680XX_ERROR_JTAG_TAP_ENABLE_CORE,
                          "Failed to get master tap.");
index 9476b0fb485f08c8e8cb59c878f71d3b9fbb4107..d17e1ddff66a0649a475261810a439961a586911 100644 (file)
@@ -539,7 +539,7 @@ static int esirisc_add_breakpoints(struct target *target)
 
        LOG_DEBUG("-");
 
-       while (breakpoint != NULL) {
+       while (breakpoint) {
                if (breakpoint->set == 0)
                        esirisc_add_breakpoint(target, breakpoint);
 
@@ -723,7 +723,7 @@ static int esirisc_add_watchpoints(struct target *target)
 
        LOG_DEBUG("-");
 
-       while (watchpoint != NULL) {
+       while (watchpoint) {
                if (watchpoint->set == 0)
                        esirisc_add_watchpoint(target, watchpoint);
 
@@ -890,7 +890,7 @@ static int esirisc_resume_or_step(struct target *target, int current, target_add
 
        if (handle_breakpoints) {
                breakpoint = breakpoint_find(target, address);
-               if (breakpoint != NULL)
+               if (breakpoint)
                        esirisc_remove_breakpoint(target, breakpoint);
        }
 
@@ -1061,7 +1061,7 @@ static int esirisc_debug_entry(struct target *target)
                        case EID_INST_BREAKPOINT:
                                breakpoint = breakpoint_find(target,
                                                buf_get_u32(esirisc->epc->value, 0, esirisc->epc->size));
-                               target->debug_reason = (breakpoint != NULL) ?
+                               target->debug_reason = (breakpoint) ?
                                                DBG_REASON_BREAKPOINT : DBG_REASON_DBGRQ;
                                break;
 
@@ -1561,7 +1561,7 @@ static int esirisc_target_create(struct target *target, Jim_Interp *interp)
        struct jtag_tap *tap = target->tap;
        struct esirisc_common *esirisc;
 
-       if (tap == NULL)
+       if (!tap)
                return ERROR_FAIL;
 
        if (tap->ir_length != INSTR_LENGTH) {
@@ -1571,7 +1571,7 @@ static int esirisc_target_create(struct target *target, Jim_Interp *interp)
        }
 
        esirisc = calloc(1, sizeof(struct esirisc_common));
-       if (esirisc == NULL)
+       if (!esirisc)
                return ERROR_FAIL;
 
        esirisc->target = target;
index 28d7536af7fdb8ba598e46fe2d1874ea2979a57e..d17a65d63a2776366539173103de2738c723f8d7 100644 (file)
@@ -551,7 +551,7 @@ static int esirisc_trace_analyze_buffer(struct command_invocation *cmd)
 
        size = esirisc_trace_buffer_size(trace_info);
        buffer = calloc(1, size);
-       if (buffer == NULL) {
+       if (!buffer) {
                command_print(cmd, "out of memory");
                return ERROR_FAIL;
        }
@@ -576,7 +576,7 @@ static int esirisc_trace_analyze_memory(struct command_invocation *cmd,
        int retval;
 
        buffer = calloc(1, size);
-       if (buffer == NULL) {
+       if (!buffer) {
                command_print(cmd, "out of memory");
                return ERROR_FAIL;
        }
@@ -628,7 +628,7 @@ static int esirisc_trace_dump_buffer(struct command_invocation *cmd, const char
 
        size = esirisc_trace_buffer_size(trace_info);
        buffer = calloc(1, size);
-       if (buffer == NULL) {
+       if (!buffer) {
                command_print(cmd, "out of memory");
                return ERROR_FAIL;
        }
@@ -653,7 +653,7 @@ static int esirisc_trace_dump_memory(struct command_invocation *cmd, const char
        int retval;
 
        buffer = calloc(1, size);
-       if (buffer == NULL) {
+       if (!buffer) {
                command_print(cmd, "out of memory");
                return ERROR_FAIL;
        }
index 0c03c4dbec8a9b4bfdfe5307bb4048987d594500..ce1bef968e89fb255529e152aafc14d7fb83cf1b 100644 (file)
@@ -44,7 +44,7 @@ static int etb_set_instr(struct etb *etb, uint32_t new_instr)
        struct jtag_tap *tap;
 
        tap = etb->tap;
-       if (tap == NULL)
+       if (!tap)
                return ERROR_FAIL;
 
        if (buf_get_u32(tap->cur_instr, 0, tap->ir_length) != new_instr) {
@@ -349,7 +349,7 @@ COMMAND_HANDLER(handle_etb_config_command)
        }
 
        tap = jtag_tap_by_string(CMD_ARGV[1]);
-       if (tap == NULL) {
+       if (!tap) {
                command_print(CMD, "ETB: TAP %s does not exist", CMD_ARGV[1]);
                return ERROR_FAIL;
        }
index 8555872ffd05086f502c6cfa36f7267faf5d6aaf..05577ead102e6a27ee667c9cb5558b7e97984dfe 100644 (file)
@@ -1808,7 +1808,7 @@ COMMAND_HANDLER(handle_etm_load_command)
                fileio_read_u32(file, &etm_ctx->trace_depth);
        }
        etm_ctx->trace_data = malloc(sizeof(struct etmv1_trace_data) * etm_ctx->trace_depth);
-       if (etm_ctx->trace_data == NULL) {
+       if (!etm_ctx->trace_data) {
                command_print(CMD, "not enough memory to perform operation");
                fileio_close(file);
                return ERROR_FAIL;
index d9de2d3a2aa2bf807960c072c9b055e6fe3d309f..78ec7e885943ee55ccc35393c31837172cbf90b3 100644 (file)
@@ -208,7 +208,7 @@ static int adapter_target_create(struct target *target,
        }
 
        struct cortex_m_common *cortex_m = calloc(1, sizeof(struct cortex_m_common));
-       if (cortex_m == NULL) {
+       if (!cortex_m) {
                LOG_ERROR("No memory creating target");
                return ERROR_FAIL;
        }
index df07ea3ef81edd1ada4a71852495e0185e9eac57..eafa73eaae648e4c347e128091702d5ed35d29de 100644 (file)
@@ -337,12 +337,12 @@ static int image_ihex_buffer_complete_inner(struct image *image,
 static int image_ihex_buffer_complete(struct image *image)
 {
        char *lpsz_line = malloc(1023);
-       if (lpsz_line == NULL) {
+       if (!lpsz_line) {
                LOG_ERROR("Out of memory");
                return ERROR_FAIL;
        }
        struct imagesection *section = malloc(sizeof(struct imagesection) * IMAGE_MAX_SECTIONS);
-       if (section == NULL) {
+       if (!section) {
                free(lpsz_line);
                LOG_ERROR("Out of memory");
                return ERROR_FAIL;
@@ -374,7 +374,7 @@ static int image_elf32_read_headers(struct image *image)
 
        elf->header32 = malloc(sizeof(Elf32_Ehdr));
 
-       if (elf->header32 == NULL) {
+       if (!elf->header32) {
                LOG_ERROR("insufficient memory to perform operation");
                return ERROR_FILEIO_OPERATION_FAILED;
        }
@@ -402,7 +402,7 @@ static int image_elf32_read_headers(struct image *image)
        }
 
        elf->segments32 = malloc(elf->segment_count*sizeof(Elf32_Phdr));
-       if (elf->segments32 == NULL) {
+       if (!elf->segments32) {
                LOG_ERROR("insufficient memory to perform operation");
                return ERROR_FILEIO_OPERATION_FAILED;
        }
@@ -454,7 +454,7 @@ static int image_elf32_read_headers(struct image *image)
 
        /* alloc and fill sections array with loadable segments */
        image->sections = malloc(image->num_sections * sizeof(struct imagesection));
-       if (image->sections == NULL) {
+       if (!image->sections) {
                LOG_ERROR("insufficient memory to perform operation");
                return ERROR_FILEIO_OPERATION_FAILED;
        }
@@ -499,7 +499,7 @@ static int image_elf64_read_headers(struct image *image)
 
        elf->header64 = malloc(sizeof(Elf64_Ehdr));
 
-       if (elf->header64 == NULL) {
+       if (!elf->header64) {
                LOG_ERROR("insufficient memory to perform operation");
                return ERROR_FILEIO_OPERATION_FAILED;
        }
@@ -527,7 +527,7 @@ static int image_elf64_read_headers(struct image *image)
        }
 
        elf->segments64 = malloc(elf->segment_count*sizeof(Elf64_Phdr));
-       if (elf->segments64 == NULL) {
+       if (!elf->segments64) {
                LOG_ERROR("insufficient memory to perform operation");
                return ERROR_FILEIO_OPERATION_FAILED;
        }
@@ -579,7 +579,7 @@ static int image_elf64_read_headers(struct image *image)
 
        /* alloc and fill sections array with loadable segments */
        image->sections = malloc(image->num_sections * sizeof(struct imagesection));
-       if (image->sections == NULL) {
+       if (!image->sections) {
                LOG_ERROR("insufficient memory to perform operation");
                return ERROR_FILEIO_OPERATION_FAILED;
        }
@@ -937,12 +937,12 @@ static int image_mot_buffer_complete_inner(struct image *image,
 static int image_mot_buffer_complete(struct image *image)
 {
        char *lpsz_line = malloc(1023);
-       if (lpsz_line == NULL) {
+       if (!lpsz_line) {
                LOG_ERROR("Out of memory");
                return ERROR_FAIL;
        }
        struct imagesection *section = malloc(sizeof(struct imagesection) * IMAGE_MAX_SECTIONS);
-       if (section == NULL) {
+       if (!section) {
                free(lpsz_line);
                LOG_ERROR("Out of memory");
                return ERROR_FAIL;
@@ -1018,7 +1018,7 @@ int image_open(struct image *image, const char *url, const char *type_string)
        } else if (image->type == IMAGE_MEMORY) {
                struct target *target = get_target(url);
 
-               if (target == NULL) {
+               if (!target) {
                        LOG_ERROR("target '%s' not defined", url);
                        return ERROR_FAIL;
                }
index 31b521b3a8418f97c5442ce2a03031d24f1e64fd..e3f331d13ad950ee03c46214312ff4a4e3e5a914 100644 (file)
@@ -227,7 +227,7 @@ static int irscan(struct target *t, uint8_t *out,
 {
        int retval = ERROR_OK;
        struct x86_32_common *x86_32 = target_to_x86_32(t);
-       if (NULL == t->tap) {
+       if (!t->tap) {
                retval = ERROR_FAIL;
                LOG_ERROR("%s invalid target tap", __func__);
                return retval;
@@ -260,7 +260,7 @@ static int drscan(struct target *t, uint8_t *out, uint8_t *in, uint8_t len)
        int retval = ERROR_OK;
        uint64_t data = 0;
        struct x86_32_common *x86_32 = target_to_x86_32(t);
-       if (NULL == t->tap) {
+       if (!t->tap) {
                retval = ERROR_FAIL;
                LOG_ERROR("%s invalid target tap", __func__);
                return retval;
@@ -283,7 +283,7 @@ static int drscan(struct target *t, uint8_t *out, uint8_t *in, uint8_t len)
                        return retval;
                }
        }
-       if (in != NULL) {
+       if (in) {
                if (len >= 8) {
                        for (int n = (len / 8) - 1 ; n >= 0; n--)
                                data = (data << 8) + *(in+n);
@@ -940,7 +940,7 @@ int lakemont_poll(struct target *t)
                                 */
                                struct breakpoint *bp = NULL;
                                bp = breakpoint_find(t, eip-1);
-                               if (bp != NULL) {
+                               if (bp) {
                                        t->debug_reason = DBG_REASON_BREAKPOINT;
                                        if (bp->type == BKPT_SOFT) {
                                                /* The EIP is now pointing the next byte after the
@@ -1128,7 +1128,7 @@ static int lakemont_reset_break(struct target *t)
 
        /* prepare resetbreak setting the proper bits in CLTAPC_CPU_VPREQ */
        x86_32->curr_tap = jtag_tap_by_position(1);
-       if (x86_32->curr_tap == NULL) {
+       if (!x86_32->curr_tap) {
                x86_32->curr_tap = saved_tap;
                LOG_ERROR("%s could not select quark_x10xx.cltap", __func__);
                return ERROR_FAIL;
index 0c3d7f78a016da0655afaf573b979305f5003e0f..424d6e71674a81420ea61c20d8e19a2d01d4c485 100644 (file)
@@ -38,7 +38,7 @@ static int mem_ap_target_create(struct target *target, Jim_Interp *interp)
        struct adiv5_private_config *pc;
 
        pc = (struct adiv5_private_config *)target->private_config;
-       if (pc == NULL)
+       if (!pc)
                return ERROR_FAIL;
 
        if (pc->ap_num == DP_APSEL_INVALID) {
@@ -47,7 +47,7 @@ static int mem_ap_target_create(struct target *target, Jim_Interp *interp)
        }
 
        mem_ap = calloc(1, sizeof(struct mem_ap));
-       if (mem_ap == NULL) {
+       if (!mem_ap) {
                LOG_ERROR("Out of memory");
                return ERROR_FAIL;
        }
index f8643fa2d78304b5f75df6d272d79819b4bbd028..4a8cfcd4bf6f917b717128adeceb0ce57264d89e 100644 (file)
@@ -373,7 +373,7 @@ int mips32_pracc_queue_exec(struct mips_ejtag *ejtag_info, struct pracc_queue_in
                } scan_32;
 
        } *scan_in = malloc(sizeof(union scan_in) * (ctx->code_count + ctx->store_count));
-       if (scan_in == NULL) {
+       if (!scan_in) {
                LOG_ERROR("Out of memory");
                return ERROR_FAIL;
        }
@@ -483,7 +483,7 @@ int mips32_pracc_read_mem(struct mips_ejtag *ejtag_info, uint32_t addr, int size
        uint32_t *data = NULL;
        if (size != 4) {
                data = malloc(256 * sizeof(uint32_t));
-               if (data == NULL) {
+               if (!data) {
                        LOG_ERROR("Out of memory");
                        goto exit;
                }
index 64abf5727cc3e9577eb044d1101809744873a26b..b2af39cede7032b89b937eb9ed9f53e819c941c6 100644 (file)
@@ -79,7 +79,7 @@ static int mips64_pracc_exec_read(struct mips64_pracc_context *ctx, uint64_t add
                        return ERROR_JTAG_DEVICE_ERROR;
                }
 
-               if (ctx->local_iparam == NULL) {
+               if (!ctx->local_iparam) {
                        LOG_ERROR("Error: unexpected reading of input parameter");
                        return ERROR_JTAG_DEVICE_ERROR;
                }
@@ -91,7 +91,7 @@ static int mips64_pracc_exec_read(struct mips64_pracc_context *ctx, uint64_t add
                   && (address < MIPS64_PRACC_PARAM_OUT + ctx->num_oparam * MIPS64_PRACC_DATA_STEP)) {
 
                offset = (address - MIPS64_PRACC_PARAM_OUT) / MIPS64_PRACC_DATA_STEP;
-               if (ctx->local_oparam == NULL) {
+               if (!ctx->local_oparam) {
                        LOG_ERROR("Error: unexpected reading of output parameter");
                        return ERROR_JTAG_DEVICE_ERROR;
                }
@@ -179,7 +179,7 @@ static int mips64_pracc_exec_write(struct mips64_pracc_context *ctx, uint64_t ad
        if ((address >= MIPS64_PRACC_PARAM_IN)
                && (address < MIPS64_PRACC_PARAM_IN + ctx->num_iparam * MIPS64_PRACC_DATA_STEP)) {
                offset = (address - MIPS64_PRACC_PARAM_IN) / MIPS64_PRACC_DATA_STEP;
-               if (ctx->local_iparam == NULL) {
+               if (!ctx->local_iparam) {
                        LOG_ERROR("Error: unexpected writing of input parameter");
                        return ERROR_JTAG_DEVICE_ERROR;
                }
@@ -187,7 +187,7 @@ static int mips64_pracc_exec_write(struct mips64_pracc_context *ctx, uint64_t ad
        } else if ((address >= MIPS64_PRACC_PARAM_OUT)
                && (address < MIPS64_PRACC_PARAM_OUT + ctx->num_oparam * MIPS64_PRACC_DATA_STEP)) {
                offset = (address - MIPS64_PRACC_PARAM_OUT) / MIPS64_PRACC_DATA_STEP;
-               if (ctx->local_oparam == NULL) {
+               if (!ctx->local_oparam) {
                        LOG_ERROR("Error: unexpected writing of output parameter");
                        return ERROR_JTAG_DEVICE_ERROR;
                }
index 09af855e5b92e4dc3996d0235b006b849c085bb4..b21a1bdc4cf6ffb4aab0c3a4b0c02ae9a1b665a4 100644 (file)
@@ -32,7 +32,7 @@
 
 void mips_ejtag_set_instr(struct mips_ejtag *ejtag_info, uint32_t new_instr)
 {
-       assert(ejtag_info->tap != NULL);
+       assert(ejtag_info->tap);
        struct jtag_tap *tap = ejtag_info->tap;
 
        if (buf_get_u32(tap->cur_instr, 0, tap->ir_length) != new_instr) {
@@ -68,7 +68,7 @@ static int mips_ejtag_get_impcode(struct mips_ejtag *ejtag_info)
 
 void mips_ejtag_add_scan_96(struct mips_ejtag *ejtag_info, uint32_t ctrl, uint32_t data, uint8_t *in_scan_buf)
 {
-       assert(ejtag_info->tap != NULL);
+       assert(ejtag_info->tap);
        struct jtag_tap *tap = ejtag_info->tap;
 
        struct scan_field field;
@@ -94,7 +94,7 @@ int mips_ejtag_drscan_64(struct mips_ejtag *ejtag_info, uint64_t *data)
        struct jtag_tap *tap;
        tap  = ejtag_info->tap;
 
-       if (tap == NULL)
+       if (!tap)
                return ERROR_FAIL;
        struct scan_field field;
        uint8_t t[8] = { 0 }, r[8];
@@ -122,7 +122,7 @@ int mips_ejtag_drscan_64(struct mips_ejtag *ejtag_info, uint64_t *data)
 static void mips_ejtag_drscan_32_queued(struct mips_ejtag *ejtag_info,
                uint32_t data_out, uint8_t *data_in)
 {
-       assert(ejtag_info->tap != NULL);
+       assert(ejtag_info->tap);
        struct jtag_tap *tap = ejtag_info->tap;
 
        struct scan_field field;
@@ -160,7 +160,7 @@ void mips_ejtag_drscan_32_out(struct mips_ejtag *ejtag_info, uint32_t data)
 
 int mips_ejtag_drscan_8(struct mips_ejtag *ejtag_info, uint8_t *data)
 {
-       assert(ejtag_info->tap != NULL);
+       assert(ejtag_info->tap);
        struct jtag_tap *tap = ejtag_info->tap;
 
        struct scan_field field;
@@ -181,7 +181,7 @@ int mips_ejtag_drscan_8(struct mips_ejtag *ejtag_info, uint8_t *data)
 
 void mips_ejtag_drscan_8_out(struct mips_ejtag *ejtag_info, uint8_t data)
 {
-       assert(ejtag_info->tap != NULL);
+       assert(ejtag_info->tap);
        struct jtag_tap *tap = ejtag_info->tap;
 
        struct scan_field field;
@@ -421,7 +421,7 @@ int mips_ejtag_init(struct mips_ejtag *ejtag_info)
 
 int mips_ejtag_fastdata_scan(struct mips_ejtag *ejtag_info, int write_t, uint32_t *data)
 {
-       assert(ejtag_info->tap != NULL);
+       assert(ejtag_info->tap);
        struct jtag_tap *tap = ejtag_info->tap;
 
        struct scan_field fields[2];
@@ -530,7 +530,7 @@ int mips64_ejtag_fastdata_scan(struct mips_ejtag *ejtag_info, bool write_t, uint
        struct jtag_tap *tap;
 
        tap = ejtag_info->tap;
-       assert(tap != NULL);
+       assert(tap);
 
        struct scan_field fields[2];
        uint8_t spracc = 0;
index 8fa43097caf1773722b97168ed002d8b7eeca6fc..1a402933afbd265f284debee4119b13c4768e538 100644 (file)
@@ -1045,7 +1045,7 @@ static int mips_m4k_read_memory(struct target *target, target_addr_t address,
 
        if (size > 1) {
                t = malloc(count * size * sizeof(uint8_t));
-               if (t == NULL) {
+               if (!t) {
                        LOG_ERROR("Out of memory");
                        return ERROR_FAIL;
                }
@@ -1112,7 +1112,7 @@ static int mips_m4k_write_memory(struct target *target, target_addr_t address,
                /* mips32_..._write_mem with size 4/2 requires uint32_t/uint16_t in host */
                /* endianness, but byte array represents target endianness               */
                t = malloc(count * size * sizeof(uint8_t));
-               if (t == NULL) {
+               if (!t) {
                        LOG_ERROR("Out of memory");
                        return ERROR_FAIL;
                }
@@ -1218,7 +1218,7 @@ static int mips_m4k_bulk_write_memory(struct target *target, target_addr_t addre
        if (address & 0x3u)
                return ERROR_TARGET_UNALIGNED_ACCESS;
 
-       if (mips32->fast_data_area == NULL) {
+       if (!mips32->fast_data_area) {
                /* Get memory for block write handler
                 * we preserve this area between calls and gain a speed increase
                 * of about 3kb/sec when writing flash
@@ -1250,7 +1250,7 @@ static int mips_m4k_bulk_write_memory(struct target *target, target_addr_t addre
        /* but byte array represents target endianness                      */
        uint32_t *t = NULL;
        t = malloc(count * sizeof(uint32_t));
-       if (t == NULL) {
+       if (!t) {
                LOG_ERROR("Out of memory");
                return ERROR_FAIL;
        }
index 4b1d1177c9cb1f99909c793f2d4be505c46ae683..ca665ec41eaf4fe04e5fb0537bf0762c2442ac7d 100644 (file)
@@ -1991,7 +1991,7 @@ int nds32_login(struct nds32 *nds32)
 
        LOG_DEBUG("nds32_login");
 
-       if (nds32->edm_passcode != NULL) {
+       if (nds32->edm_passcode) {
                /* convert EDM passcode to command sequences */
                passcode_length = strlen(nds32->edm_passcode);
                command_sequence[0] = '\0';
@@ -2308,7 +2308,7 @@ int nds32_init(struct nds32 *nds32)
 int nds32_get_gdb_fileio_info(struct target *target, struct gdb_fileio_info *fileio_info)
 {
        /* fill syscall parameters to file-I/O info */
-       if (NULL == fileio_info) {
+       if (!fileio_info) {
                LOG_ERROR("Target has not initial file-I/O data structure");
                return ERROR_FAIL;
        }
index e9b9ee194c23f71dd1661896e3f053acb274a3e2..c447673431ed2b3e8d7e2b9846f8cec671a3b50d 100644 (file)
@@ -431,26 +431,26 @@ extern int nds32_profiling(struct target *target, uint32_t *samples,
 /** Convert target handle to generic Andes target state handle. */
 static inline struct nds32 *target_to_nds32(struct target *target)
 {
-       assert(target != NULL);
+       assert(target);
        return target->arch_info;
 }
 
 /** */
 static inline struct aice_port_s *target_to_aice(struct target *target)
 {
-       assert(target != NULL);
+       assert(target);
        return target->tap->priv;
 }
 
 static inline bool is_nds32(struct nds32 *nds32)
 {
-       assert(nds32 != NULL);
+       assert(nds32);
        return nds32->common_magic == NDS32_COMMON_MAGIC;
 }
 
 static inline bool nds32_reach_max_interrupt_level(struct nds32 *nds32)
 {
-       assert(nds32 != NULL);
+       assert(nds32);
        return nds32->max_interrupt_level == nds32->current_interrupt_level;
 }
 
index af1f8b18a69ff04e203526a548ff7b9598034d2c..9c7d0550dc3cfb5bbf2ea06cf4d8f131918bda89 100644 (file)
@@ -701,7 +701,7 @@ static int jim_nds32_bulk_write(Jim_Interp *interp, int argc, Jim_Obj * const *a
                return e;
 
        uint32_t *data = malloc(count * sizeof(uint32_t));
-       if (data == NULL)
+       if (!data)
                return JIM_ERR;
 
        jim_wide i;
index 5b8d7ded79d44384ed1beca12174b1757835d4f7..8fbcd962091207861cbaeec9f43d2ad5a1db729e 100644 (file)
@@ -1089,12 +1089,12 @@ static int or1k_init_target(struct command_context *cmd_ctx,
        struct or1k_du *du_core = or1k_to_du(or1k);
        struct or1k_jtag *jtag = &or1k->jtag;
 
-       if (du_core == NULL) {
+       if (!du_core) {
                LOG_ERROR("No debug unit selected");
                return ERROR_FAIL;
        }
 
-       if (jtag->tap_ip == NULL) {
+       if (!jtag->tap_ip) {
                LOG_ERROR("No tap selected");
                return ERROR_FAIL;
        }
@@ -1111,7 +1111,7 @@ static int or1k_init_target(struct command_context *cmd_ctx,
 
 static int or1k_target_create(struct target *target, Jim_Interp *interp)
 {
-       if (target->tap == NULL)
+       if (!target->tap)
                return ERROR_FAIL;
 
        struct or1k_common *or1k = calloc(1, sizeof(struct or1k_common));
index 31b248776312f81af5c8511516d87b3b5d8e12bf..885fcb9c107a66890c0f0ab16161b2f1320fbb75 100644 (file)
@@ -946,7 +946,7 @@ static int or1k_adv_jtag_write_memory(struct or1k_jtag *jtag_info,
        struct target *target = jtag_info->target;
        if ((target->endianness == TARGET_BIG_ENDIAN) && (size != 1)) {
                t = malloc(count * size * sizeof(uint8_t));
-               if (t == NULL) {
+               if (!t) {
                        LOG_ERROR("Out of memory");
                        return ERROR_FAIL;
                }
index 9169379bb5da2ff508c43533ebcf860aac33b0fc..211245d7db358ca2598e21b5c1cd478c579cc8ff 100644 (file)
@@ -46,7 +46,7 @@
 static int quark_d20xx_target_create(struct target *t, Jim_Interp *interp)
 {
        struct x86_32_common *x86_32 = calloc(1, sizeof(struct x86_32_common));
-       if (x86_32 == NULL) {
+       if (!x86_32) {
                LOG_ERROR("%s out of memory", __func__);
                return ERROR_FAIL;
        }
index 43f2ffb8c09a3b22d61b3620af02c830c140806f..3c062e15011aefb03af5fecd56dc4314c55af155 100644 (file)
@@ -183,7 +183,7 @@ void dump_field(int idle, const struct scan_field *field)
        if (debug_level < LOG_LVL_DEBUG)
                return;
 
-       assert(field->out_value != NULL);
+       assert(field->out_value);
        uint64_t out = buf_get_u64(field->out_value, 0, field->num_bits);
        unsigned int out_op = get_field(out, DTM_DMI_OP);
        unsigned int out_data = get_field(out, DTM_DMI_DATA);
index 4b0bac500a59ab955dc09361761878ffc48027f0..74d59d2d76d16dbec4cf265c7c6868ff7152dd20 100644 (file)
@@ -951,7 +951,7 @@ static int old_or_new_riscv_step(struct target *target, int current,
 {
        RISCV_INFO(r);
        LOG_DEBUG("handle_breakpoints=%d", handle_breakpoints);
-       if (r->is_halted == NULL)
+       if (!r->is_halted)
                return oldriscv_step(target, current, address, handle_breakpoints);
        else
                return riscv_openocd_step(target, current, address, handle_breakpoints);
@@ -975,7 +975,7 @@ static int riscv_examine(struct target *target)
        LOG_DEBUG("  version=0x%x", info->dtm_version);
 
        struct target_type *tt = get_target_type(target);
-       if (tt == NULL)
+       if (!tt)
                return ERROR_FAIL;
 
        int result = tt->init_target(info->cmd_ctx, target);
@@ -994,7 +994,7 @@ static int oldriscv_poll(struct target *target)
 static int old_or_new_riscv_poll(struct target *target)
 {
        RISCV_INFO(r);
-       if (r->is_halted == NULL)
+       if (!r->is_halted)
                return oldriscv_poll(target);
        else
                return riscv_openocd_poll(target);
@@ -1049,7 +1049,7 @@ int halt_go(struct target *target)
 {
        riscv_info_t *r = riscv_info(target);
        int result;
-       if (r->is_halted == NULL) {
+       if (!r->is_halted) {
                struct target_type *tt = get_target_type(target);
                result = tt->halt(target);
        } else {
@@ -1071,7 +1071,7 @@ int riscv_halt(struct target *target)
 {
        RISCV_INFO(r);
 
-       if (r->is_halted == NULL) {
+       if (!r->is_halted) {
                struct target_type *tt = get_target_type(target);
                return tt->halt(target);
        }
@@ -1297,7 +1297,7 @@ static int resume_go(struct target *target, int current,
 {
        riscv_info_t *r = riscv_info(target);
        int result;
-       if (r->is_halted == NULL) {
+       if (!r->is_halted) {
                struct target_type *tt = get_target_type(target);
                result = tt->resume(target, current, address, handle_breakpoints,
                                debug_execution);
@@ -3056,7 +3056,7 @@ void riscv_set_rtos_hartid(struct target *target, int hartid)
 
 int riscv_count_harts(struct target *target)
 {
-       if (target == NULL)
+       if (!target)
                return 1;
        RISCV_INFO(r);
        if (r == NULL || r->hart_count == NULL)
index ffed7350edd5794612b0b6ed9ec1de4909af57a3..fa639038d1dadab416e2079a3f51afaf9d6cc589 100644 (file)
@@ -99,7 +99,7 @@ int semihosting_common_init(struct target *target, void *setup,
        LOG_DEBUG(" ");
 
        target->fileio_info = malloc(sizeof(*target->fileio_info));
-       if (target->fileio_info == NULL) {
+       if (!target->fileio_info) {
                LOG_ERROR("out of memory");
                return ERROR_FAIL;
        }
@@ -107,7 +107,7 @@ int semihosting_common_init(struct target *target, void *setup,
 
        struct semihosting *semihosting;
        semihosting = malloc(sizeof(*target->semihosting));
-       if (semihosting == NULL) {
+       if (!semihosting) {
                LOG_ERROR("out of memory");
                return ERROR_FAIL;
        }
@@ -1478,7 +1478,7 @@ static __COMMAND_HANDLER(handle_common_semihosting_command)
 {
        struct target *target = get_current_target(CMD_CTX);
 
-       if (target == NULL) {
+       if (!target) {
                LOG_ERROR("No target selected");
                return ERROR_FAIL;
        }
@@ -1519,7 +1519,7 @@ static __COMMAND_HANDLER(handle_common_semihosting_fileio_command)
 {
        struct target *target = get_current_target(CMD_CTX);
 
-       if (target == NULL) {
+       if (!target) {
                LOG_ERROR("No target selected");
                return ERROR_FAIL;
        }
@@ -1550,7 +1550,7 @@ static __COMMAND_HANDLER(handle_common_semihosting_cmdline)
        struct target *target = get_current_target(CMD_CTX);
        unsigned int i;
 
-       if (target == NULL) {
+       if (!target) {
                LOG_ERROR("No target selected");
                return ERROR_FAIL;
        }
@@ -1566,7 +1566,7 @@ static __COMMAND_HANDLER(handle_common_semihosting_cmdline)
 
        for (i = 1; i < CMD_ARGC; i++) {
                char *cmdline = alloc_printf("%s %s", semihosting->cmdline, CMD_ARGV[i]);
-               if (cmdline == NULL)
+               if (!cmdline)
                        break;
                free(semihosting->cmdline);
                semihosting->cmdline = cmdline;
@@ -1582,7 +1582,7 @@ static __COMMAND_HANDLER(handle_common_semihosting_resumable_exit_command)
 {
        struct target *target = get_current_target(CMD_CTX);
 
-       if (target == NULL) {
+       if (!target) {
                LOG_ERROR("No target selected");
                return ERROR_FAIL;
        }
index f024b402352629d06adbda2cda03aa599bfa58ff..3338240adf6d2a3a1e2736c8885ace604b480cc0 100644 (file)
@@ -22,7 +22,7 @@
 #include "server/server.h"
 
 #define foreach_smp_target(pos, head) \
-       for (pos = head; (pos != NULL); pos = pos->next)
+       for (pos = head; (pos); pos = pos->next)
 
 extern const struct command_registration smp_command_handlers[];
 
index 4d2c6465ddc419b3bc224329f43b024b4f06992d..9a476cbf2e968958375fde371234676313874e4a 100644 (file)
@@ -188,7 +188,7 @@ static const char *target_strerror_safe(int err)
        const struct jim_nvp *n;
 
        n = jim_nvp_value2name_simple(nvp_error_target, err);
-       if (n->name == NULL)
+       if (!n->name)
                return "unknown";
        else
                return n->name;
@@ -526,7 +526,7 @@ struct target *get_current_target(struct command_context *cmd_ctx)
 {
        struct target *target = get_current_target_or_null(cmd_ctx);
 
-       if (target == NULL) {
+       if (!target) {
                LOG_ERROR("BUG: current_target out of bounds");
                exit(-1);
        }
@@ -663,7 +663,7 @@ static int target_process_reset(struct command_invocation *cmd, enum target_rese
        int retval;
        struct jim_nvp *n;
        n = jim_nvp_value2name_simple(nvp_reset_modes, reset_mode);
-       if (n->name == NULL) {
+       if (!n->name) {
                LOG_ERROR("invalid reset mode");
                return ERROR_FAIL;
        }
@@ -1537,13 +1537,13 @@ static int target_init_one(struct command_context *cmd_ctx,
        target_reset_examined(target);
 
        struct target_type *type = target->type;
-       if (type->examine == NULL)
+       if (!type->examine)
                type->examine = default_examine;
 
-       if (type->check_reset == NULL)
+       if (!type->check_reset)
                type->check_reset = default_check_reset;
 
-       assert(type->init_target != NULL);
+       assert(type->init_target);
 
        int retval = type->init_target(cmd_ctx, target);
        if (retval != ERROR_OK) {
@@ -1555,7 +1555,7 @@ static int target_init_one(struct command_context *cmd_ctx,
         * implement it in stages, but warn if we need to do so.
         */
        if (type->mmu) {
-               if (type->virt2phys == NULL) {
+               if (!type->virt2phys) {
                        LOG_ERROR("type '%s' is missing virt2phys", type->name);
                        type->virt2phys = identity_virt2phys;
                }
@@ -1652,7 +1652,7 @@ int target_register_event_callback(int (*callback)(struct target *target,
 {
        struct target_event_callback **callbacks_p = &target_event_callbacks;
 
-       if (callback == NULL)
+       if (!callback)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        if (*callbacks_p) {
@@ -1674,11 +1674,11 @@ int target_register_reset_callback(int (*callback)(struct target *target,
 {
        struct target_reset_callback *entry;
 
-       if (callback == NULL)
+       if (!callback)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        entry = malloc(sizeof(struct target_reset_callback));
-       if (entry == NULL) {
+       if (!entry) {
                LOG_ERROR("error allocating buffer for reset callback entry");
                return ERROR_COMMAND_SYNTAX_ERROR;
        }
@@ -1696,11 +1696,11 @@ int target_register_trace_callback(int (*callback)(struct target *target,
 {
        struct target_trace_callback *entry;
 
-       if (callback == NULL)
+       if (!callback)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        entry = malloc(sizeof(struct target_trace_callback));
-       if (entry == NULL) {
+       if (!entry) {
                LOG_ERROR("error allocating buffer for trace callback entry");
                return ERROR_COMMAND_SYNTAX_ERROR;
        }
@@ -1718,7 +1718,7 @@ int target_register_timer_callback(int (*callback)(void *priv),
 {
        struct target_timer_callback **callbacks_p = &target_timer_callbacks;
 
-       if (callback == NULL)
+       if (!callback)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        if (*callbacks_p) {
@@ -1748,7 +1748,7 @@ int target_unregister_event_callback(int (*callback)(struct target *target,
        struct target_event_callback **p = &target_event_callbacks;
        struct target_event_callback *c = target_event_callbacks;
 
-       if (callback == NULL)
+       if (!callback)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        while (c) {
@@ -1770,7 +1770,7 @@ int target_unregister_reset_callback(int (*callback)(struct target *target,
 {
        struct target_reset_callback *entry;
 
-       if (callback == NULL)
+       if (!callback)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        list_for_each_entry(entry, &target_reset_callback_list, list) {
@@ -1789,7 +1789,7 @@ int target_unregister_trace_callback(int (*callback)(struct target *target,
 {
        struct target_trace_callback *entry;
 
-       if (callback == NULL)
+       if (!callback)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        list_for_each_entry(entry, &target_trace_callback_list, list) {
@@ -1805,7 +1805,7 @@ int target_unregister_trace_callback(int (*callback)(struct target *target,
 
 int target_unregister_timer_callback(int (*callback)(void *priv), void *priv)
 {
-       if (callback == NULL)
+       if (!callback)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        for (struct target_timer_callback *c = target_timer_callbacks;
@@ -1961,7 +1961,7 @@ static void target_split_working_area(struct working_area *area, uint32_t size)
        if (size < area->size) {
                struct working_area *new_wa = malloc(sizeof(*new_wa));
 
-               if (new_wa == NULL)
+               if (!new_wa)
                        return;
 
                new_wa->next = area->next;
@@ -2013,7 +2013,7 @@ static void target_merge_working_areas(struct target *target)
 int target_alloc_working_area_try(struct target *target, uint32_t size, struct working_area **area)
 {
        /* Reevaluate working area address based on MMU state*/
-       if (target->working_areas == NULL) {
+       if (!target->working_areas) {
                int retval;
                int enabled;
 
@@ -2072,7 +2072,7 @@ int target_alloc_working_area_try(struct target *target, uint32_t size, struct w
                c = c->next;
        }
 
-       if (c == NULL)
+       if (!c)
                return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
 
        /* Split the working area into the requested size */
@@ -2082,9 +2082,9 @@ int target_alloc_working_area_try(struct target *target, uint32_t size, struct w
                          size, c->address);
 
        if (target->backup_working_area) {
-               if (c->backup == NULL) {
+               if (!c->backup) {
                        c->backup = malloc(c->size);
-                       if (c->backup == NULL)
+                       if (!c->backup)
                                return ERROR_FAIL;
                }
 
@@ -2215,7 +2215,7 @@ uint32_t target_get_working_area_avail(struct target *target)
        struct working_area *c = target->working_areas;
        uint32_t max_size = 0;
 
-       if (c == NULL)
+       if (!c)
                return target->working_area_size;
 
        while (c) {
@@ -2250,7 +2250,7 @@ static void target_destroy(struct target *target)
        /* release the targets SMP list */
        if (target->smp) {
                struct target_list *head = target->head;
-               while (head != NULL) {
+               while (head) {
                        struct target_list *pos = head->next;
                        head->target->smp = 0;
                        free(head);
@@ -2301,7 +2301,7 @@ void target_quit(void)
 int target_arch_state(struct target *target)
 {
        int retval;
-       if (target == NULL) {
+       if (!target) {
                LOG_WARNING("No target has been configured");
                return ERROR_OK;
        }
@@ -2520,7 +2520,7 @@ int target_checksum_memory(struct target *target, target_addr_t address, uint32_
        retval = target->type->checksum_memory(target, address, size, &checksum);
        if (retval != ERROR_OK) {
                buffer = malloc(size);
-               if (buffer == NULL) {
+               if (!buffer) {
                        LOG_ERROR("error allocating buffer for section (%" PRIu32 " bytes)", size);
                        return ERROR_COMMAND_SYNTAX_ERROR;
                }
@@ -2820,7 +2820,7 @@ int target_write_phys_u8(struct target *target, target_addr_t address, uint8_t v
 static int find_target(struct command_invocation *cmd, const char *name)
 {
        struct target *target = get_target(name);
-       if (target == NULL) {
+       if (!target) {
                command_print(cmd, "Target: %s is unknown, try one of:\n", name);
                return ERROR_FAIL;
        }
@@ -3136,7 +3136,7 @@ COMMAND_HANDLER(handle_reg_command)
                        goto not_found;
        }
 
-       assert(reg != NULL); /* give clang a hint that we *know* reg is != NULL here */
+       assert(reg); /* give clang a hint that we *know* reg is != NULL here */
 
        if (!reg->exist)
                goto not_found;
@@ -3163,7 +3163,7 @@ COMMAND_HANDLER(handle_reg_command)
        /* set register value */
        if (CMD_ARGC == 2) {
                uint8_t *buf = malloc(DIV_ROUND_UP(reg->size, 8));
-               if (buf == NULL)
+               if (!buf)
                        return ERROR_FAIL;
                str_to_buf(CMD_ARGV[1], strlen(CMD_ARGV[1]), buf, reg->size, 0);
 
@@ -3316,7 +3316,7 @@ COMMAND_HANDLER(handle_reset_command)
        if (CMD_ARGC == 1) {
                const struct jim_nvp *n;
                n = jim_nvp_name2value_simple(nvp_reset_modes, CMD_ARGV[0]);
-               if ((n->name == NULL) || (n->value == RESET_UNKNOWN))
+               if ((!n->name) || (n->value == RESET_UNKNOWN))
                        return ERROR_COMMAND_SYNTAX_ERROR;
                reset_mode = n->value;
        }
@@ -3475,7 +3475,7 @@ COMMAND_HANDLER(handle_md_command)
                COMMAND_PARSE_NUMBER(uint, CMD_ARGV[1], count);
 
        uint8_t *buffer = calloc(count, size);
-       if (buffer == NULL) {
+       if (!buffer) {
                LOG_ERROR("Failed to allocate md read buffer");
                return ERROR_FAIL;
        }
@@ -3506,7 +3506,7 @@ static int target_fill_mem(struct target *target,
         * to fill large memory areas with any sane speed */
        const unsigned chunk_size = 16384;
        uint8_t *target_buf = malloc(chunk_size * data_size);
-       if (target_buf == NULL) {
+       if (!target_buf) {
                LOG_ERROR("Out of memory");
                return ERROR_FAIL;
        }
@@ -3654,7 +3654,7 @@ COMMAND_HANDLER(handle_load_image_command)
        retval = ERROR_OK;
        for (unsigned int i = 0; i < image.num_sections; i++) {
                buffer = malloc(image.sections[i].size);
-               if (buffer == NULL) {
+               if (!buffer) {
                        command_print(CMD,
                                                  "error allocating buffer for section (%d bytes)",
                                                  (int)(image.sections[i].size));
@@ -3825,7 +3825,7 @@ static COMMAND_HELPER(handle_verify_image_command_internal, enum verify_mode ver
        retval = ERROR_OK;
        for (unsigned int i = 0; i < image.num_sections; i++) {
                buffer = malloc(image.sections[i].size);
-               if (buffer == NULL) {
+               if (!buffer) {
                        command_print(CMD,
                                        "error allocating buffer for section (%" PRIu32 " bytes)",
                                        image.sections[i].size);
@@ -4194,7 +4194,7 @@ static void write_gmon(uint32_t *samples, uint32_t sample_num, const char *filen
 {
        uint32_t i;
        FILE *f = fopen(filename, "w");
-       if (f == NULL)
+       if (!f)
                return;
        write_string(f, "gmon");
        write_long(f, 0x00000001, target); /* Version */
@@ -4236,7 +4236,7 @@ static void write_gmon(uint32_t *samples, uint32_t sample_num, const char *filen
        if (num_buckets > max_buckets)
                num_buckets = max_buckets;
        int *buckets = malloc(sizeof(int) * num_buckets);
-       if (buckets == NULL) {
+       if (!buckets) {
                fclose(f);
                return;
        }
@@ -4268,7 +4268,7 @@ static void write_gmon(uint32_t *samples, uint32_t sample_num, const char *filen
        /*append binary memory gmon.out profile_hist_data (profile_hist_data + profile_hist_hdr.hist_size) */
 
        char *data = malloc(2 * num_buckets);
-       if (data != NULL) {
+       if (data) {
                for (i = 0; i < num_buckets; i++) {
                        int val;
                        val = buckets[i];
@@ -4304,7 +4304,7 @@ COMMAND_HANDLER(handle_profile_command)
        COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], offset);
 
        uint32_t *samples = malloc(sizeof(uint32_t) * MAX_PROFILE_SAMPLE_NUM);
-       if (samples == NULL) {
+       if (!samples) {
                LOG_ERROR("No memory to store samples.");
                return ERROR_FAIL;
        }
@@ -4406,10 +4406,10 @@ static int jim_mem2array(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
        struct target *target;
 
        context = current_command_context(interp);
-       assert(context != NULL);
+       assert(context);
 
        target = get_current_target(context);
-       if (target == NULL) {
+       if (!target) {
                LOG_ERROR("mem2array: no current target");
                return JIM_ERR;
        }
@@ -4517,7 +4517,7 @@ static int target_mem2array(Jim_Interp *interp, struct target *target, int argc,
 
        const size_t buffersize = 4096;
        uint8_t *buffer = malloc(buffersize);
-       if (buffer == NULL)
+       if (!buffer)
                return JIM_ERR;
 
        /* assume ok */
@@ -4589,7 +4589,7 @@ static int get_u64_array_element(Jim_Interp *interp, const char *varname, size_t
        Jim_Obj *obj_val = Jim_GetVariable(interp, obj_name, JIM_ERRMSG);
        Jim_DecrRefCount(interp, obj_name);
        free(namebuf);
-       if (obj_val == NULL)
+       if (!obj_val)
                return JIM_ERR;
 
        jim_wide wide_val;
@@ -4604,10 +4604,10 @@ static int jim_array2mem(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
        struct target *target;
 
        context = current_command_context(interp);
-       assert(context != NULL);
+       assert(context);
 
        target = get_current_target(context);
-       if (target == NULL) {
+       if (!target) {
                LOG_ERROR("array2mem: no current target");
                return JIM_ERR;
        }
@@ -4720,7 +4720,7 @@ static int target_array2mem(Jim_Interp *interp, struct target *target,
 
        const size_t buffersize = 4096;
        uint8_t *buffer = malloc(buffersize);
-       if (buffer == NULL)
+       if (!buffer)
                return JIM_ERR;
 
        /* index counter */
@@ -4974,7 +4974,7 @@ no_params:
                                        /* END_DEPRECATED_TPIU */
 
                                        bool replace = true;
-                                       if (teap == NULL) {
+                                       if (!teap) {
                                                /* create new */
                                                teap = calloc(1, sizeof(*teap));
                                                replace = false;
@@ -5005,7 +5005,7 @@ no_params:
                                        Jim_SetEmptyResult(goi->interp);
                                } else {
                                        /* get */
-                                       if (teap == NULL)
+                                       if (!teap)
                                                Jim_SetEmptyResult(goi->interp);
                                        else
                                                Jim_SetResult(goi->interp, Jim_DuplicateObj(goi->interp, teap->body));
@@ -5091,7 +5091,7 @@ no_params:
                                        goto no_params;
                        }
                        n = jim_nvp_value2name_simple(nvp_target_endian, target->endianness);
-                       if (n->name == NULL) {
+                       if (!n->name) {
                                target->endianness = TARGET_LITTLE_ENDIAN;
                                n = jim_nvp_value2name_simple(nvp_target_endian, target->endianness);
                        }
@@ -5129,7 +5129,7 @@ no_params:
                                if (e != JIM_OK)
                                        return e;
                                tap = jtag_tap_by_jim_obj(goi->interp, o_t);
-                               if (tap == NULL)
+                               if (!tap)
                                        return JIM_ERR;
                                target->tap = tap;
                                target->tap_configured = true;
@@ -5692,7 +5692,7 @@ static int target_create(struct jim_getopt_info *goi)
        struct command_context *cmd_ctx;
 
        cmd_ctx = current_command_context(goi->interp);
-       assert(cmd_ctx != NULL);
+       assert(cmd_ctx);
 
        if (goi->argc < 3) {
                Jim_WrongNumArgs(goi->interp, 1, goi->argv, "?name? ?type? ..options...");
@@ -5824,7 +5824,7 @@ static int target_create(struct jim_getopt_info *goi)
                        }
                }
                /* tap must be set after target was configured */
-               if (target->tap == NULL)
+               if (!target->tap)
                        e = JIM_ERR;
        }
 
@@ -5922,7 +5922,7 @@ static int jim_target_current(Jim_Interp *interp, int argc, Jim_Obj *const *argv
                return JIM_ERR;
        }
        struct command_context *cmd_ctx = current_command_context(interp);
-       assert(cmd_ctx != NULL);
+       assert(cmd_ctx);
 
        struct target *target = get_current_target_or_null(cmd_ctx);
        if (target)
@@ -6081,7 +6081,7 @@ static struct fast_load *fastload;
 
 static void free_fastload(void)
 {
-       if (fastload != NULL) {
+       if (fastload) {
                for (int i = 0; i < fastload_num; i++)
                        free(fastload[i].data);
                free(fastload);
@@ -6115,7 +6115,7 @@ COMMAND_HANDLER(handle_fast_load_image_command)
        retval = ERROR_OK;
        fastload_num = image.num_sections;
        fastload = malloc(sizeof(struct fast_load)*image.num_sections);
-       if (fastload == NULL) {
+       if (!fastload) {
                command_print(CMD, "out of memory");
                image_close(&image);
                return ERROR_FAIL;
@@ -6123,7 +6123,7 @@ COMMAND_HANDLER(handle_fast_load_image_command)
        memset(fastload, 0, sizeof(struct fast_load)*image.num_sections);
        for (unsigned int i = 0; i < image.num_sections; i++) {
                buffer = malloc(image.sections[i].size);
-               if (buffer == NULL) {
+               if (!buffer) {
                        command_print(CMD, "error allocating buffer for section (%d bytes)",
                                                  (int)(image.sections[i].size));
                        retval = ERROR_FAIL;
@@ -6195,7 +6195,7 @@ COMMAND_HANDLER(handle_fast_load_command)
 {
        if (CMD_ARGC > 0)
                return ERROR_COMMAND_SYNTAX_ERROR;
-       if (fastload == NULL) {
+       if (!fastload) {
                LOG_ERROR("No image in memory");
                return ERROR_FAIL;
        }
@@ -6281,7 +6281,7 @@ COMMAND_HANDLER(handle_ps_command)
 
 static void binprint(struct command_invocation *cmd, const char *text, const uint8_t *buf, int size)
 {
-       if (text != NULL)
+       if (text)
                command_print_sameline(cmd, "%s", text);
        for (int i = 0; i < size; i++)
                command_print_sameline(cmd, " %02x", buf[i]);
@@ -6381,7 +6381,7 @@ next:
 out:
        free(test_pattern);
 
-       if (wa != NULL)
+       if (wa)
                target_free_working_area(target, wa);
 
        /* Test writes */
@@ -6466,7 +6466,7 @@ nextw:
 
        free(test_pattern);
 
-       if (wa != NULL)
+       if (wa)
                target_free_working_area(target, wa);
        return retval;
 }
index 32a907233f235fe2e5a5df070dc3c45da47eeb6d..cf588f49fc9f735044a69e752e97a88687148d6b 100644 (file)
@@ -158,7 +158,7 @@ static int add_debug_msg_receiver(struct command_context *cmd_ctx, struct target
 {
        struct debug_msg_receiver **p = &target->dbgmsg;
 
-       if (target == NULL)
+       if (!target)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        /* see if there's already a list */
@@ -186,9 +186,9 @@ static struct debug_msg_receiver *find_debug_msg_receiver(struct command_context
        int do_all_targets = 0;
 
        /* if no target has been specified search all of them */
-       if (target == NULL) {
+       if (!target) {
                /* if no targets haven been specified */
-               if (all_targets == NULL)
+               if (!all_targets)
                        return NULL;
 
                target = all_targets;
@@ -217,9 +217,9 @@ int delete_debug_msg_receiver(struct command_context *cmd_ctx, struct target *ta
        int do_all_targets = 0;
 
        /* if no target has been specified search all of them */
-       if (target == NULL) {
+       if (!target) {
                /* if no targets haven been specified */
-               if (all_targets == NULL)
+               if (!all_targets)
                        return ERROR_OK;
 
                target = all_targets;
index b7dff2361391e51400a6437ed45c731ba01b611e..0d1518ce40a144cd3b82c45ca5438633a563b3a7 100644 (file)
@@ -95,7 +95,7 @@ int x86_32_common_init_arch_info(struct target *t, struct x86_32_common *x86_32)
        x86_32->num_hw_bpoints = MAX_DEBUG_REGS;
        x86_32->hw_break_list = calloc(x86_32->num_hw_bpoints,
                                sizeof(struct x86_32_dbg_reg));
-       if (x86_32->hw_break_list == NULL) {
+       if (!x86_32->hw_break_list) {
                LOG_ERROR("%s out of memory", __func__);
                return ERROR_FAIL;
        }
@@ -157,7 +157,7 @@ int x86_32_common_read_phys_mem(struct target *t, target_addr_t phys_address,
         * with the original instructions again.
         */
        struct swbp_mem_patch *iter = x86_32->swbbp_mem_patch_list;
-       while (iter != NULL) {
+       while (iter) {
                if (iter->physaddr >= phys_address && iter->physaddr < phys_address+(size*count)) {
                        uint32_t offset = iter->physaddr - phys_address;
                        buffer[offset] = iter->orig_byte;
@@ -245,13 +245,13 @@ int x86_32_common_write_phys_mem(struct target *t, target_addr_t phys_address,
         * breakpoint instruction.
         */
        newbuffer = malloc(size*count);
-       if (newbuffer == NULL) {
+       if (!newbuffer) {
                LOG_ERROR("%s out of memory", __func__);
                return ERROR_FAIL;
        }
        memcpy(newbuffer, buffer, size*count);
        struct swbp_mem_patch *iter = x86_32->swbbp_mem_patch_list;
-       while (iter != NULL) {
+       while (iter) {
                if (iter->physaddr >= phys_address && iter->physaddr < phys_address+(size*count)) {
                        uint32_t offset = iter->physaddr - phys_address;
                        newbuffer[offset] = SW_BP_OPCODE;
@@ -1059,7 +1059,7 @@ static int set_swbp(struct target *t, struct breakpoint *bp)
 
        /* add the memory patch */
        struct swbp_mem_patch *new_patch = malloc(sizeof(struct swbp_mem_patch));
-       if (new_patch == NULL) {
+       if (!new_patch) {
                LOG_ERROR("%s out of memory", __func__);
                return ERROR_FAIL;
        }
@@ -1069,10 +1069,10 @@ static int set_swbp(struct target *t, struct breakpoint *bp)
        new_patch->swbp_unique_id = bp->unique_id;
 
        struct swbp_mem_patch *addto = x86_32->swbbp_mem_patch_list;
-       if (addto == NULL)
+       if (!addto)
                x86_32->swbbp_mem_patch_list = new_patch;
        else {
-               while (addto->next != NULL)
+               while (addto->next)
                        addto = addto->next;
                addto->next = new_patch;
        }
@@ -1107,7 +1107,7 @@ static int unset_swbp(struct target *t, struct breakpoint *bp)
 
        /* remove from patch */
        struct swbp_mem_patch *iter = x86_32->swbbp_mem_patch_list;
-       if (iter != NULL) {
+       if (iter) {
                if (iter->swbp_unique_id == bp->unique_id) {
                        /* it's the first item */
                        x86_32->swbbp_mem_patch_list = iter->next;
@@ -1115,7 +1115,7 @@ static int unset_swbp(struct target *t, struct breakpoint *bp)
                } else {
                        while (iter->next != NULL && iter->next->swbp_unique_id != bp->unique_id)
                                iter = iter->next;
-                       if (iter->next != NULL) {
+                       if (iter->next) {
                                /* it's the next one */
                                struct swbp_mem_patch *freeme = iter->next;
                                iter->next = iter->next->next;
index b25999d3c65ccf0d619d46b96efed69d0e00dcef..dd383b6e46d50ef831ab23562d637ca09df9411e 100644 (file)
@@ -150,7 +150,7 @@ static int xscale_verify_pointer(struct command_invocation *cmd,
 
 static int xscale_jtag_set_instr(struct jtag_tap *tap, uint32_t new_instr, tap_state_t end_state)
 {
-       assert(tap != NULL);
+       assert(tap);
 
        if (buf_get_u32(tap->cur_instr, 0, tap->ir_length) != new_instr) {
                struct scan_field field;
@@ -1158,7 +1158,7 @@ static int xscale_resume(struct target *target, int current,
                struct breakpoint *breakpoint;
                breakpoint = breakpoint_find(target,
                                buf_get_u32(arm->pc->value, 0, 32));
-               if (breakpoint != NULL) {
+               if (breakpoint) {
                        uint32_t next_pc;
                        enum trace_mode saved_trace_mode;
 
@@ -1421,7 +1421,7 @@ static int xscale_step(struct target *target, int current,
        if (handle_breakpoints)
                breakpoint = breakpoint_find(target,
                                buf_get_u32(arm->pc->value, 0, 32));
-       if (breakpoint != NULL) {
+       if (breakpoint) {
                retval = xscale_unset_breakpoint(target, breakpoint);
                if (retval != ERROR_OK)
                        return retval;
@@ -3048,7 +3048,7 @@ COMMAND_HANDLER(xscale_handle_debug_handler_command)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        target = get_target(CMD_ARGV[0]);
-       if (target == NULL) {
+       if (!target) {
                LOG_ERROR("target '%s' not defined", CMD_ARGV[0]);
                return ERROR_FAIL;
        }
@@ -3083,7 +3083,7 @@ COMMAND_HANDLER(xscale_handle_cache_clean_address_command)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        target = get_target(CMD_ARGV[0]);
-       if (target == NULL) {
+       if (!target) {
                LOG_ERROR("target '%s' not defined", CMD_ARGV[0]);
                return ERROR_FAIL;
        }
index ba1f9e9f7bee9d6fd7775df6cbeeabad22b67f5c..5ec8b875458849e2af084e6b78ec37a84c93939b 100644 (file)
@@ -197,7 +197,7 @@ COMMAND_HELPER(transport_list_parse, char ***vector)
 
        /* our return vector must be NULL terminated */
        argv = calloc(n + 1, sizeof(char *));
-       if (argv == NULL)
+       if (!argv)
                return ERROR_FAIL;
 
        for (unsigned i = 0; i < n; i++) {
index 823784908d0d26748c89d1b25d85cda78043b1f3..c4ce55adcad2b99ee4c7940984b5f7614ba29e1f 100644 (file)
@@ -487,7 +487,7 @@ COMMAND_HANDLER(handle_xsvf_command)
                                        field.out_value = dr_out_buf;
                                        field.in_value = calloc(DIV_ROUND_UP(field.num_bits, 8), 1);
 
-                                       if (tap == NULL)
+                                       if (!tap)
                                                jtag_add_plain_dr_scan(field.num_bits,
                                                                field.out_value,
                                                                field.in_value,
@@ -696,7 +696,7 @@ COMMAND_HANDLER(handle_xsvf_command)
 
                                        field.in_value = NULL;
 
-                                       if (tap == NULL)
+                                       if (!tap)
                                                jtag_add_plain_ir_scan(field.num_bits,
                                                                field.out_value, field.in_value, my_end_state);
                                        else
@@ -930,7 +930,7 @@ COMMAND_HANDLER(handle_xsvf_command)
                                        if (attempt > 0 && verbose)
                                                LOG_USER("LSDR retry %d", attempt);
 
-                                       if (tap == NULL)
+                                       if (!tap)
                                                jtag_add_plain_dr_scan(field.num_bits,
                                                                field.out_value,
                                                                field.in_value,