From: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
qemu-arm@nongnu.org
Subject: Re: [PATCH 1/4] hw/arm: use g_autofree for filename in arm_load_dtb
Date: Mon, 1 Sep 2025 16:04:13 +0300 [thread overview]
Message-ID: <CAAjaMXZNZPyga1xPLemcfF9NDwdw=_nfeW54n5pbbfZgdr7KTQ@mail.gmail.com> (raw)
In-Reply-To: <20250901125304.1047624-2-alex.bennee@linaro.org>
On Mon, Sep 1, 2025 at 3:54 PM Alex Bennée <alex.bennee@linaro.org> wrote:
>
> The function has quite a number of exit cases so lets try and clean
> things up with g_autofree. As the fdt hasn't be allocated yet we can
> return directly from the fail point.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
> hw/arm/boot.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/hw/arm/boot.c b/hw/arm/boot.c
> index d391cd01bb1..56fd13b9f7c 100644
> --- a/hw/arm/boot.c
> +++ b/hw/arm/boot.c
> @@ -528,20 +528,18 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
> Error *err = NULL;
>
> if (binfo->dtb_filename) {
> - char *filename;
> - filename = qemu_find_file(QEMU_FILE_TYPE_DTB, binfo->dtb_filename);
> + g_autofree char *filename = qemu_find_file(QEMU_FILE_TYPE_DTB,
> + binfo->dtb_filename);
> if (!filename) {
> fprintf(stderr, "Couldn't open dtb file %s\n", binfo->dtb_filename);
> - goto fail;
> + return -1;
> }
>
> fdt = load_device_tree(filename, &size);
> if (!fdt) {
> fprintf(stderr, "Couldn't open dtb file %s\n", filename);
> - g_free(filename);
> goto fail;
> }
> - g_free(filename);
> } else {
> fdt = binfo->get_dtb(binfo, &size);
> if (!fdt) {
> --
> 2.47.2
>
>
next prev parent reply other threads:[~2025-09-01 13:05 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-01 12:53 [PATCH 0/4] arm_load_dtb cleanups Alex Bennée
2025-09-01 12:53 ` [PATCH 1/4] hw/arm: use g_autofree for filename in arm_load_dtb Alex Bennée
2025-09-01 13:04 ` Manos Pitsidianakis [this message]
2025-09-03 3:53 ` Richard Henderson
2025-09-01 12:53 ` [PATCH 2/4] hw/arm: use g_autofree for fdt " Alex Bennée
2025-09-01 13:01 ` Manos Pitsidianakis
2025-09-02 9:36 ` Peter Maydell
2025-09-03 8:16 ` Alex Bennée
2025-09-03 10:04 ` Peter Maydell
2025-09-03 10:05 ` Alex Bennée
2025-09-01 12:53 ` [PATCH 3/4] hw/arm: use g_auto(GStrv) for node_path " Alex Bennée
2025-09-01 13:05 ` Manos Pitsidianakis
2025-09-03 3:59 ` Richard Henderson
2025-09-01 12:53 ` [PATCH 4/4] hw/arm: expose Error * to arm_load_dtb Alex Bennée
2025-09-01 13:03 ` Manos Pitsidianakis
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='CAAjaMXZNZPyga1xPLemcfF9NDwdw=_nfeW54n5pbbfZgdr7KTQ@mail.gmail.com' \
--to=manos.pitsidianakis@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).