Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
drunkirishcoder committed Jul 15, 2022
1 parent 7576270 commit a8a0686
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 22 deletions.
2 changes: 1 addition & 1 deletion core/src/ffi/dpdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub(crate) type MempoolPtr = EasyPtr<cffi::rte_mempool>;

impl Clone for MempoolPtr {
fn clone(&self) -> Self {
self.0.clone().into()
self.0.into()
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/net/cidr/v4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl FromStr for Ipv4Cidr {
let address =
Ipv4Addr::from_str(addr).map_err(|e| CidrError::Malformed(e.to_string()))?;

if let Ok(len) = usize::from_str_radix(len_or_netmask, 10) {
if let Ok(len) = len_or_netmask.parse::<usize>() {
Ipv4Cidr::new(address, len)
} else {
let netmask = Ipv4Addr::from_str(len_or_netmask)
Expand Down
2 changes: 1 addition & 1 deletion core/src/net/cidr/v6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl FromStr for Ipv6Cidr {
let address =
Ipv6Addr::from_str(addr).map_err(|e| CidrError::Malformed(e.to_string()))?;

if let Ok(len) = usize::from_str_radix(len_or_netmask, 10) {
if let Ok(len) = len_or_netmask.parse::<usize>() {
Ipv6Cidr::new(address, len)
} else {
let netmask = Ipv6Addr::from_str(len_or_netmask)
Expand Down
2 changes: 1 addition & 1 deletion core/src/packets/icmp/v6/ndp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ impl MutableNdpOptionsIterator<'_> {
#[allow(clippy::should_implement_trait)]
pub fn next(&mut self) -> Result<Option<MutableNdpOption<'_>>> {
if self.mbuf.data_len() > self.offset {
match MutableNdpOption::new(&mut self.mbuf, self.offset) {
match MutableNdpOption::new(self.mbuf, self.offset) {
Ok(option) => {
// advances the offset to the next option
self.offset = option.end_offset();
Expand Down
16 changes: 8 additions & 8 deletions core/src/packets/ip/v4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,8 @@ mod tests {
assert_eq!(5, ipv4.ihl());
assert_eq!(38, ipv4.total_length());
assert_eq!(43849, ipv4.identification());
assert_eq!(true, ipv4.dont_fragment());
assert_eq!(false, ipv4.more_fragments());
assert!(ipv4.dont_fragment());
assert!(!ipv4.more_fragments());
assert_eq!(0, ipv4.fragment_offset());
assert_eq!(0, ipv4.dscp());
assert_eq!(0, ipv4.ecn());
Expand Down Expand Up @@ -661,18 +661,18 @@ mod tests {
ipv4.set_ihl(ipv4.ihl());

// Flags
assert_eq!(true, ipv4.dont_fragment());
assert_eq!(false, ipv4.more_fragments());
assert!(ipv4.dont_fragment());
assert!(!ipv4.more_fragments());

ipv4.unset_dont_fragment();
assert_eq!(false, ipv4.dont_fragment());
assert!(!ipv4.dont_fragment());
ipv4.set_dont_fragment();
assert_eq!(true, ipv4.dont_fragment());
assert!(ipv4.dont_fragment());

ipv4.set_more_fragments();
assert_eq!(true, ipv4.more_fragments());
assert!(ipv4.more_fragments());
ipv4.unset_more_fragments();
assert_eq!(false, ipv4.more_fragments());
assert!(!ipv4.more_fragments());

ipv4.set_fragment_offset(5);
assert_eq!(5, ipv4.fragment_offset());
Expand Down
2 changes: 1 addition & 1 deletion core/src/packets/mbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ impl Drop for Mbuf {
match self.inner {
MbufInner::Original(_) => {
trace!("freeing mbuf@{:p}.", self.raw().buf_addr);
dpdk::pktmbuf_free(self.inner.ptr().clone().into());
dpdk::pktmbuf_free((*self.inner.ptr()).into());
}
MbufInner::Clone(_) => (),
}
Expand Down
10 changes: 4 additions & 6 deletions core/src/runtime/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use capsule_ffi as cffi;
use clap::{clap_app, crate_version};
use regex::Regex;
use serde::Deserialize;
use std::fmt;
use std::fmt::{self, Write};
use std::fs;

/// Runtime configuration settings.
Expand Down Expand Up @@ -130,10 +130,8 @@ impl RuntimeConfig {

/// Extracts the EAL arguments from runtime settings.
pub(crate) fn to_eal_args(&self) -> Vec<String> {
let mut eal_args = vec![];

// adds the app name.
eal_args.push(self.app_name.clone());
let mut eal_args = vec![self.app_name.clone()];

// adds the proc type.
let proc_type = if self.secondary {
Expand Down Expand Up @@ -188,7 +186,7 @@ impl RuntimeConfig {
.map(ToString::to_string)
.collect::<Vec<_>>()
.join(",");
cores.push_str(&format!(",{}@{}", main, self.main_core));
let _ = write!(cores, ",{}@{}", main, self.main_core);
eal_args.push("--lcores".to_owned());
eal_args.push(cores);

Expand Down Expand Up @@ -397,7 +395,7 @@ mod tests {

let config: RuntimeConfig = toml::from_str(CONFIG)?;

assert_eq!(false, config.secondary);
assert!(!config.secondary);
assert_eq!(None, config.app_group);
assert_eq!(None, config.data_dir);
assert_eq!(None, config.dpdk_args);
Expand Down
4 changes: 2 additions & 2 deletions core/src/runtime/pcap_dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ unsafe extern "C" fn rx_callback_fn(
) -> u16 {
let capture = Box::leak(Box::from_raw(user_param as *mut CaptureFile));
let mbufs = slice::from_raw_parts_mut(pkts as *mut MbufPtr, num_pkts as usize);
dump_mbufs(&mut capture.dumper, &mbufs);
dump_mbufs(&mut capture.dumper, mbufs);
num_pkts
}

Expand All @@ -180,7 +180,7 @@ unsafe extern "C" fn tx_callback_fn(
) -> u16 {
let capture = Box::leak(Box::from_raw(user_param as *mut CaptureFile));
let mbufs = slice::from_raw_parts_mut(pkts as *mut MbufPtr, num_pkts as usize);
dump_mbufs(&mut capture.dumper, &mbufs);
dump_mbufs(&mut capture.dumper, mbufs);
num_pkts
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/testils/proptest/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl StrategyMap {
}

fn checked_value<T: Arbitrary + Clone + 'static>(&self, key: &field) -> Option<T> {
if let Some(ref v) = self.0.get(key) {
if let Some(v) = self.0.get(key) {
let v = v
.downcast_ref::<T>()
.unwrap_or_else(|| panic!("value doesn't match type for field '{:?}'", key));
Expand Down

0 comments on commit a8a0686

Please sign in to comment.