diff options
author | Antonio Borneo <borneo.antonio@gmail.com> | 2021-07-03 21:29:32 +0200 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2021-07-24 10:38:00 +0100 |
commit | 391782318723915bd259eadf9469251c13c8fa9c (patch) | |
tree | df5fe28d94e46fd98bf54f47152034db5696f5da /src/flash | |
parent | 08ee7bb982b16742f52cfdc6c649d82ffa2eb177 (diff) | |
download | riscv-openocd-391782318723915bd259eadf9469251c13c8fa9c.zip riscv-openocd-391782318723915bd259eadf9469251c13c8fa9c.tar.gz riscv-openocd-391782318723915bd259eadf9469251c13c8fa9c.tar.bz2 |
openocd: remove NULL comparisons with checkpatch [1/2]
Patch generated automatically through the new checkpatch with
flags "--types COMPARISON_TO_NULL --fix-inplace".
This only fixes the comparisons
if (symbol == NULL)
if (symbol != NULL)
The case of NULL on the left side of the comparison is not tested.
Some automatic fix is incorrect and has been massaged by hands:
- if (*psig == NULL)
+ if (*!psig)
changed as
+ if (!*psig)
Change-Id: If4a1e2b4e547e223532e8e3d9da89bf9cb382ce6
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6351
Tested-by: jenkins
Diffstat (limited to 'src/flash')
-rw-r--r-- | src/flash/nand/core.c | 8 | ||||
-rw-r--r-- | src/flash/nor/at91sam3.c | 6 | ||||
-rw-r--r-- | src/flash/nor/at91sam4.c | 6 | ||||
-rw-r--r-- | src/flash/nor/at91sam7.c | 2 | ||||
-rw-r--r-- | src/flash/nor/at91samd.c | 2 | ||||
-rw-r--r-- | src/flash/nor/core.c | 4 | ||||
-rw-r--r-- | src/flash/nor/jtagspi.c | 2 | ||||
-rw-r--r-- | src/flash/nor/pic32mx.c | 6 | ||||
-rw-r--r-- | src/flash/nor/tcl.c | 4 | ||||
-rw-r--r-- | src/flash/nor/virtual.c | 2 | ||||
-rw-r--r-- | src/flash/nor/xcf.c | 2 |
11 files changed, 22 insertions, 22 deletions
diff --git a/src/flash/nand/core.c b/src/flash/nand/core.c index 8e2af23..d60e0d0 100644 --- a/src/flash/nand/core.c +++ b/src/flash/nand/core.c @@ -682,7 +682,7 @@ int nand_write_page(struct nand_device *nand, uint32_t page, if (nand->blocks[block].is_erased == 1) nand->blocks[block].is_erased = 0; - if (nand->use_raw || nand->controller->write_page == NULL) + if (nand->use_raw || !nand->controller->write_page) return nand_write_page_raw(nand, page, data, data_size, oob, oob_size); else return nand->controller->write_page(nand, page, data, data_size, oob, oob_size); @@ -695,7 +695,7 @@ int nand_read_page(struct nand_device *nand, uint32_t page, if (!nand->device) return ERROR_NAND_DEVICE_NOT_PROBED; - if (nand->use_raw || nand->controller->read_page == NULL) + if (nand->use_raw || !nand->controller->read_page) return nand_read_page_raw(nand, page, data, data_size, oob, oob_size); else return nand->controller->read_page(nand, page, data, data_size, oob, oob_size); @@ -769,7 +769,7 @@ int nand_read_data_page(struct nand_device *nand, uint8_t *data, uint32_t size) { int retval = ERROR_NAND_NO_BUFFER; - if (nand->controller->read_block_data != NULL) + if (nand->controller->read_block_data) retval = (nand->controller->read_block_data)(nand, data, size); if (retval == ERROR_NAND_NO_BUFFER) { @@ -809,7 +809,7 @@ int nand_write_data_page(struct nand_device *nand, uint8_t *data, uint32_t size) { int retval = ERROR_NAND_NO_BUFFER; - if (nand->controller->write_block_data != NULL) + if (nand->controller->write_block_data) retval = (nand->controller->write_block_data)(nand, data, size); if (retval == ERROR_NAND_NO_BUFFER) { diff --git a/src/flash/nor/at91sam3.c b/src/flash/nor/at91sam3.c index 3f36af2..cec86fc 100644 --- a/src/flash/nor/at91sam3.c +++ b/src/flash/nor/at91sam3.c @@ -3545,7 +3545,7 @@ COMMAND_HANDLER(sam3_handle_info_command) int r; /* bank0 must exist before we can do anything */ - if (chip->details.bank[0].bank == NULL) { + if (!chip->details.bank[0].bank) { x = 0; need_define: command_print(CMD, @@ -3571,7 +3571,7 @@ need_define: if (!(chip->details.bank[x].present)) continue; - if (chip->details.bank[x].bank == NULL) + if (!chip->details.bank[x].bank) goto need_define; if (chip->details.bank[x].probed) @@ -3606,7 +3606,7 @@ COMMAND_HANDLER(sam3_handle_gpnvm_command) return ERROR_TARGET_NOT_HALTED; } - if (chip->details.bank[0].bank == NULL) { + if (!chip->details.bank[0].bank) { command_print(CMD, "Bank0 must be defined first via: flash bank %s ...", at91sam3_flash.name); return ERROR_FAIL; diff --git a/src/flash/nor/at91sam4.c b/src/flash/nor/at91sam4.c index 23d1c5f..4ec2ee8 100644 --- a/src/flash/nor/at91sam4.c +++ b/src/flash/nor/at91sam4.c @@ -3092,7 +3092,7 @@ COMMAND_HANDLER(sam4_handle_info_command) int r; /* bank0 must exist before we can do anything */ - if (chip->details.bank[0].bank == NULL) { + if (!chip->details.bank[0].bank) { x = 0; need_define: command_print(CMD, @@ -3118,7 +3118,7 @@ need_define: if (!(chip->details.bank[x].present)) continue; - if (chip->details.bank[x].bank == NULL) + if (!chip->details.bank[x].bank) goto need_define; if (chip->details.bank[x].probed) @@ -3153,7 +3153,7 @@ COMMAND_HANDLER(sam4_handle_gpnvm_command) return ERROR_TARGET_NOT_HALTED; } - if (chip->details.bank[0].bank == NULL) { + if (!chip->details.bank[0].bank) { command_print(CMD, "Bank0 must be defined first via: flash bank %s ...", at91sam4_flash.name); return ERROR_FAIL; diff --git a/src/flash/nor/at91sam7.c b/src/flash/nor/at91sam7.c index d3eadc7..f98d186 100644 --- a/src/flash/nor/at91sam7.c +++ b/src/flash/nor/at91sam7.c @@ -1040,7 +1040,7 @@ COMMAND_HANDLER(at91sam7_handle_gpnvm_command) return ERROR_COMMAND_SYNTAX_ERROR; bank = get_flash_bank_by_num_noprobe(0); - if (bank == NULL) + if (!bank) return ERROR_FLASH_BANK_INVALID; if (strcmp(bank->driver->name, "at91sam7")) { command_print(CMD, "not an at91sam7 flash bank '%s'", CMD_ARGV[0]); diff --git a/src/flash/nor/at91samd.c b/src/flash/nor/at91samd.c index ea85039..76c08d7 100644 --- a/src/flash/nor/at91samd.c +++ b/src/flash/nor/at91samd.c @@ -1064,7 +1064,7 @@ static COMMAND_HELPER(get_u64_from_hexarg, unsigned int num, uint64_t *value) char *check = NULL; *value = strtoull(&(CMD_ARGV[num][2]), &check, 16); if ((value == 0 && errno == ERANGE) || - check == NULL || *check != 0) { + !check || *check != 0) { command_print(CMD, "Invalid 64-bit hex value in argument %d.", num + 1); return ERROR_COMMAND_SYNTAX_ERROR; diff --git a/src/flash/nor/core.c b/src/flash/nor/core.c index 41d2d34..a2d7623 100644 --- a/src/flash/nor/core.c +++ b/src/flash/nor/core.c @@ -70,7 +70,7 @@ int flash_driver_protect(struct flash_bank *bank, int set, unsigned int first, /* force "set" to 0/1 */ set = !!set; - if (bank->driver->protect == NULL) { + if (!bank->driver->protect) { LOG_ERROR("Flash protection is not supported."); return ERROR_FLASH_OPER_UNSUPPORTED; } @@ -491,7 +491,7 @@ static int flash_iterate_address_range_inner(struct target *target, return ERROR_FLASH_DST_BREAKS_ALIGNMENT; } - if (c->prot_blocks == NULL || c->num_prot_blocks == 0) { + if (!c->prot_blocks || c->num_prot_blocks == 0) { /* flash driver does not define protect blocks, use sectors instead */ iterate_protect_blocks = false; } diff --git a/src/flash/nor/jtagspi.c b/src/flash/nor/jtagspi.c index fade970..dc49fda 100644 --- a/src/flash/nor/jtagspi.c +++ b/src/flash/nor/jtagspi.c @@ -172,7 +172,7 @@ static int jtagspi_probe(struct flash_bank *bank) free(bank->sectors); info->probed = false; - if (bank->target->tap == NULL) { + if (!bank->target->tap) { LOG_ERROR("Target has no JTAG tap"); return ERROR_FAIL; } diff --git a/src/flash/nor/pic32mx.c b/src/flash/nor/pic32mx.c index 5e6c99f..a1f2cdf 100644 --- a/src/flash/nor/pic32mx.c +++ b/src/flash/nor/pic32mx.c @@ -714,7 +714,7 @@ static int pic32mx_probe(struct flash_bank *bank) } /* Check for PIC32mx1xx/2xx */ - for (i = 0; pic32mx_devs[i].name != NULL; i++) { + for (i = 0; pic32mx_devs[i].name; i++) { if (pic32mx_devs[i].devid == (device_id & 0x0fffffff)) { if ((pic32mx_devs[i].name[0] == '1') || (pic32mx_devs[i].name[0] == '2')) pic32mx_info->dev_type = (pic32mx_devs[i].name[1] == '7') ? MX_17X_27X : MX_1XX_2XX; @@ -819,14 +819,14 @@ static int pic32mx_info(struct flash_bank *bank, struct command_invocation *cmd) } int i; - for (i = 0; pic32mx_devs[i].name != NULL; i++) { + for (i = 0; pic32mx_devs[i].name; i++) { if (pic32mx_devs[i].devid == (device_id & 0x0fffffff)) { command_print_sameline(cmd, "PIC32MX%s", pic32mx_devs[i].name); break; } } - if (pic32mx_devs[i].name == NULL) + if (!pic32mx_devs[i].name) command_print_sameline(cmd, "Unknown"); command_print_sameline(cmd, " Ver: 0x%02x", diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c index d746650..b078e90 100644 --- a/src/flash/nor/tcl.c +++ b/src/flash/nor/tcl.c @@ -99,7 +99,7 @@ COMMAND_HANDLER(handle_flash_info_command) /* If the driver does not implement protection, we show the default * state of is_protected array - usually protection state unknown */ - if (p->driver->protect_check == NULL) { + if (!p->driver->protect_check) { retval = ERROR_FLASH_OPER_UNSUPPORTED; } else { /* We must query the hardware to avoid printing stale information! */ @@ -148,7 +148,7 @@ COMMAND_HANDLER(handle_flash_info_command) protect_state); } - if (p->driver->info != NULL) { + if (p->driver->info) { /* Let the flash driver print extra custom info */ retval = p->driver->info(p, CMD); command_print_sameline(CMD, "\n"); diff --git a/src/flash/nor/virtual.c b/src/flash/nor/virtual.c index deab3c0..01a9247 100644 --- a/src/flash/nor/virtual.c +++ b/src/flash/nor/virtual.c @@ -93,7 +93,7 @@ static int virtual_protect_check(struct flash_bank *bank) if (!master_bank) return ERROR_FLASH_OPERATION_FAILED; - if (master_bank->driver->protect_check == NULL) + if (!master_bank->driver->protect_check) return ERROR_FLASH_OPER_UNSUPPORTED; /* call master handler */ diff --git a/src/flash/nor/xcf.c b/src/flash/nor/xcf.c index fd31c9d..c6de1ac 100644 --- a/src/flash/nor/xcf.c +++ b/src/flash/nor/xcf.c @@ -602,7 +602,7 @@ static int xcf_probe(struct flash_bank *bank) free(bank->sectors); priv->probed = false; - if (bank->target->tap == NULL) { + if (!bank->target->tap) { LOG_ERROR("Target has no JTAG tap"); return ERROR_FAIL; } |