uefi: serial: fix core::fmt::Write impl

This is the more expected and natural behavior.
This commit is contained in:
Philipp Schuster
2026-01-24 14:25:46 +01:00
parent 32172b76e8
commit 9098df93e5
3 changed files with 7 additions and 2 deletions
+5 -1
View File
@@ -10,6 +10,7 @@ extern crate alloc;
use alloc::string::ToString;
use alloc::vec::Vec;
use core::fmt::Write;
use core::time::Duration;
use uefi::mem::memory_map::MemoryMap;
use uefi::prelude::*;
@@ -116,7 +117,10 @@ fn send_request_helper(serial: &mut Serial, request: HostRequest) -> Result {
serial.set_attributes(&io_mode)?;
// Send a screenshot request to the host.
serial.write(request.as_bytes()).discard_errdata()?;
//serial.write(request.as_bytes()).discard_errdata()?;
serial
.write_str(request.as_str())
.expect("should write all bytes");
// Wait for the host's acknowledgement before moving forward.
let mut reply = [0; 3];
+1
View File
@@ -30,6 +30,7 @@
return `n` in any case. In the happy path, this always corresponds to the
length if the provided data/buffer, but helps to cope with non-spec-compliant
implementations.
- Fixed potential partial writes in `core::fmt::Write` impl of `Serial` protocol
# uefi - v0.36.1 (2025-11-05)
+1 -1
View File
@@ -345,6 +345,6 @@ impl Serial {
impl Write for Serial {
fn write_str(&mut self, s: &str) -> fmt::Result {
self.write(s.as_bytes()).map(|_| ()).map_err(|_| fmt::Error)
self.write_exact(s.as_bytes()).map_err(|_| fmt::Error)
}
}