Skip to content

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

@kat-perez

Description

@kat-perez

Summary

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.

Background

Currently, protocol.rs has manual match statements converting SmbiosError variants to efi::Status in each FFI
function (add_ext, update_string_ext, remove_ext). This duplicates the conversion logic that already exists
in From<SmbiosError> for EfiError.

Proposed Change

  1. Update From<SmbiosError> for EfiError in error.rs:

    • Map RecordTooSmall and StringPoolTooSmall to EfiError::BufferTooSmall (instead of InvalidParameter)
  2. Simplify protocol.rs to use the conversion chain:

// Instead of manual match arms:
Err(SmbiosError::RecordTooSmall) => efi::Status::BUFFER_TOO_SMALL,
Err(SmbiosError::HandleNotFound) => efi::Status::NOT_FOUND,
// ...

// Use:
Err(e) => patina::error::EfiError::from(e).into()

Benefits

  • Single source of truth for error mappings
  • Reduces code duplication across FFI functions
  • Easier to maintain and update error mappings

Related

Identified during PR #1147 review.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions