Mark io target static variables as const to avoid race conditions#2557
Merged
Mark io target static variables as const to avoid race conditions#2557
Conversation
fhanau
commented
Aug 20, 2024
|
|
||
| struct EncDetail { | ||
| char* pass = &EMPTY_PASSPHRASE[0]; | ||
| char* pass = const_cast<char*>(&EMPTY_PASSPHRASE[0]); |
Contributor
Author
There was a problem hiding this comment.
I haven't used const_cast before – let me know if this usage pattern is incorrect.
Contributor
There was a problem hiding this comment.
I think this case is ok since we don't expect anything to be written.
Also cleans up remaining instances of uninitialized variables in that target.
a6951dc to
c65a65a
Compare
fhanau
commented
Aug 20, 2024
|
|
||
| // Class which regulates a SQL query, especially to control how queries created in JavaScript | ||
| // application code are handled. | ||
| class Regulator { |
Contributor
Author
There was a problem hiding this comment.
The compiler insisted on Regulator being defined before the static constexpr Regulator variable, so I moved the subclass inside.
anonrig
approved these changes
Aug 20, 2024
jasnell
approved these changes
Aug 20, 2024
kentonv
reviewed
Aug 21, 2024
| }; | ||
|
|
||
| InputGate(Hooks& hooks = Hooks::DEFAULT); | ||
| InputGate(Hooks& hooks = const_cast<Hooks&>(Hooks::DEFAULT)); |
Member
There was a problem hiding this comment.
Generally any const_cast should come with a comment saying why it's OK. In this case: "const_cast OK because the object has no members, it's just a vtable."
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Also cleans up remaining instances of uninitialized variables in that target. Some trivial cases of static variables elsewhere are also cleaned up.