* [PATCH 1/1] env: superfluous check before free()
@ 2021-10-25 22:41 Heinrich Schuchardt
2021-10-26 22:42 ` Tom Rini
0 siblings, 1 reply; 2+ messages in thread
From: Heinrich Schuchardt @ 2021-10-25 22:41 UTC (permalink / raw)
To: Joe Hershberger; +Cc: Wolfgang Denk, u-boot, Heinrich Schuchardt
Free() checks if its argument in NULL. There is no need for the caller to
do the same.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
env/flash.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/env/flash.c b/env/flash.c
index ebee9069e4..473e82454d 100644
--- a/env/flash.c
+++ b/env/flash.c
@@ -210,8 +210,7 @@ static int env_flash_save(void)
perror:
flash_perror(rc);
done:
- if (saved_data)
- free(saved_data);
+ free(saved_data);
/* try to re-protect */
flash_sect_protect(1, (ulong)flash_addr, end_addr);
flash_sect_protect(1, (ulong)flash_addr_new, end_addr_new);
@@ -298,8 +297,7 @@ static int env_flash_save(void)
perror:
flash_perror(rc);
done:
- if (saved_data)
- free(saved_data);
+ free(saved_data);
/* try to re-protect */
flash_sect_protect(1, (long)flash_addr, end_addr);
return rc;
--
2.32.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] env: superfluous check before free()
2021-10-25 22:41 [PATCH 1/1] env: superfluous check before free() Heinrich Schuchardt
@ 2021-10-26 22:42 ` Tom Rini
0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2021-10-26 22:42 UTC (permalink / raw)
To: Heinrich Schuchardt; +Cc: Joe Hershberger, Wolfgang Denk, u-boot
[-- Attachment #1: Type: text/plain, Size: 292 bytes --]
On Tue, Oct 26, 2021 at 12:41:59AM +0200, Heinrich Schuchardt wrote:
> Free() checks if its argument in NULL. There is no need for the caller to
> do the same.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Applied to u-boot/master, thanks!
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-26 22:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-25 22:41 [PATCH 1/1] env: superfluous check before free() Heinrich Schuchardt
2021-10-26 22:42 ` Tom Rini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.