Skip to content

Centralize SmbiosError to EFI Status conversion using From impl#1384

Merged
kat-perez merged 1 commit intoOpenDevicePartnership:mainfrom
kat-perez:centralize-smbios-error-conversion
Mar 11, 2026
Merged

Centralize SmbiosError to EFI Status conversion using From impl#1384
kat-perez merged 1 commit intoOpenDevicePartnership:mainfrom
kat-perez:centralize-smbios-error-conversion

Conversation

@kat-perez
Copy link
Contributor

@kat-perez kat-perez commented Mar 10, 2026

Description

Centralize the SmbiosError to efi::Status conversion in protocol.rs by using the existing From<SmbiosError> for EfiError impl and the EfiErrorefi::Status conversion chain, instead of manual match arms in each FFI function (add_ext, update_string_ext, remove_ext).

Additionally, RecordTooSmall and StringPoolTooSmall are remapped from EfiError::InvalidParameter to EfiError::BufferTooSmall for more accurate error semantics.

Closes #1163

  • Impacts functionality?
  • Impacts security?
  • Breaking change?
  • Includes tests?
  • Includes documentation?

How This Was Tested

Ran cargo test -p patina_smbios — all 134 tests pass, including updated assertions for the new BufferTooSmall mappings in test_smbios_error_to_efi_error_conversion.

Integration Instructions

N/A

@patina-automation
Copy link
Contributor

patina-automation bot commented Mar 10, 2026

✅ QEMU Validation Passed

All QEMU validation jobs completed successfully.

Note: Windows Q35 is only built (QEMU boot is disabled due to QEMU vfat issue).

Workflow run: https://github.com/OpenDevicePartnership/patina/actions/runs/22957134501

Boot Time to EFI Shell

Platform Elapsed
Linux Q35 34.9s
Linux SBSA 42.2s

This comment was automatically generated by the Patina QEMU PR Validation Post workflow.

@github-actions github-actions bot added impact:non-functional Does not have a functional impact impact:testing Affects testing labels Mar 10, 2026
@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kat-perez kat-perez force-pushed the centralize-smbios-error-conversion branch from c481b9a to d5f0d25 Compare March 11, 2026 13:38
Use the existing From<SmbiosError> for EfiError impl chain instead of
manual match arms in protocol.rs FFI functions. Map RecordTooSmall and
StringPoolTooSmall to BufferTooSmall for accurate error semantics.

Closes OpenDevicePartnership#1163
@kat-perez kat-perez force-pushed the centralize-smbios-error-conversion branch from d5f0d25 to fa79bfb Compare March 11, 2026 14:04
@kat-perez kat-perez marked this pull request as ready for review March 11, 2026 14:40
@kat-perez kat-perez enabled auto-merge (squash) March 11, 2026 14:41
Copy link
Contributor

@Javagedes Javagedes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this.

You could make this even more concise if you are interested, however. Right now you are doing a SmbiosError->EfiError->efi::Status conversion, however you could move your patina::error::EfiError::from(e).into() logic into a impl From<SmbiosError> for efi::Status so that these different match statements are just Err(e) => e.into().

@kat-perez kat-perez merged commit c4b47ac into OpenDevicePartnership:main Mar 11, 2026
9 checks passed
@Javagedes
Copy link
Contributor

Whoops auto merge merged this. I guess I should have left a blocking comment to be manually resolved lmao.

@kat-perez
Copy link
Contributor Author

@Javagedes oops yeah, I can put up another PR with your suggestion

kat-perez added a commit that referenced this pull request Mar 11, 2026
## Description

Adds `impl From<SmbiosError> for efi::Status` to streamline error
conversion in FFI protocol functions, simplifying `add_ext`,
`update_string_ext`, and `remove_ext` from
`patina::error::EfiError::from(e).into()` to `e.into()`.

Implements feedback from @Javagedes on #1384 (which auto-merged before
this could be addressed).

- [x] Impacts functionality?
- [ ] Impacts security?
- [ ] Breaking change?
- [ ] Includes tests?
- [ ] Includes documentation?

## How This Was Tested

`cargo make all` passes — all tests, clippy, fmt, deny, and doc checks
clean.

## Integration Instructions

N/A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact:non-functional Does not have a functional impact impact:testing Affects testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task] Centralize SmbiosError to EFI Status conversion using From impl

3 participants