diff options
author | 2022-12-24 20:04:11 +0300 | |
---|---|---|
committer | 2022-12-24 20:04:23 +0300 | |
commit | b21a125d25eaaa04ba43a9d4d6d8388c5ec3e720 (patch) | |
tree | 654b79dd7ccb648338eda620e93803271ca46653 | |
parent | 7bab7659c7d08bc3f97a2308a71c74a7d5b93b84 (diff) | |
download | newsboat-b21a125d25eaaa04ba43a9d4d6d8388c5ec3e720.tar.gz newsboat-b21a125d25eaaa04ba43a9d4d6d8388c5ec3e720.tar.zst newsboat-b21a125d25eaaa04ba43a9d4d6d8388c5ec3e720.zip |
Fix unnecessary cast (Clippy warning)
-rw-r--r-- | rust/libnewsboat-ffi/src/utils.rs | 13 | ||||
-rw-r--r-- | rust/regex-rs/src/lib.rs | 4 |
2 files changed, 12 insertions, 5 deletions
diff --git a/rust/libnewsboat-ffi/src/utils.rs b/rust/libnewsboat-ffi/src/utils.rs index 3fa44ef9..4d0740b9 100644 --- a/rust/libnewsboat-ffi/src/utils.rs +++ b/rust/libnewsboat-ffi/src/utils.rs @@ -1,4 +1,4 @@ -use libc::c_char; +use libc::{c_char, c_ulong}; use libnewsboat::utils::{self, *}; use std::ffi::{CStr, CString}; use std::path::{Path, PathBuf}; @@ -103,7 +103,16 @@ mod bridged { } fn get_auth_method(method: &str) -> u64 { - utils::get_auth_method(method) as u64 + let result: c_ulong = utils::get_auth_method(method); + #[cfg(target_pointer_width = "32")] + { + // On 32-bit platforms, upcast + result as u64 + } + #[cfg(target_pointer_width = "64")] + { + result + } } fn run_interactively(command: &str, caller: &str, exit_code: &mut u8) -> bool { diff --git a/rust/regex-rs/src/lib.rs b/rust/regex-rs/src/lib.rs index f6e30edd..50ca9cfe 100644 --- a/rust/regex-rs/src/lib.rs +++ b/rust/regex-rs/src/lib.rs @@ -117,9 +117,7 @@ unsafe fn regex_error_to_str(errcode: libc::c_int, regex: ®ex_t) -> Option<St let errmsg_length = regerror(errcode, regex, ptr::null_mut(), 0); // Allocate the buffer and get the message. - // Casting u64 to usize is safe since the error message is unlikely to hit usize's - // upper bound. - let mut errmsg: Vec<u8> = vec![0; errmsg_length as usize]; + let mut errmsg: Vec<u8> = vec![0; errmsg_length]; // Casting `*mut u8` to `*mut c_char` should be safe since C doesn't really care: // it can store any ASCII symbol in a `char`, disregarding signedness. regerror( |