-
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
Introduce const qualifiers in the API wherever appropriate #1485
Comments
related issue: #396 |
I would like to suggest a change that would not break any existing code but might make life easier for applications that want to use If you cannot actually make any of the arguments const right now, so be it. But please for each such argument that you would like to make const and is (beyond being passed as a non-const pointer for historical reasons) actually const, just document in the Doxygen headers that "Despite taking them as non-const pointers, this function does not modify arguments x,z,y. In a future major release they will be made const.". Then, callers can know it is actually safe to cast An example where the situation is currently ambiguous - |
Note: This issue enhances #803 |
I don't think that part is valid: |
I'm closing this as it has been superseded by #4033 |
There are many places in the code that could benefit from using const qualifiers in the function arguments' lists. However introducing such change at this moment will cause a wide range API change. It is worth considering as it is an idiomatic C approach and the lack of the const qualifiers has been reported to cause inconvenience in third party code, which lead to submitting the following (potentially more) PRs:
pk.h
)pk.h
)bignum.h
)ecp.h
,ecdsa.h
: thembedtls_ecp_group *grp
argument to many functions, and as a consequence pointers to structures containing an ECP group such as thectx
argument ofmbedtls_ecdsa_read_signature
andmbedtls_ecdsa_write_signature
.The main problem with the current API is that if somebody wishes to use const qualifiers in their code, they will need to cast away the constness of their pointers.
The text was updated successfully, but these errors were encountered: