Skip to content
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

Debug assert to verify the correctness at DeframerVecBuffer #1929

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion rustls/src/msgs/deframer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,12 @@ impl DeframerBuffer<'_, InternalPayload> for DeframerVecBuffer {

#[cfg(feature = "std")]
impl<'a> DeframerBuffer<'a, ExternalPayload<'a>> for DeframerVecBuffer {
fn copy(&mut self, payload: &ExternalPayload<'a>, _at: usize) {
fn copy(&mut self, payload: &ExternalPayload<'a>, at: usize) {
// The `at` was actually used before this code had to be tweaked for
// the unbuffered connection APIs support.
// Refactoring the trait and the surrounding code in a way that avoid
// having an `at` argument at the `copy` fn would be great.
debug_assert_eq!(at, self.used);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also indicated you thought some of the context from the fix commit message deserved to be a comment. That sounds reasonable to me, could you roll that into this diff?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was thinking about that too. However it is not trivial how to formulate this context from a commit message explaining why this was changes into a more permanent why is it "ok to be like this" comment for the code.
While thinking about it - I figures that maybe this is actually not an ok thing to have - and a broader remodelling of how this trait and in general part of logic is in order.

If you can agree this is the case - that is what I'll capture and add as a comment.

let len = payload.len();
self.unfilled()[..len].copy_from_slice(payload.0);
self.advance(len);
Expand Down