From 3baebc1af0a47fcb0f81463b1e0240bbda1433ac Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 7 Jan 2022 10:20:13 +0000 Subject: [PATCH] arch: x86_64: Fix clippy (needless_late_init) issue warning: unneeded late initalization --> arch/src/x86_64/mod.rs:318:17 | 318 | let reg_val: u32; | ^^^^^^^^^^^^^^^^^ | = note: `#[warn(clippy::needless_late_init)]` on by default = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init help: declare `reg_val` here | 319 | let reg_val: u32 = match reg { | ++++++++++++++++++ help: remove the assignments from the `match` arms | 321 ~ entry.eax 322 | } 323 | CpuidReg::EBX => { 324 ~ entry.ebx 325 | } 326 | CpuidReg::ECX => { ... help: add a semicolon after the `match` expression | 332 | }; | + warning: unneeded late initalization --> arch/src/x86_64/mod.rs:525:13 | 525 | let entry_compatible; | ^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init help: declare `entry_compatible` here | 526 | let entry_compatible = match entry.compatible_check { | ++++++++++++++++++++++ help: remove the assignments from the `match` arms | 530 ~ src_vm_feature_bits_only == 0 531 | } 532 | CpuidCompatibleCheck::Equal => { 533 ~ src_vm_feature == dest_vm_feature 534 | } 535 | CpuidCompatibleCheck::NumNotGreater => { Signed-off-by: Rob Bradford --- arch/src/x86_64/mod.rs | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/arch/src/x86_64/mod.rs b/arch/src/x86_64/mod.rs index 9f4244777..564dce1cf 100644 --- a/arch/src/x86_64/mod.rs +++ b/arch/src/x86_64/mod.rs @@ -315,21 +315,12 @@ impl CpuidPatch { for entry in entries.iter() { if entry.function == function && entry.index == index { - let reg_val: u32; - match reg { - CpuidReg::EAX => { - reg_val = entry.eax; - } - CpuidReg::EBX => { - reg_val = entry.ebx; - } - CpuidReg::ECX => { - reg_val = entry.ecx; - } - CpuidReg::EDX => { - reg_val = entry.edx; - } - } + let reg_val = match reg { + CpuidReg::EAX => entry.eax, + CpuidReg::EBX => entry.ebx, + CpuidReg::ECX => entry.ecx, + CpuidReg::EDX => entry.edx, + }; return (reg_val & mask) == mask; } @@ -522,19 +513,14 @@ impl CpuidFeatureEntry { .enumerate() { let entry = &feature_entry_list[i]; - let entry_compatible; - match entry.compatible_check { + let entry_compatible = match entry.compatible_check { CpuidCompatibleCheck::BitwiseSubset => { let different_feature_bits = src_vm_feature ^ dest_vm_feature; let src_vm_feature_bits_only = different_feature_bits & src_vm_feature; - entry_compatible = src_vm_feature_bits_only == 0; - } - CpuidCompatibleCheck::Equal => { - entry_compatible = src_vm_feature == dest_vm_feature; - } - CpuidCompatibleCheck::NumNotGreater => { - entry_compatible = src_vm_feature <= dest_vm_feature; + src_vm_feature_bits_only == 0 } + CpuidCompatibleCheck::Equal => src_vm_feature == dest_vm_feature, + CpuidCompatibleCheck::NumNotGreater => src_vm_feature <= dest_vm_feature, }; if !entry_compatible { error!(