From 40190504ddc9e6b8c9d0c30a2e075b5444deeae9 Mon Sep 17 00:00:00 2001 From: caesay Date: Mon, 26 Feb 2024 10:55:59 +0000 Subject: [PATCH] Fix unix warnings --- src/Rust/build.rs | 3 ++- src/Rust/src/shared/download.rs | 1 + src/Rust/src/shared/util_linux.rs | 3 ++- src/Rust/src/shared/util_osx.rs | 3 ++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Rust/build.rs b/src/Rust/build.rs index ac3f8526..595ff8e8 100644 --- a/src/Rust/build.rs +++ b/src/Rust/build.rs @@ -1,5 +1,4 @@ #![allow(unused_variables)] -use core::panic; use semver; use std::process::Command; @@ -33,7 +32,9 @@ fn main() { .unwrap(); } +#[cfg(target_os = "windows")] fn link_locksmith() { + use core::panic; let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap(); if arch == "x86_64" { println!("cargo:rustc-link-lib=UpdateLocksmith_x64"); diff --git a/src/Rust/src/shared/download.rs b/src/Rust/src/shared/download.rs index 0a241bdf..a0080e5b 100644 --- a/src/Rust/src/shared/download.rs +++ b/src/Rust/src/shared/download.rs @@ -47,6 +47,7 @@ pub fn download_url_as_string(url: &str) -> Result { } fn get_download_agent() -> Result { + #[allow(unused_mut)] let mut tls_builder = native_tls::TlsConnector::builder(); #[cfg(target_os = "windows")] diff --git a/src/Rust/src/shared/util_linux.rs b/src/Rust/src/shared/util_linux.rs index 8f8264c6..9b1ae94e 100644 --- a/src/Rust/src/shared/util_linux.rs +++ b/src/Rust/src/shared/util_linux.rs @@ -5,10 +5,11 @@ use std::{path::Path, path::PathBuf, process::Command as Process, time::Duration pub fn wait_for_pid_to_exit(pid: u32, ms_to_wait: u32) -> Result<()> { info!("Waiting {}ms for process ({}) to exit.", ms_to_wait, pid); - let mut handle = waitpid_any::WaitHandle::open(pid)?; + let mut handle = waitpid_any::WaitHandle::open(pid.try_into()?)?; let result = handle.wait_timeout(Duration::from_millis(ms_to_wait as u64))?; if result.is_some() { info!("Parent process exited."); + Ok(()) } else { bail!("Parent process timed out."); } diff --git a/src/Rust/src/shared/util_osx.rs b/src/Rust/src/shared/util_osx.rs index cf2e36b3..3d6e3b19 100644 --- a/src/Rust/src/shared/util_osx.rs +++ b/src/Rust/src/shared/util_osx.rs @@ -6,10 +6,11 @@ use std::{path::Path, path::PathBuf, process::Command as Process, time::Duration pub fn wait_for_pid_to_exit(pid: u32, ms_to_wait: u32) -> Result<()> { info!("Waiting {}ms for process ({}) to exit.", ms_to_wait, pid); - let mut handle = waitpid_any::WaitHandle::open(pid)?; + let mut handle = waitpid_any::WaitHandle::open(pid.try_into()?)?; let result = handle.wait_timeout(Duration::from_millis(ms_to_wait as u64))?; if result.is_some() { info!("Parent process exited."); + Ok(()) } else { bail!("Parent process timed out."); }