-
Notifications
You must be signed in to change notification settings - Fork 55
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
td-shim: remove the use of Vec
in e820
#700
td-shim: remove the use of Vec
in e820
#700
Conversation
5b49c49
to
4a60eb0
Compare
td-shim/src/bin/td-shim/e820.rs
Outdated
} | ||
|
||
// Move all entries after the index back one position | ||
for idx in (index + 1..self.num_entries + 1).rev() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if the index > self.num_entries?
what if the index == self.num_entries?
td-shim/src/bin/td-shim/e820.rs
Outdated
} | ||
|
||
// Move all entries after the index forward one position | ||
for idx in index + 1..self.num_entries { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if the index > self.num_entries?
what if the index == self.num_entries?
Reducing the use of heap can improve the functional safety. For e820 implementation, use an fixed `MAX_E820_ENTRY` size array to replace the vector. Signed-off-by: Jiaqi Gao <[email protected]>
4a60eb0
to
387cc8b
Compare
} | ||
|
||
fn remove_entry(&mut self, index: usize) -> Result<(), E820Error> { | ||
if index >= self.num_entries { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if self.num_entries is 0 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if self.num_entries == 0
, the index >= self.num_entries
will always be true, then it will return error
Reducing the use of heap can improve the functional safety. For e820 implementation, use an fixed
MAX_E820_ENTRY
size array to replace the vector.Relate issue: #685