Skip to content

Commit eef5535

Browse files
bjzhjingrbradford
authored andcommitted
lint: Fix clippy lint warnings
Signed-off-by: Cathy Zhang <cathy.zhang@intel.com>
1 parent 02a04c0 commit eef5535

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/cmdline/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl Cmdline {
8484
assert_ne!(capacity, 0);
8585
Cmdline {
8686
line: String::with_capacity(capacity),
87-
capacity: capacity,
87+
capacity,
8888
}
8989
}
9090

src/loader/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ use vm_memory::{Address, Bytes, GuestAddress, GuestMemory, GuestMemoryMmap, Gues
2121
#[allow(non_camel_case_types)]
2222
#[allow(non_snake_case)]
2323
#[allow(non_upper_case_globals)]
24-
#[cfg_attr(feature = "cargo-clippy", allow(clippy))]
24+
#[cfg_attr(feature = "cargo-clippy", allow(clippy::all))]
2525
pub mod bootparam;
2626
#[allow(dead_code)]
2727
#[allow(non_camel_case_types)]
2828
#[allow(non_snake_case)]
2929
#[allow(non_upper_case_globals)]
30-
#[cfg_attr(feature = "cargo-clippy", allow(clippy))]
30+
#[cfg_attr(feature = "cargo-clippy", allow(clippy::all))]
3131
mod elf;
3232
mod struct_util;
3333

@@ -175,10 +175,10 @@ impl KernelLoader for Elf {
175175
// If the program header is backwards, bail.
176176
return Err(Error::InvalidProgramHeaderOffset);
177177
}
178-
if lowest_kernel_start.is_some() {
179-
if (ehdr.e_entry as u64) < lowest_kernel_start.unwrap().raw_value() {
180-
return Err(Error::InvalidEntryAddress);
181-
}
178+
if (lowest_kernel_start.is_some())
179+
&& ((ehdr.e_entry as u64) < lowest_kernel_start.unwrap().raw_value())
180+
{
181+
return Err(Error::InvalidEntryAddress);
182182
}
183183

184184
let mut loader_result: KernelLoaderResult = Default::default();
@@ -271,7 +271,7 @@ impl KernelLoader for BzImage {
271271

272272
// if the HdrS magic number is not found at offset 0x202, the boot protocol version is "old",
273273
// the image type is assumed as zImage, not bzImage.
274-
if boot_header.header != 0x53726448 {
274+
if boot_header.header != 0x5372_6448 {
275275
return Err(Error::InvalidBzImage);
276276
}
277277

@@ -289,15 +289,15 @@ impl KernelLoader for BzImage {
289289

290290
// verify bzImage validation by checking if code32_start, the defaults to the address of
291291
// the kernel is not lower than high memory.
292-
if lowest_kernel_start.is_some() {
293-
if (boot_header.code32_start as u64) < lowest_kernel_start.unwrap().raw_value() {
294-
return Err(Error::InvalidKernelStartAddress);
295-
}
292+
if (lowest_kernel_start.is_some())
293+
&& (u64::from(boot_header.code32_start) < lowest_kernel_start.unwrap().raw_value())
294+
{
295+
return Err(Error::InvalidKernelStartAddress);
296296
}
297297

298298
let mem_offset = match kernel_start {
299299
Some(start) => start,
300-
None => GuestAddress(boot_header.code32_start as u64),
300+
None => GuestAddress(u64::from(boot_header.code32_start)),
301301
};
302302

303303
boot_header.code32_start = mem_offset.raw_value() as u32;

0 commit comments

Comments
 (0)