Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 532eacb

Browse files
committed
clippy: add const to more fns
1 parent 90f24de commit 532eacb

File tree

10 files changed

+11
-11
lines changed

10 files changed

+11
-11
lines changed

‎uefi/src/mem/aligned_buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl AlignedBuffer {
4747

4848
/// Get a mutable pointer to the aligned memory region managed by this instance.
4949
#[must_use]
50-
pub fn ptr_mut(&mut self) -> *mut u8 {
50+
pub constfn ptr_mut(&mut self) -> *mut u8 {
5151
self.ptr.as_ptr()
5252
}
5353

‎uefi/src/mem/memory_map/impl_.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ impl MemoryMapBackingMemory {
335335

336336
/// Returns a mutable slice to the underlying memory.
337337
#[must_use]
338-
pub fn as_mut_slice(&mut self) -> &mut [u8] {
338+
pub constfn as_mut_slice(&mut self) -> &mut [u8] {
339339
unsafe { self.0.as_mut() }
340340
}
341341
}

‎uefi/src/proto/ata/pass_thru.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pub struct AtaDevice<'a> {
105105
}
106106

107107
impl AtaDevice<'_> {
108-
fn proto_mut(&mut self) -> *mut AtaPassThruProtocol {
108+
constfn proto_mut(&mut self) -> *mut AtaPassThruProtocol {
109109
ptr::from_ref(self.proto).cast_mut()
110110
}
111111

‎uefi/src/proto/console/gop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ impl FrameBuffer<'_> {
569569
///
570570
/// On some implementations this framebuffer pointer can be used after
571571
/// exiting boot services, but that is not guaranteed by the UEFI Specification.
572-
pub fn as_mut_ptr(&mut self) -> *mut u8 {
572+
pub constfn as_mut_ptr(&mut self) -> *mut u8 {
573573
self.base
574574
}
575575

‎uefi/src/proto/console/text/output.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl Output {
7272

7373
/// Returns an iterator of all supported text modes.
7474
// TODO: Bring back impl Trait once the story around bounds improves
75-
pub fn modes(&mut self) -> OutputModeIter<'_> {
75+
pub constfn modes(&mut self) -> OutputModeIter<'_> {
7676
let max = self.data().max_mode as usize;
7777
OutputModeIter {
7878
output: self,

‎uefi/src/proto/device_path/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub struct DevicePathBuilder<'a> {
7979

8080
impl<'a> DevicePathBuilder<'a> {
8181
/// Create a builder backed by a statically-sized buffer.
82-
pub fn with_buf(buf: &'a mut [MaybeUninit<u8>]) -> Self {
82+
pub constfn with_buf(buf: &'a mut [MaybeUninit<u8>]) -> Self {
8383
Self {
8484
storage: BuilderStorage::Buf { buf, offset: 0 },
8585
}

‎uefi/src/proto/loaded_image.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl LoadedImage {
131131
/// long enough.
132132
///
133133
/// [shim]: https://github.com/rhboot/shim/blob/4d64389c6c941d21548b06423b8131c872e3c3c7/pe.c#L1143
134-
pub unsafe fn set_image(&mut self, data: *const c_void, size: u64) {
134+
pub constunsafe fn set_image(&mut self, data: *const c_void, size: u64) {
135135
self.0.image_base = data;
136136
self.0.image_size = size;
137137
}
@@ -167,7 +167,7 @@ impl LoadedImage {
167167
/// must ensure that the memory lives long enough.
168168
///
169169
/// [`boot::start_image`]: crate::boot::start_image
170-
pub unsafe fn set_load_options(&mut self, options: *const u8, size: u32) {
170+
pub constunsafe fn set_load_options(&mut self, options: *const u8, size: u32) {
171171
self.0.load_options = options.cast();
172172
self.0.load_options_size = size;
173173
}

‎uefi/src/proto/network/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl IpAddress {
5858
}
5959

6060
#[must_use]
61-
fn as_raw_ptr_mut(&mut self) -> *mut uefi_raw::IpAddress {
61+
constfn as_raw_ptr_mut(&mut self) -> *mut uefi_raw::IpAddress {
6262
// The uefi-raw type is defined differently, but the layout is
6363
// compatible.
6464
self.0.as_mut_ptr().cast()

‎uefi/src/proto/nvme/pass_thru.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pub struct NvmeNamespace<'a> {
119119
}
120120

121121
impl NvmeNamespace<'_> {
122-
fn proto_mut(&mut self) -> *mut NvmExpressPassThruProtocol {
122+
constfn proto_mut(&mut self) -> *mut NvmExpressPassThruProtocol {
123123
ptr::from_ref(self.proto).cast_mut()
124124
}
125125

‎uefi/src/proto/scsi/pass_thru.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub struct ScsiDevice<'a> {
130130
target_lun: ScsiTargetLun,
131131
}
132132
impl ScsiDevice<'_> {
133-
fn proto_mut(&mut self) -> *mut ExtScsiPassThruProtocol {
133+
constfn proto_mut(&mut self) -> *mut ExtScsiPassThruProtocol {
134134
ptr::from_ref(self.proto).cast_mut()
135135
}
136136

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /