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

Replace reserved identifier clashes with suitable replacements #4750

Conversation

yutotakano
Copy link
Contributor

@yutotakano yutotakano commented Jul 5, 2021

Description

Closes #4630. C unconditionally reserves identifiers that either begin with two underscore, or a single underscore followed by a capital letter. MbedTLS has a few of these, and they could cause unwanted effects if the compilers decide to use these identifiers.

A slightly modified version of the grep in the issue was used to find all matches.

grep -P '^(?!#| \*| *!?\(? *defined\(| *(__asm|__attribute__|__GNUC__)).*\b(?!__FILE__|__LINE__|__ARMCC_VERSION|__ARM_ARCH|__TARGET_ARCH.*|__APPLE__|__MACH__|__GNUC__|_POSIX_*|__WATCOMC__)_[A-Z_]' library/*.c tests/suites/*.function programs/*/*.c
  • _B was replaced with B since it was safe to do so.
  • _RR (representing the precomputed value of R squared) was replaced with prec_RR since RR is defined in the same scope. The header file (bignum.h) was also edited to reflect this change.

Open to other names, since I'm not very proud of prec_RR but I can't think of anything better other than the explicit and long precomputed_RR.

Status

READY

Requires Backporting

Yes, because it is a bugfix.

Requires ChangeLog entry

Yes, as a bugfix.

@yutotakano yutotakano added bug needs-review Every commit must be reviewed by at least two team members, Arm Contribution needs-backports Backports are missing or are pending review and approval. needs-reviewer This PR needs someone to pick it up for review size-s Estimated task size: small (~2d) labels Jul 5, 2021
@yutotakano yutotakano self-assigned this Jul 5, 2021
Signed-off-by: Yuto Takano <yuto.takano@arm.com>
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.

Please rename _RR in bignum.h.

I think this warrants a changelog entry under Bugfix, since our code had undefined behavior. Something like

Don't use reserved identifiers as local variables. Fixes #4630.

Other than that, looks good to me.

The CI complaint is a warning that a renamed parameter could indicate a semantic change. Since we know the parameter didn't change semantics, this is a false positive.

@gilles-peskine-arm gilles-peskine-arm added needs-work 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 Jul 13, 2021
Signed-off-by: Yuto Takano <yuto.takano@arm.com>
@yutotakano yutotakano force-pushed the fix-reserved-identifier-clash branch from 71110d9 to 538a0cb Compare July 14, 2021 09:20
Signed-off-by: Yuto Takano <yuto.takano@arm.com>
@yutotakano yutotakano 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 labels Jul 14, 2021
Copy link
Contributor

@TRodziewicz TRodziewicz left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@gilles-peskine-arm gilles-peskine-arm 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 needs-backports Backports are missing or are pending review and approval. labels Jul 16, 2021
@gilles-peskine-arm gilles-peskine-arm merged commit 3b9bea0 into Mbed-TLS:development Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug size-s Estimated task size: small (~2d)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reserved identifiers used as local variables
3 participants