From 9dde814b99e7e070e64e9cddb1c48fb45f6a7851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20L=C3=B6nnhager?= Date: Tue, 26 Nov 2024 09:22:04 +0100 Subject: [PATCH] Fix clippy lints in mullvad-api --- mullvad-api/src/ffi/device.rs | 2 +- mullvad-api/src/ffi/mod.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mullvad-api/src/ffi/device.rs b/mullvad-api/src/ffi/device.rs index 82ba5f59ccf1..87fdfcf98b57 100644 --- a/mullvad-api/src/ffi/device.rs +++ b/mullvad-api/src/ffi/device.rs @@ -90,7 +90,7 @@ pub extern "C" fn mullvad_api_device_iter_next( // SAFETY: Assuming device pointer is valid unsafe { ptr::write(device_ptr, device.into()) } - return true; + true } #[no_mangle] diff --git a/mullvad-api/src/ffi/mod.rs b/mullvad-api/src/ffi/mod.rs index 82f96be2d898..507b2b2f1cfe 100644 --- a/mullvad-api/src/ffi/mod.rs +++ b/mullvad-api/src/ffi/mod.rs @@ -234,7 +234,7 @@ impl FfiClient { /// * `hostname`: pointer to a null-terminated UTF-8 string representing the hostname that will be /// used for TLS validation. #[no_mangle] -pub extern "C" fn mullvad_api_client_initialize( +pub unsafe extern "C" fn mullvad_api_client_initialize( client_ptr: *mut MullvadApiClient, api_address_ptr: *const libc::c_char, hostname: *const libc::c_char, @@ -258,7 +258,7 @@ pub extern "C" fn mullvad_api_client_initialize( /// * `account_str_ptr`: pointer to nul-terminated UTF-8 string containing the account number of the /// account that will have all of it's devices removed. #[no_mangle] -pub extern "C" fn mullvad_api_remove_all_devices( +pub unsafe extern "C" fn mullvad_api_remove_all_devices( client_ptr: MullvadApiClient, account_ptr: *const libc::c_char, ) -> MullvadApiError { @@ -280,7 +280,7 @@ pub extern "C" fn mullvad_api_remove_all_devices( /// * `expiry_unix_timestamp`: a pointer to a signed 64 bit integer. If this function returns no /// error, the expiry timestamp will be written to this pointer. #[no_mangle] -pub extern "C" fn mullvad_api_get_expiry( +pub unsafe extern "C" fn mullvad_api_get_expiry( client_ptr: MullvadApiClient, account_str_ptr: *const libc::c_char, expiry_unix_timestamp: *mut i64, @@ -307,7 +307,7 @@ pub extern "C" fn mullvad_api_get_expiry( /// doesn't return an error, the pointer will be initialized with a valid instance of /// `device::MullvadApiDeviceIterator`, which can be used to iterate through the devices. #[no_mangle] -pub extern "C" fn mullvad_api_list_devices( +pub unsafe extern "C" fn mullvad_api_list_devices( client_ptr: MullvadApiClient, account_str_ptr: *const libc::c_char, device_iter_ptr: *mut device::MullvadApiDeviceIterator, @@ -336,7 +336,7 @@ pub extern "C" fn mullvad_api_list_devices( /// * `new_device_ptr`: a pointer to enough memory to allocate a `MullvadApiDevice`. If this /// function doesn't return an error, it will be initialized. #[no_mangle] -pub extern "C" fn mullvad_api_add_device( +pub unsafe extern "C" fn mullvad_api_add_device( client_ptr: MullvadApiClient, account_str_ptr: *const libc::c_char, public_key_ptr: *const u8, @@ -366,7 +366,7 @@ pub extern "C" fn mullvad_api_add_device( /// account number will be written to this pointer. It must be freed via /// `mullvad_api_cstring_drop`. #[no_mangle] -pub extern "C" fn mullvad_api_create_account( +pub unsafe extern "C" fn mullvad_api_create_account( client_ptr: MullvadApiClient, account_str_ptr: *mut *const libc::c_char, ) -> MullvadApiError { @@ -394,7 +394,7 @@ pub extern "C" fn mullvad_api_create_account( /// /// * `account_str_ptr`: A null-terminated string representing the account to be deleted. #[no_mangle] -pub extern "C" fn mullvad_api_delete_account( +pub unsafe extern "C" fn mullvad_api_delete_account( client_ptr: MullvadApiClient, account_str_ptr: *const libc::c_char, ) -> MullvadApiError { @@ -412,7 +412,7 @@ pub extern "C" fn mullvad_api_client_drop(client: MullvadApiClient) { /// Deallocates a CString returned by the Mullvad API client. #[no_mangle] -pub extern "C" fn mullvad_api_cstring_drop(cstr_ptr: *mut libc::c_char) { +pub unsafe extern "C" fn mullvad_api_cstring_drop(cstr_ptr: *mut libc::c_char) { let _ = unsafe { CString::from_raw(cstr_ptr) }; }