diff --git a/aya/src/lib.rs b/aya/src/lib.rs index ba57bfd3..ad88af0c 100644 --- a/aya/src/lib.rs +++ b/aya/src/lib.rs @@ -39,6 +39,7 @@ #![cfg_attr(docsrs, feature(doc_cfg))] #![deny( clippy::all, + clippy::cast_lossless, clippy::use_self, absolute_paths_not_starting_with_crate, deprecated_in_future, diff --git a/aya/src/sys/netlink.rs b/aya/src/sys/netlink.rs index 02ae5ee7..85ef1bed 100644 --- a/aya/src/sys/netlink.rs +++ b/aya/src/sys/netlink.rs @@ -174,7 +174,10 @@ pub(crate) unsafe fn netlink_qdisc_attach( req.tc_info.tcm_handle = handle; // auto-assigned, if zero req.tc_info.tcm_ifindex = if_index; req.tc_info.tcm_parent = attach_type.tc_parent(); - req.tc_info.tcm_info = tc_handler_make((priority as u32) << 16, htons(ETH_P_ALL as u16) as u32); + req.tc_info.tcm_info = tc_handler_make( + u32::from(priority) << 16, + u32::from(htons(ETH_P_ALL as u16)), + ); let attrs_buf = unsafe { request_attributes(&mut req, nlmsg_len) }; @@ -242,7 +245,10 @@ pub(crate) unsafe fn netlink_qdisc_detach( req.tc_info.tcm_family = AF_UNSPEC as u8; req.tc_info.tcm_handle = handle; // auto-assigned, if zero - req.tc_info.tcm_info = tc_handler_make((priority as u32) << 16, htons(ETH_P_ALL as u16) as u32); + req.tc_info.tcm_info = tc_handler_make( + u32::from(priority) << 16, + u32::from(htons(ETH_P_ALL as u16)), + ); req.tc_info.tcm_parent = attach_type.tc_parent(); req.tc_info.tcm_ifindex = if_index; @@ -452,7 +458,7 @@ impl NetlinkSocket { let message = NetlinkMessage::read(&buf[offset..])?; offset += align_to(message.header.nlmsg_len as usize, NLMSG_ALIGNTO as usize); multipart = message.header.nlmsg_flags & NLM_F_MULTI as u16 != 0; - match message.header.nlmsg_type as i32 { + match i32::from(message.header.nlmsg_type) { NLMSG_ERROR => { let err = message.error.unwrap(); if err.error == 0 { diff --git a/aya/src/sys/perf_event.rs b/aya/src/sys/perf_event.rs index 1cc01a2c..afedefa9 100644 --- a/aya/src/sys/perf_event.rs +++ b/aya/src/sys/perf_event.rs @@ -95,7 +95,7 @@ pub(crate) fn perf_event_open_trace_point( attr.size = mem::size_of::() as u32; attr.type_ = PERF_TYPE_TRACEPOINT as u32; - attr.config = id as u64; + attr.config = u64::from(id); let cpu = if pid.is_some() { -1 } else { 0 }; let pid = pid.unwrap_or(-1);