Skip to content

Commit fae721f

Browse files
committed
uefi: serial: fix core::fmt::Write impl
This is the more expected and natural behavior.
1 parent e9c9821 commit fae721f

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

uefi-test-runner/src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ extern crate alloc;
1010

1111
use alloc::string::ToString;
1212
use alloc::vec::Vec;
13+
use core::fmt::Write;
14+
use core::time::Duration;
1315
use uefi::mem::memory_map::MemoryMap;
1416
use uefi::prelude::*;
1517
use uefi::proto::console::serial::Serial;
@@ -115,7 +117,10 @@ fn send_request_helper(serial: &mut Serial, request: HostRequest) -> Result {
115117
serial.set_attributes(&io_mode)?;
116118

117119
// Send a screenshot request to the host.
118-
serial.write(request.as_bytes()).discard_errdata()?;
120+
//serial.write(request.as_bytes()).discard_errdata()?;
121+
serial
122+
.write_str(request.as_str())
123+
.expect("should write all bytes");
119124

120125
// Wait for the host's acknowledgement before moving forward.
121126
let mut reply = [0; 3];

uefi/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
return `n` in any case. In the happy path, this always corresponds to the
3030
length if the provided data/buffer, but helps to cope with non-spec-compliant
3131
implementations.
32+
- Fixed potential partial writes in `core::fmt::Write` impl of `Serial` protocol
3233

3334
# uefi - v0.36.1 (2025-11-05)
3435

uefi/src/proto/console/serial.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,6 @@ impl Serial {
270270

271271
impl Write for Serial {
272272
fn write_str(&mut self, s: &str) -> fmt::Result {
273-
self.write(s.as_bytes()).map(|_| ()).map_err(|_| fmt::Error)
273+
self.write_exact(s.as_bytes()).map_err(|_| fmt::Error)
274274
}
275275
}

0 commit comments

Comments
 (0)