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 <james.o.hunt@intel.com>
This commit is contained in:
James O. D. Hunt 2022-10-15 11:40:31 +01:00
parent ff8bfdfe3b
commit c322d1d12a

View File

@ -7,36 +7,32 @@ use anyhow::Result;
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
pub mod aarch64; pub mod aarch64;
#[cfg(target_arch = "aarch64")]
pub use aarch64 as arch_specific;
#[cfg(target_arch = "powerpc64le")] #[cfg(target_arch = "powerpc64le")]
pub mod powerpc64le; pub mod powerpc64le;
#[cfg(target_arch = "powerpc64le")]
pub use powerpc64le as arch_specific;
#[cfg(target_arch = "s390x")] #[cfg(target_arch = "s390x")]
pub mod s390x; pub mod s390x;
#[cfg(target_arch = "s390x")]
pub use s390x as arch_specific;
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
pub mod 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<()> { pub fn check() -> Result<()> {
#[cfg(target_arch = "aarch64")] arch_specific::check()
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
} }