Skip to content

Commit d3fec79

Browse files
andreeaflorescualexandruag
authored andcommitted
fix clippy checks
Implement From instead of Into as this offers a default Into implementation as well. Use ..Default::default() when initializing structs. Signed-off-by: Andreea Florescu <fandree@amazon.com>
1 parent e321f72 commit d3fec79

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

src/cmdline/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,9 @@ impl Cmdline {
331331
}
332332
}
333333

334-
impl Into<Vec<u8>> for Cmdline {
335-
fn into(self) -> Vec<u8> {
336-
self.line.into_bytes()
334+
impl From<Cmdline> for Vec<u8> {
335+
fn from(cmdline: Cmdline) -> Vec<u8> {
336+
cmdline.line.into_bytes()
337337
}
338338
}
339339

src/loader/x86_64/bzimage/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,11 @@ impl KernelLoader for BzImage {
159159

160160
boot_header.code32_start = mem_offset.raw_value() as u32;
161161

162-
let mut loader_result: KernelLoaderResult = Default::default();
163-
loader_result.setup_header = Some(boot_header);
164-
loader_result.kernel_load = mem_offset;
162+
let mut loader_result = KernelLoaderResult {
163+
setup_header: Some(boot_header),
164+
kernel_load: mem_offset,
165+
..Default::default()
166+
};
165167

166168
// Seek the compressed `vmlinux.bin` and read it to memory.
167169
kernel_image

src/loader/x86_64/elf/mod.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -219,17 +219,17 @@ impl KernelLoader for Elf {
219219
}
220220
}
221221

222-
let mut loader_result: KernelLoaderResult = Default::default();
223-
224-
// Address where the kernel will be loaded.
225-
loader_result.kernel_load = match kernel_offset {
226-
Some(k_offset) => GuestAddress(
227-
k_offset
228-
.raw_value()
229-
.checked_add(ehdr.e_entry as u64)
230-
.ok_or(Error::Overflow)?,
231-
),
232-
None => GuestAddress(ehdr.e_entry as u64),
222+
let mut loader_result = KernelLoaderResult {
223+
kernel_load: match kernel_offset {
224+
Some(k_offset) => GuestAddress(
225+
k_offset
226+
.raw_value()
227+
.checked_add(ehdr.e_entry as u64)
228+
.ok_or(Error::Overflow)?,
229+
),
230+
None => GuestAddress(ehdr.e_entry as u64),
231+
},
232+
..Default::default()
233233
};
234234

235235
kernel_image

0 commit comments

Comments
 (0)