flash: avoid checking for non NULL pointer to free it 11/5811/4
authorAntonio Borneo <borneo.antonio@gmail.com>
Mon, 17 Aug 2020 08:08:35 +0000 (10:08 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 5 Sep 2020 16:11:34 +0000 (17:11 +0100)
commit62329444abc89ad3b37fbb4ebc2edfd1dee23351
treea5d83cee6878aa9e055ddc2e718c46b9c9e8b89b
parent47d29ebe11babdddd107ba5edab7e5cd85ce1fee
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
30 files changed:
src/flash/nand/fileio.c
src/flash/nor/ambiqmicro.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/cc3220sf.c
src/flash/nor/cfi.c
src/flash/nor/efm32.c
src/flash/nor/em357.c
src/flash/nor/kinetis.c
src/flash/nor/kinetis_ke.c
src/flash/nor/max32xxx.c
src/flash/nor/mdr.c
src/flash/nor/msp432.c
src/flash/nor/niietcm4.c
src/flash/nor/pic32mx.c
src/flash/nor/psoc4.c
src/flash/nor/psoc6.c
src/flash/nor/sim3x.c
src/flash/nor/stellaris.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/swm050.c
src/flash/nor/tms470.c
src/flash/nor/w600.c

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)