We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ccfd122 commit c1d539aCopy full SHA for c1d539a
src/structures/gdt.rs
@@ -101,13 +101,13 @@ impl GlobalDescriptorTable {
101
pub fn add_entry(&mut self, entry: Descriptor) -> SegmentSelector {
102
let index = match entry {
103
Descriptor::UserSegment(value) => {
104
- if self.len > self.table.len() - 1 {
+ if self.len > self.table.len().saturating_sub(1) {
105
panic!("GDT full")
106
}
107
self.push(value)
108
109
Descriptor::SystemSegment(value_low, value_high) => {
110
- if self.len > self.table.len() - 2 {
+ if self.len > self.table.len().saturating_sub(2) {
111
panic!("GDT requires two free spaces to hold a SystemSegment")
112
113
let index = self.push(value_low);
0 commit comments