Skip to content

Commit d2fa968

Browse files
authored
Merge pull request #130 from AntoineSebert/master
Fix clippy warnings
2 parents 09ec44e + 6f913bf commit d2fa968

File tree

8 files changed

+32
-32
lines changed

8 files changed

+32
-32
lines changed

src/instructions/port.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl<T: PortRead> PortReadOnly<T> {
118118
#[cfg(feature = "const_fn")]
119119
pub const fn new(port: u16) -> PortReadOnly<T> {
120120
PortReadOnly {
121-
port: port,
121+
port,
122122
phantom: PhantomData,
123123
}
124124
}
@@ -127,7 +127,7 @@ impl<T: PortRead> PortReadOnly<T> {
127127
#[cfg(not(feature = "const_fn"))]
128128
pub fn new(port: u16) -> PortReadOnly<T> {
129129
PortReadOnly {
130-
port: port,
130+
port,
131131
phantom: PhantomData,
132132
}
133133
}
@@ -147,7 +147,7 @@ impl<T: PortWrite> PortWriteOnly<T> {
147147
#[cfg(feature = "const_fn")]
148148
pub const fn new(port: u16) -> PortWriteOnly<T> {
149149
PortWriteOnly {
150-
port: port,
150+
port,
151151
phantom: PhantomData,
152152
}
153153
}
@@ -156,7 +156,7 @@ impl<T: PortWrite> PortWriteOnly<T> {
156156
#[cfg(not(feature = "const_fn"))]
157157
pub fn new(port: u16) -> PortWriteOnly<T> {
158158
PortWriteOnly {
159-
port: port,
159+
port,
160160
phantom: PhantomData,
161161
}
162162
}
@@ -176,7 +176,7 @@ impl<T: PortReadWrite> Port<T> {
176176
#[cfg(feature = "const_fn")]
177177
pub const fn new(port: u16) -> Port<T> {
178178
Port {
179-
port: port,
179+
port,
180180
phantom: PhantomData,
181181
}
182182
}
@@ -185,7 +185,7 @@ impl<T: PortReadWrite> Port<T> {
185185
#[cfg(not(feature = "const_fn"))]
186186
pub fn new(port: u16) -> Port<T> {
187187
Port {
188-
port: port,
188+
port,
189189
phantom: PhantomData,
190190
}
191191
}

src/registers/control.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ bitflags! {
1212
/// Configuration flags of the Cr0 register.
1313
pub struct Cr0Flags: u64 {
1414
/// Enables protected mode.
15-
const PROTECTED_MODE_ENABLE = 1 << 0;
15+
const PROTECTED_MODE_ENABLE = 1;
1616
/// Enables monitoring of the coprocessor, typical for x87 instructions.
1717
///
1818
/// Controls together with the `TASK_SWITCHED` flag whether a `wait` or `fwait`
@@ -73,7 +73,7 @@ bitflags! {
7373
pub struct Cr4Flags: u64 {
7474
/// Enables hardware-supported performance enhancements for software running in
7575
/// virtual-8086 mode.
76-
const VIRTUAL_8086_MODE_EXTENSIONS = 1 << 0;
76+
const VIRTUAL_8086_MODE_EXTENSIONS = 1;
7777
/// Enables support for protected-mode virtual interrupts.
7878
const PROTECTED_MODE_VIRTUAL_INTERRUPTS = 1 << 1;
7979
/// When set, only privilege-level 0 can execute the RDTSC or RDTSCP instructions.

src/registers/model_specific.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub struct SFMask;
4848

4949
impl Efer {
5050
/// The underlying model specific register.
51-
pub const MSR: Msr = Msr(0xC0000080);
51+
pub const MSR: Msr = Msr(0xC000_0080);
5252
}
5353

5454
impl FsBase {
@@ -85,7 +85,7 @@ bitflags! {
8585
/// Flags of the Extended Feature Enable Register.
8686
pub struct EferFlags: u64 {
8787
/// Enables the `syscall` and `sysret` instructions.
88-
const SYSTEM_CALL_EXTENSIONS = 1 << 0;
88+
const SYSTEM_CALL_EXTENSIONS = 1;
8989
/// Activates long mode, requires activating paging.
9090
const LONG_MODE_ENABLE = 1 << 8;
9191
/// Indicates that long mode is active.
@@ -264,12 +264,12 @@ mod x86_64 {
264264
SegmentSelector,
265265
) {
266266
let raw = Self::read_raw();
267-
return (
267+
(
268268
SegmentSelector((raw.0 + 16).try_into().unwrap()),
269269
SegmentSelector((raw.0 + 8).try_into().unwrap()),
270270
SegmentSelector((raw.1).try_into().unwrap()),
271271
SegmentSelector((raw.1 + 8).try_into().unwrap()),
272-
);
272+
)
273273
}
274274

275275
/// Write the Ring 0 and Ring 3 segment bases.
@@ -323,7 +323,7 @@ mod x86_64 {
323323
return Err("Syscall's segment must be a Ring0 segment.");
324324
}
325325

326-
unsafe { Self::write_raw((ss_sysret.0 - 8).into(), cs_syscall.0.into()) };
326+
unsafe { Self::write_raw(ss_sysret.0 - 8, cs_syscall.0) };
327327

328328
Ok(())
329329
}

src/registers/rflags.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ bitflags! {
5858
const PARITY_FLAG = 1 << 2;
5959
/// Set by hardware if last arithmetic operation generated a carry out of the
6060
/// most-significant bit of the result.
61-
const CARRY_FLAG = 1 << 0;
61+
const CARRY_FLAG = 1;
6262
}
6363
}
6464

src/structures/idt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ bitflags! {
824824
pub struct PageFaultErrorCode: u64 {
825825
/// If this flag is set, the page fault was caused by a page-protection violation,
826826
/// else the page fault was caused by a not-present page.
827-
const PROTECTION_VIOLATION = 1 << 0;
827+
const PROTECTION_VIOLATION = 1;
828828

829829
/// If this flag is set, the memory access that caused the page fault was a write.
830830
/// Else the access that caused the page fault is a memory read. This bit does not

src/structures/paging/frame.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,26 @@ impl<S: PageSize> fmt::Debug for PhysFrame<S> {
7474
impl<S: PageSize> Add<u64> for PhysFrame<S> {
7575
type Output = Self;
7676
fn add(self, rhs: u64) -> Self::Output {
77-
PhysFrame::containing_address(self.start_address() + rhs * u64::from(S::SIZE))
77+
PhysFrame::containing_address(self.start_address() + rhs * S::SIZE)
7878
}
7979
}
8080

8181
impl<S: PageSize> AddAssign<u64> for PhysFrame<S> {
8282
fn add_assign(&mut self, rhs: u64) {
83-
*self = self.clone() + rhs;
83+
*self = *self + rhs;
8484
}
8585
}
8686

8787
impl<S: PageSize> Sub<u64> for PhysFrame<S> {
8888
type Output = Self;
8989
fn sub(self, rhs: u64) -> Self::Output {
90-
PhysFrame::containing_address(self.start_address() - rhs * u64::from(S::SIZE))
90+
PhysFrame::containing_address(self.start_address() - rhs * S::SIZE)
9191
}
9292
}
9393

9494
impl<S: PageSize> SubAssign<u64> for PhysFrame<S> {
9595
fn sub_assign(&mut self, rhs: u64) {
96-
*self = self.clone() - rhs;
96+
*self = *self - rhs;
9797
}
9898
}
9999

@@ -118,7 +118,7 @@ impl<S: PageSize> PhysFrameRange<S> {
118118
/// Returns whether the range contains no frames.
119119
#[inline]
120120
pub fn is_empty(&self) -> bool {
121-
!(self.start < self.end)
121+
self.start >= self.end
122122
}
123123
}
124124

@@ -127,7 +127,7 @@ impl<S: PageSize> Iterator for PhysFrameRange<S> {
127127

128128
fn next(&mut self) -> Option<Self::Item> {
129129
if self.start < self.end {
130-
let frame = self.start.clone();
130+
let frame = self.start;
131131
self.start += 1;
132132
Some(frame)
133133
} else {
@@ -159,7 +159,7 @@ impl<S: PageSize> PhysFrameRangeInclusive<S> {
159159
/// Returns whether the range contains no frames.
160160
#[inline]
161161
pub fn is_empty(&self) -> bool {
162-
!(self.start <= self.end)
162+
self.start >= self.end
163163
}
164164
}
165165

@@ -168,7 +168,7 @@ impl<S: PageSize> Iterator for PhysFrameRangeInclusive<S> {
168168

169169
fn next(&mut self) -> Option<Self::Item> {
170170
if self.start <= self.end {
171-
let frame = self.start.clone();
171+
let frame = self.start;
172172
self.start += 1;
173173
Some(frame)
174174
} else {

src/structures/paging/page.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,26 +206,26 @@ impl<S: PageSize> fmt::Debug for Page<S> {
206206
impl<S: PageSize> Add<u64> for Page<S> {
207207
type Output = Self;
208208
fn add(self, rhs: u64) -> Self::Output {
209-
Page::containing_address(self.start_address() + rhs * u64::from(S::SIZE))
209+
Page::containing_address(self.start_address() + rhs * S::SIZE)
210210
}
211211
}
212212

213213
impl<S: PageSize> AddAssign<u64> for Page<S> {
214214
fn add_assign(&mut self, rhs: u64) {
215-
*self = self.clone() + rhs;
215+
*self = *self + rhs;
216216
}
217217
}
218218

219219
impl<S: PageSize> Sub<u64> for Page<S> {
220220
type Output = Self;
221221
fn sub(self, rhs: u64) -> Self::Output {
222-
Page::containing_address(self.start_address() - rhs * u64::from(S::SIZE))
222+
Page::containing_address(self.start_address() - rhs * S::SIZE)
223223
}
224224
}
225225

226226
impl<S: PageSize> SubAssign<u64> for Page<S> {
227227
fn sub_assign(&mut self, rhs: u64) {
228-
*self = self.clone() - rhs;
228+
*self = *self - rhs;
229229
}
230230
}
231231

@@ -249,7 +249,7 @@ pub struct PageRange<S: PageSize = Size4KiB> {
249249
impl<S: PageSize> PageRange<S> {
250250
/// Returns wether this range contains no pages.
251251
pub fn is_empty(&self) -> bool {
252-
!(self.start < self.end)
252+
self.start >= self.end
253253
}
254254
}
255255

@@ -258,7 +258,7 @@ impl<S: PageSize> Iterator for PageRange<S> {
258258

259259
fn next(&mut self) -> Option<Self::Item> {
260260
if self.start < self.end {
261-
let page = self.start.clone();
261+
let page = self.start;
262262
self.start += 1;
263263
Some(page)
264264
} else {
@@ -300,7 +300,7 @@ pub struct PageRangeInclusive<S: PageSize = Size4KiB> {
300300
impl<S: PageSize> PageRangeInclusive<S> {
301301
/// Returns wether this range contains no pages.
302302
pub fn is_empty(&self) -> bool {
303-
!(self.start <= self.end)
303+
self.start >= self.end
304304
}
305305
}
306306

@@ -309,7 +309,7 @@ impl<S: PageSize> Iterator for PageRangeInclusive<S> {
309309

310310
fn next(&mut self) -> Option<Self::Item> {
311311
if self.start <= self.end {
312-
let page = self.start.clone();
312+
let page = self.start;
313313
self.start += 1;
314314
Some(page)
315315
} else {

src/structures/paging/page_table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ bitflags! {
114114
/// Possible flags for a page table entry.
115115
pub struct PageTableFlags: u64 {
116116
/// Specifies whether the mapped frame or page table is loaded in memory.
117-
const PRESENT = 1 << 0;
117+
const PRESENT = 1;
118118
/// Controls whether writes to the mapped frames are allowed.
119119
///
120120
/// If this bit is unset in a level 1 page table entry, the mapped frame is read-only.

0 commit comments

Comments
 (0)