mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] boot: omit menu freeing loop when CONFIG_MENU is disabled
@ 2025-02-14  9:54 Ahmad Fatoum
  2025-02-17  9:49 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2025-02-14  9:54 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

While free() can handle NULL pointers, it's better to not even call
free() when we know at compile-time that the pointers are NULL.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/boot.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/common/boot.c b/common/boot.c
index f6ac4779cc33..ced3b3a3477c 100644
--- a/common/boot.c
+++ b/common/boot.c
@@ -50,13 +50,14 @@ void bootentries_free(struct bootentries *bootentries)
 		be->release(be);
 	}
 
-	if (bootentries->menu) {
+	if (IS_ENABLED(CONFIG_MENU) && bootentries->menu) {
 		int i;
 		for (i = 0; i < bootentries->menu->display_lines; i++)
 			free_const(bootentries->menu->display[i]);
 		free_const(bootentries->menu->display);
+		free(bootentries->menu);
 	}
-	free(bootentries->menu);
+
 	free(bootentries);
 }
 
-- 
2.39.5




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-02-17  9:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-14  9:54 [PATCH] boot: omit menu freeing loop when CONFIG_MENU is disabled Ahmad Fatoum
2025-02-17  9:49 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox