Skip to content

Commit d23d7ba

Browse files
Merge branch 'fix-clippy-lints'
2 parents 8dcbb39 + 406405f commit d23d7ba

File tree

6 files changed

+26
-46
lines changed

6 files changed

+26
-46
lines changed

Cargo.lock

+4-29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mullvad-daemon/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ simple-signal = "1.1"
6262
talpid-dbus = { path = "../talpid-dbus" }
6363

6464
[target.'cfg(target_os="macos")'.dependencies]
65-
objc = { version = "0.2.7", features = ["exception", "verify_message"] }
65+
objc2 = { version = "0.5.2", features = ["exception"] }
6666

6767
[target.'cfg(windows)'.dependencies]
6868
ctrlc = "3.0"

mullvad-daemon/src/macos_launch_daemon.rs

+17-11
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
//! must be checked so that the user can be directed to approve the launch
66
//! daemon in the system settings.
77
8-
use objc::{class, msg_send, sel, sel_impl};
8+
use libc::c_longlong;
9+
use objc2::{class, msg_send, runtime::AnyObject, Encode, Encoding, RefEncode};
910
use std::ffi::CStr;
1011

11-
type Id = *mut objc::runtime::Object;
12+
type Id = *mut AnyObject;
1213

1314
// Framework that contains `SMAppService`.
1415
#[link(name = "ServiceManagement", kind = "framework")]
@@ -18,18 +19,23 @@ extern "C" {}
1819
#[repr(C)]
1920
#[derive(Debug)]
2021
struct NSOperatingSystemVersion {
21-
major_version: libc::c_longlong,
22-
minor_version: libc::c_longlong,
23-
patch_version: libc::c_longlong,
22+
major_version: c_longlong,
23+
minor_version: c_longlong,
24+
patch_version: c_longlong,
2425
}
2526

26-
/// Implement Objective-C type encoding for the struct. Allows the `objc` crate
27+
/// Implement Objective-C type encoding for the struct. Allows the `objc2` crate
2728
/// to perform function signature matching before performing calls into the Objective-C
28-
/// runtime. This is needed to be able to enable the `verify_message` feature on `objc`.
29-
unsafe impl objc::Encode for NSOperatingSystemVersion {
30-
fn encode() -> objc::Encoding {
31-
unsafe { objc::Encoding::from_str("{?=qqq}") }
32-
}
29+
/// runtime.
30+
unsafe impl Encode for NSOperatingSystemVersion {
31+
const ENCODING: Encoding = Encoding::Struct(
32+
"NSOperatingSystemVersion",
33+
&[Encoding::LongLong, Encoding::LongLong, Encoding::LongLong],
34+
);
35+
}
36+
37+
unsafe impl RefEncode for NSOperatingSystemVersion {
38+
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
3339
}
3440

3541
/// Authorization status of the Mullvad daemon.

talpid-core/src/split_tunnel/macos/process.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ mod test {
567567
msg.contains('\n'),
568568
"Message does not contain a newline!! Make sure to add a newline to '{msg}'"
569569
);
570-
let (stdout_read, mut stdout_write) = simplex(msg.as_bytes().len());
570+
let (stdout_read, mut stdout_write) = simplex(msg.len());
571571
// "print" to "stdout" after `duration`.
572572
tokio::spawn(async move {
573573
tokio::time::sleep(lag).await;

talpid-dbus/src/systemd_resolved.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,7 @@ impl SystemdResolved {
208208
let parts = contents.trim().split(' ');
209209
parts
210210
.map(str::parse::<IpAddr>)
211-
.map(|maybe_ip| maybe_ip.map(|addr| addr.is_loopback()).unwrap_or(false))
212-
.any(|is_loopback| is_loopback)
211+
.any(|maybe_ip| maybe_ip.map(|addr| addr.is_loopback()).unwrap_or(false))
213212
})
214213
.unwrap_or(false);
215214

talpid-types/src/net/proxy.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,12 @@ impl SocksAuth {
159159
/// assert!(too_long_username.is_err());
160160
/// ```
161161
pub fn new(username: String, password: String) -> Result<Self, Error> {
162-
if !(1..=255).contains(&password.as_bytes().len()) {
162+
if !(1..=255).contains(&password.len()) {
163163
return Err(Error::InvalidSocksAuthValues(
164164
"Password length should between 1 and 255 bytes",
165165
));
166166
}
167-
if !(1..=255).contains(&username.as_bytes().len()) {
167+
if !(1..=255).contains(&username.len()) {
168168
return Err(Error::InvalidSocksAuthValues(
169169
"Username length should between 1 and 255 bytes",
170170
));

0 commit comments

Comments
 (0)