Skip to content

Commit 1d0a725

Browse files
committed
net: remove unused impl Write for Tap
The only use of this implement was its test. Remove both. Signed-off-by: Patrick Roy <[email protected]>
1 parent 347f877 commit 1d0a725

File tree

1 file changed

+1
-31
lines changed
  • src/vmm/src/devices/virtio/net

1 file changed

+1
-31
lines changed

src/vmm/src/devices/virtio/net/tap.rs

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
use std::fmt::{self, Debug};
99
use std::fs::File;
10-
use std::io::{Error as IoError, Read, Write};
10+
use std::io::{Error as IoError, Read};
1111
use std::os::raw::*;
1212
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
1313

@@ -206,16 +206,6 @@ impl Read for Tap {
206206
}
207207
}
208208

209-
impl Write for Tap {
210-
fn write(&mut self, buf: &[u8]) -> Result<usize, IoError> {
211-
self.tap_file.write(buf)
212-
}
213-
214-
fn flush(&mut self) -> Result<(), IoError> {
215-
Ok(())
216-
}
217-
}
218-
219209
impl AsRawFd for Tap {
220210
fn as_raw_fd(&self) -> RawFd {
221211
self.tap_file.as_raw_fd()
@@ -323,26 +313,6 @@ pub mod tests {
323313
);
324314
}
325315

326-
#[test]
327-
fn test_write() {
328-
let mut tap = Tap::open_named("").unwrap();
329-
enable(&tap);
330-
let tap_traffic_simulator = TapTrafficSimulator::new(if_index(&tap));
331-
332-
let mut packet = [0u8; PACKET_SIZE];
333-
let payload = utils::rand::rand_alphanumerics(PAYLOAD_SIZE);
334-
packet[gen::ETH_HLEN as usize..payload.len() + gen::ETH_HLEN as usize]
335-
.copy_from_slice(payload.as_bytes());
336-
assert_eq!(tap.write(&packet).unwrap(), PACKET_SIZE);
337-
338-
let mut read_buf = [0u8; PACKET_SIZE];
339-
assert!(tap_traffic_simulator.pop_rx_packet(&mut read_buf));
340-
assert_eq!(
341-
&read_buf[..PACKET_SIZE - VNET_HDR_SIZE],
342-
&packet[VNET_HDR_SIZE..]
343-
);
344-
}
345-
346316
#[test]
347317
fn test_write_iovec() {
348318
let mut tap = Tap::open_named("").unwrap();

0 commit comments

Comments
 (0)