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 90f24de

Browse files
committed
clippy: apply latest fixes
1 parent b8e1df0 commit 90f24de

File tree

18 files changed

+49
-49
lines changed

18 files changed

+49
-49
lines changed

‎uefi-macros/src/lib.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,10 @@ pub fn unsafe_protocol(args: TokenStream, input: TokenStream) -> TokenStream {
6969
quote!(::uefi::guid!(#lit))
7070
}
7171
Expr::Path(ExprPath { path, .. }) => quote!(#path),
72-
_ => {
73-
return err!(
74-
expr,
75-
"macro input must be either a string literal or path to a constant"
76-
)
77-
.into();
78-
}
72+
_ => err!(
73+
expr,
74+
"macro input must be either a string literal or path to a constant"
75+
),
7976
};
8077

8178
let item_struct = parse_macro_input!(input as ItemStruct);

‎uefi/src/data_types/strs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -993,10 +993,10 @@ mod tests {
993993
fn test_unaligned_cstr16() {
994994
let mut buf = [0u16; 6];
995995
let us = unsafe {
996-
let ptr = buf.as_mut_ptr()as*mutu8;
996+
let ptr = buf.as_mut_ptr().cast::<u8>();
997997
// Intentionally create an unaligned u16 pointer. This
998998
// leaves room for five u16 characters.
999-
let ptr = ptr.add(1)as*mutu16;
999+
let ptr = ptr.add(1).cast::<u16>();
10001000
// Write out the "test" string.
10011001
ptr.add(0).write_unaligned(b't'.into());
10021002
ptr.add(1).write_unaligned(b'e'.into());

‎uefi/src/mem/aligned_buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ mod tests {
112112
#[test]
113113
fn test_allocation_alignment() {
114114
for request_alignment in [1, 2, 4, 8, 16, 32, 64, 128] {
115-
for request_len in [1asusize, 32, 64, 128, 1024] {
115+
for request_len in [1_usize, 32, 64, 128, 1024] {
116116
let buffer =
117117
AlignedBuffer::from_size_align(request_len, request_alignment).unwrap();
118118
assert_eq!(buffer.ptr() as usize % request_alignment, 0);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,13 +461,13 @@ mod tests {
461461
];
462462

463463
/// Returns a copy of [`BASE_MMAP_UNSORTED`] owned on the stack.
464-
fn new_mmap_memory() -> [MemoryDescriptor; 3] {
464+
constfn new_mmap_memory() -> [MemoryDescriptor; 3] {
465465
BASE_MMAP_UNSORTED
466466
}
467467

468468
fn mmap_raw<'a>(memory: &mut [MemoryDescriptor]) -> (&'a mut [u8], MemoryMapMeta) {
469469
let desc_size = size_of::<MemoryDescriptor>();
470-
let len = memory.len()* desc_size;
470+
let len = core::mem::size_of_val(memory);
471471
let ptr = memory.as_mut_ptr().cast::<u8>();
472472
let slice = unsafe { core::slice::from_raw_parts_mut(ptr, len) };
473473
let meta = MemoryMapMeta {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ mod tests_mmap_artificial {
110110
fn buffer_to_map(buffer: &mut [MemoryDescriptor]) -> MemoryMapRefMut {
111111
let mmap_len = size_of_val(buffer);
112112
let mmap = {
113-
unsafe { core::slice::from_raw_parts_mut(buffer.as_mut_ptr()as*mutu8, mmap_len) }
113+
unsafe { core::slice::from_raw_parts_mut(buffer.as_mut_ptr().cast::<u8>(), mmap_len) }
114114
};
115115

116116
MemoryMapRefMut::new(

‎uefi/src/polyfill.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub const unsafe fn maybe_uninit_slice_assume_init_ref<T>(s: &[MaybeUninit<T>])
1818
/// Polyfill for the unstable `MaybeUninit::slice_as_mut_ptr` function.
1919
///
2020
/// See <https://github.com/rust-lang/rust/issues/63569>.
21-
pub fn maybe_uninit_slice_as_mut_ptr<T>(s: &mut [MaybeUninit<T>]) -> *mut T {
21+
pub constfn maybe_uninit_slice_as_mut_ptr<T>(s: &mut [MaybeUninit<T>]) -> *mut T {
2222
s.as_mut_ptr().cast::<T>()
2323
}
2424

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ impl<'a> AtaResponse<'a> {
294294
/// # Returns
295295
/// A reference to the [`AtaStatusBlock`] containing details about the status of the executed operation.
296296
#[must_use]
297-
pub fn status(&self) -> &'a AtaStatusBlock {
297+
pub constfn status(&self) -> &'a AtaStatusBlock {
298298
unsafe {
299299
self.req
300300
.asb
@@ -310,7 +310,7 @@ impl<'a> AtaResponse<'a> {
310310
/// # Returns
311311
/// `Option<&[u8]>`: A slice of the data read from the device, or `None` if no read buffer was used.
312312
#[must_use]
313-
pub fn read_buffer(&self) -> Option<&'a [u8]> {
313+
pub constfn read_buffer(&self) -> Option<&'a [u8]> {
314314
if self.req.packet.in_data_buffer.is_null() {
315315
return None;
316316
}

‎uefi/src/proto/boot_policy.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,8 @@ mod tests {
5151

5252
#[test]
5353
fn boot_policy() {
54-
assert_eq!(
55-
BootPolicy::try_from(Boolean::TRUE).unwrap(),
56-
BootPolicy::BootSelection
57-
);
58-
assert_eq!(
59-
BootPolicy::try_from(Boolean::FALSE).unwrap(),
60-
BootPolicy::ExactMatch
61-
);
54+
assert_eq!(BootPolicy::from(Boolean::TRUE), BootPolicy::BootSelection);
55+
assert_eq!(BootPolicy::from(Boolean::FALSE), BootPolicy::ExactMatch);
6256
assert_eq!(Boolean::from(BootPolicy::BootSelection), Boolean::TRUE);
6357
assert_eq!(Boolean::from(BootPolicy::ExactMatch), Boolean::FALSE);
6458
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ mod tests {
248248
};
249249
use core::slice;
250250

251-
fn path_to_bytes(path: &DevicePath) -> &[u8] {
251+
constfn path_to_bytes(path: &DevicePath) -> &[u8] {
252252
unsafe { slice::from_raw_parts(path.as_ffi_ptr().cast::<u8>(), size_of_val(path)) }
253253
}
254254

‎uefi/src/proto/loaded_image.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl LoadedImage {
9595
///
9696
/// [`load_options_as_cstr16`]: `Self::load_options_as_cstr16`
9797
#[must_use]
98-
pub fn load_options_as_bytes(&self) -> Option<&[u8]> {
98+
pub constfn load_options_as_bytes(&self) -> Option<&[u8]> {
9999
if self.0.load_options.is_null() {
100100
None
101101
} else {

0 commit comments

Comments
(0)

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