Skip to content

Commit

Permalink
Fix cargo clippy
Browse files Browse the repository at this point in the history
Signed-off-by: Gris Ge <[email protected]>
  • Loading branch information
cathay4t committed Mar 28, 2024
1 parent de62338 commit 6e4fabd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/create_macvlan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async fn main() -> Result<(), String> {
}
let link_name = &args[1];
let mac: Option<Vec<u8>> = if args.len() == 3 {
let mac_address_arg = (&args[2]).to_string();
let mac_address_arg = args[2].to_string();
let mac_address = MacAddr::from_str(mac_address_arg.as_str())
.map_err(|e| format!("{e}"))?;
Some(mac_address.as_bytes().into())
Expand Down
10 changes: 5 additions & 5 deletions src/link/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn create_get_delete_macvlan() {
const MACVLAN_IFACE_NAME: &str = "mvlan1";
const LOWER_DEVICE_IDX: u32 = 2;
const MACVLAN_MODE: u32 = 4; // bridge
let mac_address = &vec![2u8, 0, 0, 0, 0, 1];
let mac_address = [2u8, 0, 0, 0, 0, 1];

let rt = Runtime::new().unwrap();
let handle = rt.block_on(_create_macvlan(
Expand All @@ -49,7 +49,7 @@ fn create_get_delete_macvlan() {
rt.block_on(_get_iface(&mut handle, MACVLAN_IFACE_NAME.to_owned()));
assert!(msg.is_ok());
assert!(has_nla(
&msg.as_ref().unwrap(),
msg.as_ref().unwrap(),
&LinkAttribute::LinkInfo(vec![
LinkInfo::Kind(InfoKind::MacVlan),
LinkInfo::Data(InfoData::MacVlan(vec![
Expand All @@ -62,15 +62,15 @@ fn create_get_delete_macvlan() {
])
));
assert!(has_nla(
&msg.as_ref().unwrap(),
msg.as_ref().unwrap(),
&LinkAttribute::IfName(MACVLAN_IFACE_NAME.to_string())
));
assert!(has_nla(
&msg.as_ref().unwrap(),
msg.as_ref().unwrap(),
&LinkAttribute::Link(LOWER_DEVICE_IDX)
));
assert!(has_nla(
&msg.as_ref().unwrap(),
msg.as_ref().unwrap(),
&LinkAttribute::Address(mac_address.to_vec())
));

Expand Down
2 changes: 1 addition & 1 deletion src/ns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use nix::{
},
unistd::{fork, ForkResult},
};
use std::{option::Option, os::fd::BorrowedFd, path::Path, process::exit};
use std::{os::fd::BorrowedFd, path::Path, process::exit};

// if "only" smol or smol+tokio were enabled, we use smol because
// it doesn't require an active tokio runtime - just to be sure.
Expand Down
4 changes: 1 addition & 3 deletions src/traffic_control/add_qdisc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ mod test {

use super::*;
use crate::{new_connection, NetworkNamespace, NETNS_PATH, SELF_NS_PATH};
use netlink_packet_route::{
link::LinkMessage, tc::TcAttribute, AddressFamily,
};
use netlink_packet_route::{link::LinkMessage, AddressFamily};

const TEST_NS: &str = "netlink_test_qdisc_ns";
const TEST_DUMMY: &str = "test_dummy";
Expand Down

0 comments on commit 6e4fabd

Please sign in to comment.