From 2f514523ddc7b446bcd8fe1c351b2b949f2c7253 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Thu, 23 Jun 2022 08:29:52 +0000 Subject: [PATCH] hypervisor: emulator: use matches! No functional change. Just make the code a bit nicer to read. Signed-off-by: Wei Liu --- .../src/arch/x86/emulator/instructions/mod.rs | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/hypervisor/src/arch/x86/emulator/instructions/mod.rs b/hypervisor/src/arch/x86/emulator/instructions/mod.rs index 516f8714b..ef10df58f 100644 --- a/hypervisor/src/arch/x86/emulator/instructions/mod.rs +++ b/hypervisor/src/arch/x86/emulator/instructions/mod.rs @@ -28,14 +28,11 @@ fn get_op( ))); } - match op_size { - 1 | 2 | 4 | 8 => {} - _ => { - return Err(PlatformError::InvalidOperand(anyhow!( - "Invalid operand size {:?}", - op_size - ))) - } + if !matches!(op_size, 1 | 2 | 4 | 8) { + return Err(PlatformError::InvalidOperand(anyhow!( + "Invalid operand size {:?}", + op_size + ))); } let value = match insn @@ -81,14 +78,11 @@ fn set_op( ))); } - match op_size { - 1 | 2 | 4 | 8 => {} - _ => { - return Err(PlatformError::InvalidOperand(anyhow!( - "Invalid operand size {:?}", - op_size - ))) - } + if !matches!(op_size, 1 | 2 | 4 | 8) { + return Err(PlatformError::InvalidOperand(anyhow!( + "Invalid operand size {:?}", + op_size + ))); } match insn