Skip to content
New issue

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

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

Already on GitHub? # to your account

Define legacy error codes as aliases for PSA error codes #9629

Conversation

gilles-peskine-arm
Copy link
Contributor

Part of #9619. Precise goal not defined yet.

Continues #9566.

Status: DI in progress, for CI feedback.

PR checklist

  • changelog TODO
  • development PR here
  • framework PR not required
  • 3.6 PR not required because: new stuff
  • 2.28 PR not required because: new stuff
  • tests provided

Replace obvious additions of an `MBEDTLS_ERR_xxx` constant by a call to
`MBEDTLS_ERROR_ADD`.

Skip `case` statements since `MBEDTLS_ERROR_ADD(pp_constant)` is not a
preprocessor constant.

This commit does not replace additions split over lines. Those will be
handled in a subsequent commit.

```
git ls-files '*.h' '*.c' '*.function' '*.data' |
xargs perl -i -pe '
    next if /\bcase\b/;
    s/\b(MBEDTLS_ERR_\w+)\s*\+\s*(\w+)\b/MBEDTLS_ERROR_ADD($1, $2)/g;
    s/\b(\w+)\s*\+\s*(MBEDTLS_ERR_\w+)\b/MBEDTLS_ERROR_ADD($1, $2)/g'
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Reject direct additions of error constants (regex-based approximation).

Fix the lone straggler.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
What could possibly go wrong...

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
We mostly use MBEDTLS_ERROR_ADD with both a low-level and a high-level
error, but we also occasionally use it with a low-level code that can be 0.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
@gilles-peskine-arm gilles-peskine-arm added needs-ci Needs to pass CI tests needs-preceding-pr Requires another PR to be merged first priority-high High priority - will be reviewed soon labels Sep 24, 2024
@gilles-peskine-arm
Copy link
Contributor Author

Productized as Mbed-TLS/TF-PSA-Crypto#167 and #9926.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
needs-ci Needs to pass CI tests needs-preceding-pr Requires another PR to be merged first priority-high High priority - will be reviewed soon
Development

Successfully merging this pull request may close these issues.

1 participant