From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 1/2] common: elf: use strdup_const for symmetry
Date: Mon, 5 Jan 2026 09:33:37 +0100 [thread overview]
Message-ID: <20260105083340.3254634-1-a.fatoum@barebox.org> (raw)
The elf->filename is free'd by free_const, but it's always allocated
with strdup. Change this to strdup_const to be able to avoid duplicating
string literals.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
common/elf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/elf.c b/common/elf.c
index c68ea0be3fa6..e8126c9b64e7 100644
--- a/common/elf.c
+++ b/common/elf.c
@@ -315,7 +315,7 @@ static struct elf_image *elf_check_init(const char *filename)
}
close(fd);
- elf->filename = strdup(filename);
+ elf->filename = strdup_const(filename);
if (!elf->filename) {
ret = -ENOMEM;
goto err_free_hdr_buf;
--
2.47.3
next reply other threads:[~2026-01-05 8:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-05 8:33 Ahmad Fatoum [this message]
2026-01-05 8:33 ` [PATCH 2/2] common: elf: use memcmp for fixed-size comparison Ahmad Fatoum
2026-01-06 7:39 ` [PATCH 1/2] common: elf: use strdup_const for symmetry Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260105083340.3254634-1-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox