From c322d1d12a9a949233dbfc411d9426537f99db6d Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Sat, 15 Oct 2022 11:40:31 +0100 Subject: [PATCH] kata-ctl: arch: Improve check call Rework the architecture-specific `check()` call by moving all the conditional logic out of the function. Fixes: #5402. Signed-off-by: James O. D. Hunt --- src/tools/kata-ctl/src/arch/mod.rs | 38 +++++++++++++----------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/src/tools/kata-ctl/src/arch/mod.rs b/src/tools/kata-ctl/src/arch/mod.rs index e72bcc4537..b85811a0ca 100644 --- a/src/tools/kata-ctl/src/arch/mod.rs +++ b/src/tools/kata-ctl/src/arch/mod.rs @@ -7,36 +7,32 @@ use anyhow::Result; #[cfg(target_arch = "aarch64")] pub mod aarch64; +#[cfg(target_arch = "aarch64")] +pub use aarch64 as arch_specific; #[cfg(target_arch = "powerpc64le")] pub mod powerpc64le; +#[cfg(target_arch = "powerpc64le")] +pub use powerpc64le as arch_specific; #[cfg(target_arch = "s390x")] pub mod s390x; +#[cfg(target_arch = "s390x")] +pub use s390x as arch_specific; #[cfg(target_arch = "x86_64")] pub mod x86_64; +#[cfg(target_arch = "x86_64")] +pub use x86_64 as arch_specific; + +#[cfg(not(any( + target_arch = "aarch64", + target_arch = "powerpc64le", + target_arch = "s390x", + target_arch = "x86_64" +)))] +compile_error!("unknown architecture"); pub fn check() -> Result<()> { - #[cfg(target_arch = "aarch64")] - let result = aarch64::check(); - - #[cfg(target_arch = "powerpc64le")] - let result = powerpc64le::check(); - - #[cfg(target_arch = "s390x")] - let result = s390x::check(); - - #[cfg(target_arch = "x86_64")] - let result = x86_64::check(); - - #[cfg(not(any( - target_arch = "aarch64", - target_arch = "powerpc64le", - target_arch = "s390x", - target_arch = "x86_64" - )))] - compile_error!("unknown architecture"); - - result + arch_specific::check() }