Skip to content

Commit 0dcda0d

Browse files
Alexandra Iordacheandreeaflorescu
Alexandra Iordache
authored andcommitted
fix clippy warnings
Signed-off-by: Alexandra Iordache <[email protected]>
1 parent 21f4f32 commit 0dcda0d

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/loader/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ pub fn load_cmdline<M: GuestMemory>(
399399
.checked_add(len as u64 + 1)
400400
.ok_or(Error::CommandLineOverflow)?; // Extra for null termination.
401401
if end > guest_mem.last_addr() {
402-
return Err(Error::CommandLineOverflow)?;
402+
return Err(Error::CommandLineOverflow);
403403
}
404404

405405
guest_mem

src/loader/struct_util.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ pub enum Error {
1818
pub type Result<T> = std::result::Result<T, Error>;
1919

2020
/// Reads a struct from an input buffer.
21-
/// This is unsafe because the struct is initialized to unverified data read from the input.
22-
/// `read_struct` should only be called to fill plain old data structs. It is not endian safe.
2321
///
2422
/// # Arguments
2523
///
2624
/// * `f` - The input to read from. Often this is a file.
2725
/// * `out` - The struct to fill with data read from `f`.
26+
///
27+
/// # Safety
28+
///
29+
/// This is unsafe because the struct is initialized to unverified data read from the input.
30+
/// `read_struct` should only be called to fill plain data structs. It is not endian safe.
2831
pub unsafe fn read_struct<T: Copy, F: Read>(f: &mut F, out: &mut T) -> Result<()> {
2932
let out_slice = std::slice::from_raw_parts_mut(out as *mut T as *mut u8, mem::size_of::<T>());
3033
f.read_exact(out_slice).map_err(|_| Error::ReadStruct)?;
@@ -33,13 +36,16 @@ pub unsafe fn read_struct<T: Copy, F: Read>(f: &mut F, out: &mut T) -> Result<()
3336

3437
/// Reads an array of structs from an input buffer. Returns a Vec of structs initialized with data
3538
/// from the specified input.
36-
/// This is unsafe because the structs are initialized to unverified data read from the input.
37-
/// `read_struct_slice` should only be called for plain old data structs. It is not endian safe.
3839
///
3940
/// # Arguments
4041
///
4142
/// * `f` - The input to read from. Often this is a file.
4243
/// * `len` - The number of structs to fill with data read from `f`.
44+
///
45+
/// # Safety
46+
///
47+
/// This is unsafe because the struct is initialized to unverified data read from the input.
48+
/// `read_struct_slice` should only be called to fill plain data structs. It is not endian safe.
4349
#[cfg(feature = "elf")]
4450
pub unsafe fn read_struct_slice<T: Copy, F: Read>(f: &mut F, len: usize) -> Result<Vec<T>> {
4551
let mut out: Vec<T> = Vec::with_capacity(len);

0 commit comments

Comments
 (0)