Skip to content

Commit 2e5dea4

Browse files
authored
Merge pull request #1143 from nicholasbishop/bishop-drop-panic-log
uefi: Drop the panic-on-logger-errors feature
2 parents ddb81bd + bcac03d commit 2e5dea4

File tree

4 files changed

+9
-26
lines changed

4 files changed

+9
-26
lines changed

uefi/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# uefi - [Unreleased]
22

3+
## Removed
4+
- Removed the `panic-on-logger-errors` feature of the `uefi` crate. Logger
5+
errors are now silently ignored.
6+
37

48
# uefi - 0.28.0 (2024-04-19)
59

uefi/Cargo.toml

-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ repository.workspace = true
1313
rust-version.workspace = true
1414

1515
[features]
16-
default = ["panic-on-logger-errors"]
1716
alloc = []
1817

1918
# Generic gate to code that uses unstable features of Rust. You usually need a nightly toolchain.
@@ -23,10 +22,6 @@ unstable = []
2322
logger = []
2423
global_allocator = []
2524
panic_handler = []
26-
# Ignore text output errors in logger as a workaround for firmware issues that
27-
# were observed on the VirtualBox UEFI implementation (see uefi-rs#121).
28-
# In those cases, this feature can be excluded by removing the default features.
29-
panic-on-logger-errors = []
3025
qemu = ["dep:qemu-exit", "panic_handler"] # panic_handler: logical, not technical dependency
3126

3227
[dependencies]

uefi/src/helpers/logger.rs

+5-18
Original file line numberDiff line numberDiff line change
@@ -107,30 +107,17 @@ impl log::Log for Logger {
107107

108108
if !output.is_null() {
109109
let writer = unsafe { &mut *output };
110-
let result = DecoratedLog::write(
110+
111+
// Ignore all errors. Since we're in the logger implementation we
112+
// can't log the error. We also don't want to panic, since logging
113+
// is generally not critical functionality.
114+
let _ = DecoratedLog::write(
111115
writer,
112116
record.level(),
113117
record.args(),
114118
record.file().unwrap_or("<unknown file>"),
115119
record.line().unwrap_or(0),
116120
);
117-
118-
// Some UEFI implementations, such as the one used by VirtualBox,
119-
// may intermittently drop out some text from SimpleTextOutput and
120-
// report an EFI_DEVICE_ERROR. This will be reported here as an
121-
// `fmt::Error`, and given how the `log` crate is designed, our main
122-
// choices when that happens are to ignore the error or panic.
123-
//
124-
// Ignoring errors is bad, especially when they represent loss of
125-
// precious early-boot system diagnosis data, so we panic by
126-
// default. But if you experience this problem and want your UEFI
127-
// application to keep running when it happens, you can disable the
128-
// `panic-on-logger-errors` cargo feature. If you do so, logging errors
129-
// will be ignored by `uefi-rs` instead.
130-
//
131-
if cfg!(feature = "panic-on-logger-errors") {
132-
result.unwrap()
133-
}
134121
}
135122
}
136123

xtask/src/cargo.rs

-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ pub enum Feature {
5050
Alloc,
5151
GlobalAllocator,
5252
Logger,
53-
PanicOnLoggerErrors,
5453
Unstable,
5554
PanicHandler,
5655
Qemu,
@@ -70,7 +69,6 @@ impl Feature {
7069
Self::Alloc => "alloc",
7170
Self::GlobalAllocator => "global_allocator",
7271
Self::Logger => "logger",
73-
Self::PanicOnLoggerErrors => "panic-on-logger-errors",
7472
Self::Unstable => "unstable",
7573
Self::PanicHandler => "panic_handler",
7674
Self::Qemu => "qemu",
@@ -91,7 +89,6 @@ impl Feature {
9189
Self::Alloc,
9290
Self::GlobalAllocator,
9391
Self::Logger,
94-
Self::PanicOnLoggerErrors,
9592
Self::Unstable,
9693
Self::PanicHandler,
9794
Self::Qemu,

0 commit comments

Comments
 (0)