Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bignum] Fix 32 bit unreachable code build failure #7806

Merged

Conversation

paul-elliott-arm
Copy link
Member

@paul-elliott-arm paul-elliott-arm commented Jun 20, 2023

Description

Given the size of ciL is set dependant on MBEDTLS_HAVE_INT32, clang rightfully reports this as unreachable code. Fix this by using #define guards instead.

Addresses #7787

PR checklist

Please tick as appropriate and edit the reasons (e.g.: "backport: not needed because this is a new feature")

  • changelog provided, or not required
  • backport done, or not required
  • tests provided, or not required

@paul-elliott-arm paul-elliott-arm self-assigned this Jun 20, 2023
@paul-elliott-arm paul-elliott-arm changed the title Fix 32 bit unreachable code build failure [Bignum] Fix 32 bit unreachable code build failure Jun 20, 2023
@paul-elliott-arm paul-elliott-arm added bug needs-review Every commit must be reviewed by at least two team members, needs-reviewer This PR needs someone to pick it up for review single-reviewer This PR qualifies for having only one reviewer priority-high High priority - will be reviewed soon size-xs Estimated task size: extra small (a few hours at most) labels Jun 20, 2023
@gilles-peskine-arm gilles-peskine-arm added needs-ci Needs to pass CI tests and removed needs-review Every commit must be reviewed by at least two team members, needs-reviewer This PR needs someone to pick it up for review single-reviewer This PR qualifies for having only one reviewer labels Jun 20, 2023
@gilles-peskine-arm
Copy link
Contributor

Thanks for fixing this, unfortunately the CI is unhappy.

@gilles-peskine-arm
Copy link
Contributor

Also please add a changelog entry, since this is fixing a reported bug.

Given the size of ciL is set dependant on MBEDTLS_HAVE_INT32 /
MBEDTLS_HAVE_INT64, clang rightfully reports this as unreachable code in
32 bit builds. Fix this by using #define guards instead.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
@gilles-peskine-arm gilles-peskine-arm added needs-review Every commit must be reviewed by at least two team members, needs-reviewer This PR needs someone to pick it up for review and removed needs-work needs-ci Needs to pass CI tests labels Jun 20, 2023
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a correct change.

Also, I've confirmed that this fixes the build in the default configuration on x86_64 with make lib CC=clang-15 CFLAGS='-Werror -Wall -Wextra -Wunreachable-code'. Together with #7805, this fixes the build in the default configuration with CC=clang-15 cmake on 32-bit x86.

Ok for merging this with no changelog entry since this only fixes a compiler warning, not code that was actually wrong, and it doesn't fix all the reported issues in #7787.

@gilles-peskine-arm gilles-peskine-arm added approved Design and code approved - may be waiting for CI or backports single-reviewer This PR qualifies for having only one reviewer and removed needs-review Every commit must be reviewed by at least two team members, needs-reviewer This PR needs someone to pick it up for review labels Jun 20, 2023
@gilles-peskine-arm gilles-peskine-arm merged commit a3a0025 into Mbed-TLS:development Jun 20, 2023
14 of 17 checks passed
}
#ifdef MBEDTLS_HAVE_INT64
M[P224_WIDTH_MIN] &= ((mbedtls_mpi_uint)-1) >> (P224_UNUSED_BITS);
#endif

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it have a space before #endif

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, so it does, thanks for letting us know.

Weird that our code style checker didn't object to that one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Design and code approved - may be waiting for CI or backports bug priority-high High priority - will be reviewed soon single-reviewer This PR qualifies for having only one reviewer size-xs Estimated task size: extra small (a few hours at most)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compilation failure on 32-bit and 64-bit arm platforms with a recent clang
3 participants