From: Samuel Tardieu <sam@rfc1149.net>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, Richard Henderson <richard.henderson@linaro.org>
Subject: Re: [PATCH 2/2] tcg: Jump after always false condition
Date: Tue, 19 Dec 2023 18:55:59 +0100 [thread overview]
Message-ID: <871qbiys6w.fsf@rfc1149.net> (raw)
In-Reply-To: <CAFEAcA_f93-Siwmc_5hVrz=A5Rva_d6bWFXYoRcb90AXZXJhmg@mail.gmail.com>
Peter Maydell <peter.maydell@linaro.org> writes:
> So, well, all of this is definitely removing dead
> code, but on the other hand it's also moving away
> from the coding-style pattern the function has at
> the moment, which is "there is a fail-and-exit
> codepath which is robust against wherever you might
> choose to jump to it, and so if we need to add new
> code to this function then it also can jump to 'fail'
> without any further updates to that error-exit path".
> Instead we end up with an "every error-exit check
> does its own tidyup" idiom. For the sake of not having
> a static checker say "this is technically dead code",
> is that worth doing, or does it make the code a little
> less readable and less amenable to future modification?
> I'm not sure...
Hi Peter.
I see your point and I agree with you. Perhaps we could get the
best of both worlds by:
- renaming `fail_rx` as `fail`, so that we get a unique exit block
— not only will the compiler optimize the jump if it can, and
this is the slow path anyway
- adding a one-line comment saying that `buf_rx` is always
`MAP_FAILED` – that will let people know that they might need to
add a cleanup if they add another jump to `fail`
- calling `error_setg_errno()` at the right place before jumping
to `fail`
I will produce a v2 to make this proposal clearer.
Sam
--
Samuel Tardieu
prev parent reply other threads:[~2023-12-19 18:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-14 23:30 [PATCH 0/2] Remove unreachable code and move label after unreachable condition Samuel Tardieu
2023-12-14 23:30 ` [PATCH 1/2] tcg: Remove unreachable code Samuel Tardieu
2023-12-19 17:14 ` Peter Maydell
2023-12-14 23:30 ` [PATCH 2/2] tcg: Jump after always false condition Samuel Tardieu
2023-12-19 17:26 ` Peter Maydell
2023-12-19 17:55 ` Samuel Tardieu [this message]
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=871qbiys6w.fsf@rfc1149.net \
--to=sam@rfc1149.net \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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 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.