constify many functions in x509_vfy.h etc.#10504
constify many functions in x509_vfy.h etc.#10504DDvO wants to merge 8 commits intoopenssl:masterfrom
Conversation
|
Why not make the name attribute in those local structs const? |
Can this be done for situations like this in |
|
BTW, I find the programming pattern in |
|
Looking for a solution that avoids the type casts to non-const, but this did not work for two reasons: the compiler cannot handle non-static initialization (with the What would work is to copy the name: and later free it, but this would be inefficient. |
|
Then I realized that it would be much better to replace the Doing so I had to introduce just one type cast to non-const in of I added the following comment there for justification: I also had to adapt a couple of slightly fishy code sections in Due to the new constifications I was able to remove again the five casts to non-const that I had introduced yesterday. I also found some new opportunities for little code simplifications, which I did. I also found and eliminated some casts to non-const that were no longer needed for instance due to my earlier constification of ASN.1 |
|
For backwards compatibility, you need to be careful with everything in the public headers. Some const changes will require the applications to also change it to const, which is not something we want to force them to do (at this time.) |
|
@kroeckx, I understand the point regarding backward compatibility. If I revert my improvements regarding |
|
I actually felt the incompatibilities of constifying |
|
OpenSSL 3.0 is supposed to remain as compatible as possible, we
expect most applications to just need to rebuild and not make any
changes. Anything that requires them to make changes needs to wait
until at least 4.0.
I think there are 3 types that I complained about:
- Changing the return type to const
- Changing a "TYPE **" parameter to a "const TYPE **"
- Chaning a public member of a struct to const.
They all require the users to also change their variable to const.
|
|
I see - thanks for the clarification! |
1fe7ddf to
ad754a3
Compare
|
@kroeckx, finally I've found the time to execute all requested changes. |
|
I've just did a quick look at this, and currently don't have any objections. Didn't have time to do a full review. |
|
Thanks nevertheless for your quick scan & response! |
|
This PR contributes to handling the long-standing issue #3742 ("more const"). |
@kroeckx, when do you think you'll be able to do a full review? |
|
I've just picked up this stalled PR, rebasing and simplifying it. @kroeckx, can you resume reviewing this soon, or who else? |
|
I have no idea when I'll find the time to review this
|
I see. Anyone willing to fill in? Actually after my recent simplifications the PR consists basically just of a large number of straightforward additions of I've also added a couple of comments why certain constifications cannot be done (at least as long as compatibility is an issue). Since meanwhile I'm confident that the set of changes done in this PR has stabilized I've updated the documentation accordingly. |
|
Please rebase |
…ructures and functions
|
Thanks @t8m for taking over the review of this (simplified) PR! |
|
The Travis failure is just a timeout. |
|
24 hours has passed since 'approval: done' was set, but this PR has failing CI tests. Once the tests pass it will get moved to 'approval: ready to merge' automatically, alternatively please review and set the label manually. |
|
Please squash the commits and add some descriptive commit message when merging. |
…pps/
in particular X509_NAME*, X509_STORE{,_CTX}*, and ASN1_INTEGER *,
also some result types of new functions, which does not break compatibility
Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: David von Oheimb <[email protected]>
(Merged from #10504)
… tests constify a local variable in cmp_client.c reflecting the merge of openssl#10504
Due to a little
constincident in #10502 I've tentatively constified most ofx509_vfy.hand friends.As far as folks are fine with these changes I'll update the respective doc files accordingly.
I had to introduce type casts from
const X509_NAME*to non-constX509_NAMEat five places wherenameparameter pointers are stored in a local structure, but these should be harmless because the structure contents are used only for lookup and are not modified.