From 1dc4eb0d201f4cfbb22206cd9e53dffd3d8d51e3 Mon Sep 17 00:00:00 2001
From: zhouli57 <zhouli57@huawei.com>
Date: Mon, 14 Mar 2022 14:56:32 +0800
Subject: [PATCH] machine: clear some warnings

Signed-off-by: zhouli57 <zhouli57@huawei.com>
---
 cpu/src/aarch64/core_regs.rs               | 12 ++++++------
 devices/src/legacy/rtc.rs                  |  2 +-
 machine/src/micro_vm/syscall.rs            |  1 +
 machine/src/standard_vm/aarch64/syscall.rs |  1 +
 machine/src/standard_vm/x86_64/syscall.rs  |  1 +
 5 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/cpu/src/aarch64/core_regs.rs b/cpu/src/aarch64/core_regs.rs
index ba3b400..bc46f69 100644
--- a/cpu/src/aarch64/core_regs.rs
+++ b/cpu/src/aarch64/core_regs.rs
@@ -194,15 +194,15 @@ pub fn get_core_regs(vcpu_fd: &VcpuFd) -> Result<kvm_regs> {
 
     for i in 0..KVM_NR_FP_REGS as usize {
         let register_value_vec =
-            get_one_reg_vec(&vcpu_fd, Arm64CoreRegs::UserFPSIMDStateVregs(i).into())?;
+            get_one_reg_vec(vcpu_fd, Arm64CoreRegs::UserFPSIMDStateVregs(i).into())?;
         core_regs.fp_regs.vregs[i][0] = *u64::from_bytes(&register_value_vec[0..8]).unwrap();
         core_regs.fp_regs.vregs[i][1] = *u64::from_bytes(&register_value_vec[8..16]).unwrap();
     }
 
-    let register_value_vec = get_one_reg_vec(&vcpu_fd, Arm64CoreRegs::UserFPSIMDStateFpsr.into())?;
+    let register_value_vec = get_one_reg_vec(vcpu_fd, Arm64CoreRegs::UserFPSIMDStateFpsr.into())?;
     core_regs.fp_regs.fpsr = *u32::from_bytes(&register_value_vec[0..4]).unwrap();
 
-    let register_value_vec = get_one_reg_vec(&vcpu_fd, Arm64CoreRegs::UserFPSIMDStateFpcr.into())?;
+    let register_value_vec = get_one_reg_vec(vcpu_fd, Arm64CoreRegs::UserFPSIMDStateFpcr.into())?;
     core_regs.fp_regs.fpcr = *u32::from_bytes(&register_value_vec[0..4]).unwrap();
 
     Ok(core_regs)
@@ -239,20 +239,20 @@ pub fn set_core_regs(vcpu_fd: &VcpuFd, core_regs: kvm_regs) -> Result<()> {
         data.append(&mut core_regs.fp_regs.vregs[i][0].as_bytes().to_vec());
         data.append(&mut core_regs.fp_regs.vregs[i][1].as_bytes().to_vec());
         set_one_reg_vec(
-            &vcpu_fd,
+            vcpu_fd,
             Arm64CoreRegs::UserFPSIMDStateVregs(i).into(),
             &data,
         )?;
     }
 
     set_one_reg_vec(
-        &vcpu_fd,
+        vcpu_fd,
         Arm64CoreRegs::UserFPSIMDStateFpsr.into(),
         &core_regs.fp_regs.fpsr.as_bytes().to_vec(),
     )?;
 
     set_one_reg_vec(
-        &vcpu_fd,
+        vcpu_fd,
         Arm64CoreRegs::UserFPSIMDStateFpcr.into(),
         &core_regs.fp_regs.fpcr.as_bytes().to_vec(),
     )?;
diff --git a/devices/src/legacy/rtc.rs b/devices/src/legacy/rtc.rs
index 0ec8658..a549bfb 100644
--- a/devices/src/legacy/rtc.rs
+++ b/devices/src/legacy/rtc.rs
@@ -59,7 +59,7 @@ const CMOS_MEM_BELOW_4GB: (u8, u8) = (0x34, 0x35);
 const CMOS_MEM_ABOVE_4GB: (u8, u8, u8) = (0x5B, 0x5C, 0x5D);
 
 fn get_utc_time() -> libc::tm {
-    let time_val: libc::time_t = 0_i64;
+    let time_val = 0_i64;
 
     // Safe because `libc::time` only get time.
     unsafe { libc::time(time_val as *mut i64) };
diff --git a/machine/src/micro_vm/syscall.rs b/machine/src/micro_vm/syscall.rs
index 5e9c6d8..81637a3 100644
--- a/machine/src/micro_vm/syscall.rs
+++ b/machine/src/micro_vm/syscall.rs
@@ -22,6 +22,7 @@ const FUTEX_CMP_REQUEUE: u32 = 4;
 const FUTEX_WAKE_OP: u32 = 5;
 const FUTEX_WAIT_BITSET: u32 = 9;
 const FUTEX_PRIVATE_FLAG: u32 = 128;
+#[cfg(target_env = "gnu")]
 const FUTEX_CLOCK_REALTIME: u32 = 256;
 const FUTEX_WAIT_PRIVATE: u32 = FUTEX_WAIT | FUTEX_PRIVATE_FLAG;
 const FUTEX_WAKE_PRIVATE: u32 = FUTEX_WAKE | FUTEX_PRIVATE_FLAG;
diff --git a/machine/src/standard_vm/aarch64/syscall.rs b/machine/src/standard_vm/aarch64/syscall.rs
index ed3140e..f44c5f7 100644
--- a/machine/src/standard_vm/aarch64/syscall.rs
+++ b/machine/src/standard_vm/aarch64/syscall.rs
@@ -28,6 +28,7 @@ const FUTEX_CMP_REQUEUE: u32 = 4;
 const FUTEX_WAKE_OP: u32 = 5;
 const FUTEX_WAIT_BITSET: u32 = 9;
 const FUTEX_PRIVATE_FLAG: u32 = 128;
+#[cfg(target_env = "gnu")]
 const FUTEX_CLOCK_REALTIME: u32 = 256;
 const FUTEX_WAIT_PRIVATE: u32 = FUTEX_WAIT | FUTEX_PRIVATE_FLAG;
 const FUTEX_WAKE_PRIVATE: u32 = FUTEX_WAKE | FUTEX_PRIVATE_FLAG;
diff --git a/machine/src/standard_vm/x86_64/syscall.rs b/machine/src/standard_vm/x86_64/syscall.rs
index 6f8e10d..1fe711b 100644
--- a/machine/src/standard_vm/x86_64/syscall.rs
+++ b/machine/src/standard_vm/x86_64/syscall.rs
@@ -28,6 +28,7 @@ const FUTEX_CMP_REQUEUE: u32 = 4;
 const FUTEX_WAKE_OP: u32 = 5;
 const FUTEX_WAIT_BITSET: u32 = 9;
 const FUTEX_PRIVATE_FLAG: u32 = 128;
+#[cfg(target_env = "gnu")]
 const FUTEX_CLOCK_REALTIME: u32 = 256;
 const FUTEX_WAIT_PRIVATE: u32 = FUTEX_WAIT | FUTEX_PRIVATE_FLAG;
 const FUTEX_WAKE_PRIVATE: u32 = FUTEX_WAKE | FUTEX_PRIVATE_FLAG;
-- 
2.17.1

