mbox series

[v2,0/2] tcg: Jump after always false condition

Message ID 20231219182212.455952-1-sam@rfc1149.net
Headers show
Series tcg: Jump after always false condition | expand

Message

Samuel Tardieu Dec. 19, 2023, 6:22 p.m. UTC
Unreachable code in an error handling block is listed in issue
https://gitlab.com/qemu-project/qemu/-/issues/2030.

After removing this code, the `fail` label is now immediately followed
by a test whose condition can never be true when coming explicitly
via this label. Moving the label down preserves the fall-through
case while avoiding testing an always false condition.

Changes from v1:
- Add a comment explaining that `buf_rx` does not require cleanup
- Use a unique cleanup path for the function by setting `errno` before
  jumping to the cleanup block.

Samuel Tardieu (2):
  tcg: Remove unreachable code
  tcg: Make the cleanup-on-error path unique

 tcg/region.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Comments

Peter Maydell Jan. 15, 2024, 5:11 p.m. UTC | #1
On Tue, 19 Dec 2023 at 18:23, Samuel Tardieu <sam@rfc1149.net> wrote:
>
> Unreachable code in an error handling block is listed in issue
> https://gitlab.com/qemu-project/qemu/-/issues/2030.
>
> After removing this code, the `fail` label is now immediately followed
> by a test whose condition can never be true when coming explicitly
> via this label. Moving the label down preserves the fall-through
> case while avoiding testing an always false condition.
>
> Changes from v1:
> - Add a comment explaining that `buf_rx` does not require cleanup
> - Use a unique cleanup path for the function by setting `errno` before
>   jumping to the cleanup block.
>
> Samuel Tardieu (2):
>   tcg: Remove unreachable code
>   tcg: Make the cleanup-on-error path unique
>
>  tcg/region.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

RTH: I'm assuming you'll take this via your tcg tree.

thanks
-- PMM
Richard Henderson Jan. 15, 2024, 10:01 p.m. UTC | #2
On 12/20/23 05:22, Samuel Tardieu wrote:
> Unreachable code in an error handling block is listed in issue
> https://gitlab.com/qemu-project/qemu/-/issues/2030.
> 
> After removing this code, the `fail` label is now immediately followed
> by a test whose condition can never be true when coming explicitly
> via this label. Moving the label down preserves the fall-through
> case while avoiding testing an always false condition.
> 
> Changes from v1:
> - Add a comment explaining that `buf_rx` does not require cleanup
> - Use a unique cleanup path for the function by setting `errno` before
>    jumping to the cleanup block.
> 
> Samuel Tardieu (2):
>    tcg: Remove unreachable code
>    tcg: Make the cleanup-on-error path unique
> 
>   tcg/region.c | 10 ++++------
>   1 file changed, 4 insertions(+), 6 deletions(-)
> 

Queued, thanks.


r~