diff options
| author | Markus Pettersson <markus.pettersson@mullvad.net> | 2025-01-13 19:52:15 +0100 |
|---|---|---|
| committer | Markus Pettersson <markus.pettersson@mullvad.net> | 2025-01-14 09:19:52 +0100 |
| commit | 406405f4523264f0ba0bebb29acecc4a57265f7c (patch) | |
| tree | 0c2b82b1119c786cbcf490fbcb6ac8723935b568 | |
| parent | 9649e07f76cde5dd0adbe8c4335fd54d35fbcaf6 (diff) | |
| download | mullvadvpn-406405f4523264f0ba0bebb29acecc4a57265f7c.tar.xz mullvadvpn-406405f4523264f0ba0bebb29acecc4a57265f7c.zip | |
Replace `objc` with `objc2` to fix `clippy` warnings
| -rw-r--r-- | Cargo.lock | 33 | ||||
| -rw-r--r-- | mullvad-daemon/Cargo.toml | 2 | ||||
| -rw-r--r-- | mullvad-daemon/src/macos_launch_daemon.rs | 28 |
3 files changed, 22 insertions, 41 deletions
diff --git a/Cargo.lock b/Cargo.lock index 66b17974d1..13e2e0d7e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2274,15 +2274,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9106e1d747ffd48e6be5bb2d97fa706ed25b144fbee4d5c02eae110cd8d6badd" [[package]] -name = "malloc_buf" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" -dependencies = [ - "libc", -] - -[[package]] name = "match_cfg" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2544,7 +2535,7 @@ dependencies = [ "mullvad-types", "mullvad-version", "nix 0.23.2", - "objc", + "objc2", "regex", "serde", "serde_json", @@ -2987,20 +2978,13 @@ dependencies = [ ] [[package]] -name = "objc" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" -dependencies = [ - "malloc_buf", - "objc_exception", -] - -[[package]] name = "objc-sys" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" +dependencies = [ + "cc", +] [[package]] name = "objc2" @@ -3096,15 +3080,6 @@ dependencies = [ ] [[package]] -name = "objc_exception" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad970fb455818ad6cba4c122ad012fae53ae8b4795f86378bce65e4f6bab2ca4" -dependencies = [ - "cc", -] - -[[package]] name = "object" version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/mullvad-daemon/Cargo.toml b/mullvad-daemon/Cargo.toml index d8b1a2b1c6..4c9fce37ec 100644 --- a/mullvad-daemon/Cargo.toml +++ b/mullvad-daemon/Cargo.toml @@ -62,7 +62,7 @@ simple-signal = "1.1" talpid-dbus = { path = "../talpid-dbus" } [target.'cfg(target_os="macos")'.dependencies] -objc = { version = "0.2.7", features = ["exception", "verify_message"] } +objc2 = { version = "0.5.2", features = ["exception"] } [target.'cfg(windows)'.dependencies] ctrlc = "3.0" diff --git a/mullvad-daemon/src/macos_launch_daemon.rs b/mullvad-daemon/src/macos_launch_daemon.rs index 945e61828b..0c9c89080c 100644 --- a/mullvad-daemon/src/macos_launch_daemon.rs +++ b/mullvad-daemon/src/macos_launch_daemon.rs @@ -5,10 +5,11 @@ //! must be checked so that the user can be directed to approve the launch //! daemon in the system settings. -use objc::{class, msg_send, sel, sel_impl}; +use libc::c_longlong; +use objc2::{class, msg_send, runtime::AnyObject, Encode, Encoding, RefEncode}; use std::ffi::CStr; -type Id = *mut objc::runtime::Object; +type Id = *mut AnyObject; // Framework that contains `SMAppService`. #[link(name = "ServiceManagement", kind = "framework")] @@ -18,18 +19,23 @@ extern "C" {} #[repr(C)] #[derive(Debug)] struct NSOperatingSystemVersion { - major_version: libc::c_longlong, - minor_version: libc::c_longlong, - patch_version: libc::c_longlong, + major_version: c_longlong, + minor_version: c_longlong, + patch_version: c_longlong, } -/// Implement Objective-C type encoding for the struct. Allows the `objc` crate +/// Implement Objective-C type encoding for the struct. Allows the `objc2` crate /// to perform function signature matching before performing calls into the Objective-C -/// runtime. This is needed to be able to enable the `verify_message` feature on `objc`. -unsafe impl objc::Encode for NSOperatingSystemVersion { - fn encode() -> objc::Encoding { - unsafe { objc::Encoding::from_str("{?=qqq}") } - } +/// runtime. +unsafe impl Encode for NSOperatingSystemVersion { + const ENCODING: Encoding = Encoding::Struct( + "NSOperatingSystemVersion", + &[Encoding::LongLong, Encoding::LongLong, Encoding::LongLong], + ); +} + +unsafe impl RefEncode for NSOperatingSystemVersion { + const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING); } /// Authorization status of the Mullvad daemon. |
