Skip to content

Commit 1b1e9a6

Browse files
committed
refactor: drop usage of std::io::Sink
This type is only useful if we are dynamically dispatching io via the Read/Write traits, but we are not doing that (we converted everything to static dispatch a while back, for better or for worse, and to avoid conflicts with the PCI branch, I'm not reverting that here). Signed-off-by: Patrick Roy <[email protected]>
1 parent 09a8da6 commit 1b1e9a6

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/vmm/src/device_manager/legacy.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl PortIODeviceManager {
104104
SerialEventsWrapper {
105105
buffer_ready_event_fd: None,
106106
},
107-
SerialOut::Sink(std::io::sink()),
107+
SerialOut::Sink,
108108
),
109109
input: None,
110110
}));
@@ -114,7 +114,7 @@ impl PortIODeviceManager {
114114
SerialEventsWrapper {
115115
buffer_ready_event_fd: None,
116116
},
117-
SerialOut::Sink(std::io::sink()),
117+
SerialOut::Sink,
118118
),
119119
input: None,
120120
}));
@@ -249,7 +249,7 @@ mod tests {
249249
SerialEventsWrapper {
250250
buffer_ready_event_fd: None,
251251
},
252-
SerialOut::Sink(std::io::sink()),
252+
SerialOut::Sink,
253253
),
254254
input: None,
255255
})),

src/vmm/src/device_manager/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ pub(crate) mod tests {
555555
#[cfg(target_arch = "x86_64")]
556556
let legacy_devices = PortIODeviceManager::new(
557557
Arc::new(Mutex::new(
558-
SerialDevice::new(None, SerialOut::Sink(std::io::sink())).unwrap(),
558+
SerialDevice::new(None, SerialOut::Sink).unwrap(),
559559
)),
560560
Arc::new(Mutex::new(
561561
I8042Device::new(EventFd::new(libc::EFD_NONBLOCK).unwrap()).unwrap(),

src/vmm/src/devices/legacy/serial.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,19 @@ impl SerialEvents for SerialEventsWrapper {
127127

128128
#[derive(Debug)]
129129
pub enum SerialOut {
130-
Sink(std::io::Sink),
130+
Sink,
131131
Stdout(std::io::Stdout),
132132
}
133133
impl std::io::Write for SerialOut {
134134
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
135135
match self {
136-
Self::Sink(sink) => sink.write(buf),
136+
Self::Sink => Ok(buf.len()),
137137
Self::Stdout(stdout) => stdout.write(buf),
138138
}
139139
}
140140
fn flush(&mut self) -> std::io::Result<()> {
141141
match self {
142-
Self::Sink(sink) => sink.flush(),
142+
Self::Sink => Ok(()),
143143
Self::Stdout(stdout) => stdout.flush(),
144144
}
145145
}
@@ -407,7 +407,7 @@ mod tests {
407407
SerialEventsWrapper {
408408
buffer_ready_event_fd: None,
409409
},
410-
SerialOut::Sink(std::io::sink()),
410+
SerialOut::Sink,
411411
),
412412
input: None::<std::io::Stdin>,
413413
};

0 commit comments

Comments
 (0)