From 08ee7bb982b16742f52cfdc6c649d82ffa2eb177 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Sat, 3 Jul 2021 18:51:20 +0200 Subject: openocd: fix simple cases of NULL comparison 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 Reviewed-on: http://openocd.zylin.com/6350 Tested-by: jenkins --- src/flash/nor/psoc4.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/flash/nor/psoc4.c') diff --git a/src/flash/nor/psoc4.c b/src/flash/nor/psoc4.c index 28c2124..609d3b9 100644 --- a/src/flash/nor/psoc4.c +++ b/src/flash/nor/psoc4.c @@ -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); -- cgit v1.1