fix some lints caught by Clippy
Most of these changes are very simple. Among the changes made involve
taking advantage of auto-deref (`(*val).foo()` -> `val.foo()`) and
removing instances where we create a ref and immediately dereference it
(`&*val` -> `val`). There was a pretty neat case in `posix_openpt` where
some pointer verbosity was able to be reduced by using the more modern C
strings rather than the byte strings with an explicit NUL at the end.
Additionally, `exit()` now calls `unreachable!()` at the end. We
previously did `loop {}`, but clippy didn't like this. It can be up for
debate whether we want to make this `unreachable_unchecked` or similar.
There is only one change that might cause any sort of concern, and that
is the change from `.skip_while(!p).next()` -> `.find(p)`. This, like
everything else, was caught in a Clippy lint but I believe it deserves
some explanation because it isn't immediately obvious. Info about the
lint is here: https://rust-lang.github.io/rust-clippy/rust-1.89.0/index.html#skip_while_next
This commit is contained in:
@@ -59,7 +59,7 @@ impl Dns {
|
||||
}
|
||||
|
||||
pub fn parse(data: &[u8]) -> Result<Self, String> {
|
||||
let name_ind = 0b1100_0000;
|
||||
let name_ind = 0b1100_0000u8;
|
||||
let mut i = 0;
|
||||
|
||||
macro_rules! pop_u8 {
|
||||
@@ -106,7 +106,7 @@ impl Dns {
|
||||
let name_len = pop_u8!();
|
||||
if name_len & name_ind == name_ind {
|
||||
i -= 1;
|
||||
i = (pop_n16!() - ((name_ind as u16) << 8)) as usize;
|
||||
i = (pop_n16!() - ((u16::from(name_ind)) << 8)) as usize;
|
||||
continue;
|
||||
}
|
||||
if name_len == 0 {
|
||||
|
||||
@@ -63,7 +63,7 @@ pub fn lookup_host(host: &str) -> Result<LookupHost, c_int> {
|
||||
let packet_data_len = packet_data.len();
|
||||
|
||||
let packet_data_box = packet_data.into_boxed_slice();
|
||||
let packet_data_ptr = Box::into_raw(packet_data_box) as *mut _ as *mut c_void;
|
||||
let packet_data_ptr = Box::into_raw(packet_data_box).cast::<c_void>();
|
||||
|
||||
let dest = sockaddr_in {
|
||||
sin_family: AF_INET as u16,
|
||||
@@ -164,7 +164,7 @@ pub fn lookup_addr(addr: in_addr) -> Result<Vec<Vec<u8>>, c_int> {
|
||||
let packet_data = packet.compile();
|
||||
let packet_data_len = packet_data.len();
|
||||
let packet_data_box = packet_data.into_boxed_slice();
|
||||
let packet_data_ptr = Box::into_raw(packet_data_box) as *mut _ as *mut c_void;
|
||||
let packet_data_ptr = Box::into_raw(packet_data_box).cast::<c_void>();
|
||||
|
||||
let dest = sockaddr_in {
|
||||
sin_family: AF_INET as u16,
|
||||
|
||||
Reference in New Issue
Block a user