Skip to content

Commit

Permalink
Rust: fix some new clippy warnings in 1.53
Browse files Browse the repository at this point in the history
  • Loading branch information
chrissie-c authored and fabbione committed Jul 23, 2021
1 parent 75a8c95 commit c076d95
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
14 changes: 7 additions & 7 deletions libknet/bindings/rust/tests/src/bin/knet-test.rs
Expand Up @@ -101,7 +101,7 @@ fn setup_node(our_hostid: &knet::HostId, other_hostid: &knet::HostId, name: &str
let (log_sender, log_receiver) = channel::<knet::LogMsg>();
spawn(move || logging_thread(log_receiver));

let knet_handle = match knet::handle_new(&our_hostid, Some(log_sender),
let knet_handle = match knet::handle_new(our_hostid, Some(log_sender),
knet::LogLevel::Debug, knet::HandleFlags::NONE) {
Ok(h) => h,
Err(e) => {
Expand All @@ -115,11 +115,11 @@ fn setup_node(our_hostid: &knet::HostId, other_hostid: &knet::HostId, name: &str
set_plugin_path(knet_handle);
}

if let Err(e) = knet::host_add(knet_handle, &other_hostid) {
if let Err(e) = knet::host_add(knet_handle, other_hostid) {
println!("Error from host_add: {}", e);
return Err(e);
}
if let Err(e) = knet::host_set_name(knet_handle, &other_hostid, name) {
if let Err(e) = knet::host_set_name(knet_handle, other_hostid, name) {
println!("Error from host_set_name: {}", e);
return Err(e);
}
Expand Down Expand Up @@ -250,18 +250,18 @@ fn configure_link(knet_handle: knet::Handle, our_hostid: &knet::HostId, other_ho
return Err(e);
}

if let Err(e) = knet::link_set_enable(knet_handle, &other_hostid, 0, true) {
if let Err(e) = knet::link_set_enable(knet_handle, other_hostid, 0, true) {
println!("Error from set_link_enable(true): {}", e);
return Err(e);
}

if let Err(e) = knet::link_set_ping_timers(knet_handle, &other_hostid, 0,
if let Err(e) = knet::link_set_ping_timers(knet_handle, other_hostid, 0,
500, 1000, 1024) {
println!("Error from set_link_ping_timers: {}", e);
return Err(e);
}

match knet::link_get_ping_timers(knet_handle, &other_hostid, 0) {
match knet::link_get_ping_timers(knet_handle, other_hostid, 0) {
Ok((a,b,c)) => {
if a != 500 || b != 1000 || c != 1024 {
println!("get_link_ping_timers returned wrong values {}, {},{} (s/b 500,1000,1024)",
Expand Down Expand Up @@ -677,7 +677,7 @@ fn test_metadata_calls(handle: knet::Handle, host: &knet::HostId) -> Result<()>
return Err(e);
}

match knet::handle_get_onwire_ver(handle, &host) {
match knet::handle_get_onwire_ver(handle, host) {
Ok((min, max, ver)) => {
println!("get_onwire_ver: Got onwire ver: {}/{}/{}", min, max, ver);
},
Expand Down
16 changes: 8 additions & 8 deletions libnozzle/bindings/rust/src/nozzle_bindings.rs
Expand Up @@ -31,8 +31,8 @@ pub fn open(devname: &mut String, updownpath: &str) -> Result<Handle>
let mut c_updownpath: [c_char; libc::PATH_MAX as usize] = [0; libc::PATH_MAX as usize];
let c_devname_size = IFNAMSZ;

crate::string_to_bytes(&devname, &mut c_devname)?;
crate::string_to_bytes(&updownpath, &mut c_updownpath)?;
crate::string_to_bytes(devname, &mut c_devname)?;
crate::string_to_bytes(updownpath, &mut c_updownpath)?;

let res = unsafe {
ffi::nozzle_open(c_devname.as_mut_ptr(), c_devname_size, c_updownpath.as_ptr())
Expand Down Expand Up @@ -140,8 +140,8 @@ pub fn add_ip(handle: Handle, ipaddr: &str, prefix: &str) -> Result<()>
let mut c_ipaddr: [c_char; IPADDR_CHAR_MAX] = [0; IPADDR_CHAR_MAX];
let mut c_prefix: [c_char; PREFIX_CHAR_MAX] = [0; PREFIX_CHAR_MAX];

crate::string_to_bytes(&ipaddr, &mut c_ipaddr)?;
crate::string_to_bytes(&prefix, &mut c_prefix)?;
crate::string_to_bytes(ipaddr, &mut c_ipaddr)?;
crate::string_to_bytes(prefix, &mut c_prefix)?;
let res = unsafe {
ffi::nozzle_add_ip(handle.nozzle_handle, c_ipaddr.as_ptr(), c_prefix.as_ptr())
};
Expand All @@ -159,8 +159,8 @@ pub fn del_ip(handle: Handle, ipaddr: &str, prefix: &str) -> Result<()>
let mut c_ipaddr: [c_char; IPADDR_CHAR_MAX] = [0; IPADDR_CHAR_MAX];
let mut c_prefix: [c_char; PREFIX_CHAR_MAX] = [0; PREFIX_CHAR_MAX];

crate::string_to_bytes(&ipaddr, &mut c_ipaddr)?;
crate::string_to_bytes(&prefix, &mut c_prefix)?;
crate::string_to_bytes(ipaddr, &mut c_ipaddr)?;
crate::string_to_bytes(prefix, &mut c_prefix)?;
let res = unsafe {
ffi::nozzle_del_ip(handle.nozzle_handle, c_ipaddr.as_ptr(), c_prefix.as_ptr())
};
Expand Down Expand Up @@ -301,7 +301,7 @@ pub fn get_mac(handle: Handle) -> Result<String>
pub fn set_mac(handle: Handle, ether_addr: &str) -> Result<()>
{
let mut c_mac: [c_char; 24_usize] = [0; 24_usize]; // Needs to be 8byte aligned
crate::string_to_bytes(&ether_addr, &mut c_mac)?;
crate::string_to_bytes(ether_addr, &mut c_mac)?;
let res = unsafe {
ffi::nozzle_set_mac(handle.nozzle_handle, c_mac.as_ptr())
};
Expand Down Expand Up @@ -329,7 +329,7 @@ pub fn reset_mac(handle: Handle) -> Result<()>
pub fn get_handle_by_name(devname: &str) -> Result<Handle>
{
let mut c_devname: [c_char; IFNAMSZ] = [0; IFNAMSZ];
crate::string_to_bytes(&devname, &mut c_devname)?;
crate::string_to_bytes(devname, &mut c_devname)?;
let res = unsafe {
ffi::nozzle_get_handle_by_name(c_devname.as_ptr())
};
Expand Down
14 changes: 7 additions & 7 deletions libnozzle/bindings/rust/tests/src/bin/nozzle-test.rs
Expand Up @@ -37,7 +37,7 @@ fn main() -> Result<()>

// Let the OS generate a tap name
let mut nozzle_name = String::from("");
let handle = match nozzle::open(&mut nozzle_name, &tmp_dir) {
let handle = match nozzle::open(&mut nozzle_name, tmp_dir) {
Ok(h) => {
println!("Opened device {}", nozzle_name);
h
Expand Down Expand Up @@ -65,20 +65,20 @@ fn main() -> Result<()>
};

// Play with APIs
if let Err(e) = nozzle::add_ip(handle, &"192.160.100.1", &"24") {
if let Err(e) = nozzle::add_ip(handle, "192.160.100.1", "24") {
println!("Error from add_ip: {}", e);
return Err(e);
}
if let Err(e) = nozzle::add_ip(handle, &"192.160.100.2", &"24") {
if let Err(e) = nozzle::add_ip(handle, "192.160.100.2", "24") {
println!("Error from add_ip2: {}", e);
return Err(e);
}
if let Err(e) = nozzle::add_ip(handle, &"192.160.100.3", &"24") {
if let Err(e) = nozzle::add_ip(handle, "192.160.100.3", "24") {
println!("Error from add_ip3: {}", e);
return Err(e);
}

if let Err(e) = nozzle::set_mac(handle, &"AA:00:04:00:22:01") {
if let Err(e) = nozzle::set_mac(handle, "AA:00:04:00:22:01") {
println!("Error from set_mac: {}", e);
return Err(e);
}
Expand Down Expand Up @@ -131,7 +131,7 @@ fn main() -> Result<()>

// Tidy up after ourself - remove the up.d/tapX file
fs::remove_file(&up_filename)?;
fs::remove_dir(&"up.d")?;
fs::remove_dir("up.d")?;

match nozzle::get_ips(handle) {
Ok(ips) => {
Expand Down Expand Up @@ -194,7 +194,7 @@ fn main() -> Result<()>
// Wait a little while in case user wants to check with 'ip' command
thread::sleep(time::Duration::from_millis(1000));

if let Err(e) = nozzle::del_ip(handle, &"192.160.100.3", &"24") {
if let Err(e) = nozzle::del_ip(handle, "192.160.100.3", "24") {
println!("Error from del_ip: {}", e);
return Err(e);
}
Expand Down

0 comments on commit c076d95

Please sign in to comment.