openocd: fix simple cases of NULL comparison
[fw/openocd] / src / flash / nor / stm32lx.c
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);