-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Unify error codes #8501
Comments
I think (but that's just an educated guess) that the intent was not so much helping with debugging as making each module self-contained. For a long time it was a goal that people could take just |
We discussed that as a goal around 2017. Code size didn't feature much in those discussions. Already by that time, it was not the largely case anymore (not even in 1.3): this had been untested for a long time and people had kept including more headers when they felt like it. Of course it completely went out of the window when we added |
It was an explicit goal back in the PolarSSL days. (I can remember discussions with Paul where I wanted to introduce shared things and was told "no" for this reason.) I agree that already in 2017 we were largely no longer meeting that goal when we finally made the explicit decision to drop it. All I'm saying is at the time it was still a goal, it probably influenced the decision that each low-level module had its own set of error codes. Fortunately this is no longer an obstacle. |
#9619 sets a milestone where:
|
PolarSSL was designed with each module having its own error codes. So we have, for example, many different
MBEDTLS_ERR_xxx_ALLOC_FAILED
errors, which tells you which module had a failed allocation. This doesn't actually help in debugging, and makes error handling harder. It also increases the code size because some modules convert errors from lower-level modules into their own errors.Error codes also have structure: an error code can have a low-level error, a high-level error or a combination of the two. Modules designated as low-level (e.g. individual symmetric algorithms, bignum) raise low-level errors. Modules designates as high-level (e.g. cipher, RSA, X.509, TLS) raise high-level errors possibly combined with a low-level error. This tends to increase the code size and doesn't really help with debugging. (It might be somewhat useful with debugging if an error code contained a detailed trace, but you'd need far more than two levels for that.) Combinations of error codes should be done with
MBEDTLS_ERROR_ADD
, but it's likely that there are a few places that use a plain+
.PSA has its own set of error codes, which is shared by all PSA APIs.
Minimum goals for this issue:
PSA_ERROR_INSUFFICIENT_MEMORY
.MBEDTLS_ERROR_ADD
or manual additions.In 4.0, we may still define legacy aliases to facilitate the transition, e.g.
Note that even with these aliases, this is an API break since compilers will no longer accept code like the following (“duplicate case value”):
Optional parts:
mbedtls_xxx
functions returnpsa_status_t
instead ofint
? It's formally a distinct type, but it's defined asint32_t
, so it's identical toint
on many implementations. Thus, changing a function from returningint
to returningpsa_status_t
is an API change, but we don't need to do that to just return apsa_status_t
value in a function that returnsint
(or vice versa).error.c
equivalent coveringpsa_status_t
.The text was updated successfully, but these errors were encountered: