aboutsummaryrefslogtreecommitdiff
path: root/src/flash/nor/niietcm4.c
diff options
context:
space:
mode:
authorAntonio Borneo <borneo.antonio@gmail.com>2020-08-17 10:08:35 +0200
committerAntonio Borneo <borneo.antonio@gmail.com>2020-09-05 17:11:34 +0100
commit62329444abc89ad3b37fbb4ebc2edfd1dee23351 (patch)
treea5d83cee6878aa9e055ddc2e718c46b9c9e8b89b /src/flash/nor/niietcm4.c
parent47d29ebe11babdddd107ba5edab7e5cd85ce1fee (diff)
downloadriscv-openocd-62329444abc89ad3b37fbb4ebc2edfd1dee23351.zip
riscv-openocd-62329444abc89ad3b37fbb4ebc2edfd1dee23351.tar.gz
riscv-openocd-62329444abc89ad3b37fbb4ebc2edfd1dee23351.tar.bz2
flash: avoid checking for non NULL pointer to free it
The function free() can be called with a NULL pointer as argument, no need to check the argument before. If the pointer is NULL, no operation is performed by free(). Remove the occurrences of pattern: if (ptr) free(ptr); There are cases where the pointer is set to NULL after free(), but then re-assigned within few lines. Drop the setting to NULL when this is evident. Anyway, the compiler will remove the useless assignment so no reason to be too much aggressive in this change. Change-Id: I55b2ce7cbe201410016398933e34d33a4b66e30b Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5811 Tested-by: jenkins
Diffstat (limited to 'src/flash/nor/niietcm4.c')
-rw-r--r--src/flash/nor/niietcm4.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/flash/nor/niietcm4.c b/src/flash/nor/niietcm4.c
index 2377e14..2a20edc 100644
--- a/src/flash/nor/niietcm4.c
+++ b/src/flash/nor/niietcm4.c
@@ -1469,9 +1469,7 @@ static int niietcm4_write(struct flash_bank *bank, const uint8_t *buffer,
}
free_buffer:
- if (new_buffer)
- free(new_buffer);
-
+ free(new_buffer);
return retval;
}
@@ -1681,10 +1679,9 @@ static int niietcm4_probe(struct flash_bank *bank)
struct niietcm4_flash_bank *niietcm4_info = bank->driver_priv;
struct target *target = bank->target;
- if (bank->sectors) {
- free(bank->sectors);
- bank->sectors = NULL;
- }
+ free(bank->sectors);
+ bank->sectors = NULL;
+
uint32_t retval;
uint32_t chipid;