Skip to content

refactor(fdt_mut)!: move slice access into FdtBuffer - #160

Merged
m4tx merged 1 commit into
mainfrom
fdt-buffer-refactor
Nov 27, 2026
Merged

m4tx merged 1 commit into
mainfrom
fdt-buffer-refactor

Conversation

@m4tx

@m4tx m4tx commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

FdtBuffer requiring AsRef/AsMut implementations might potentially give us wrong semantics, as these traits do not have any requirements beyond "it's cheap to perform the conversion". In case of slices, for instance, it's wrong because AsRef returns the entire slice, whereas FdtBuffer's contract is to only return the FDT blob part (so totalsize bytes), creating the need for the SliceBuffer wrapper. Moreover, AsMut doesn't require the implementations to return the same data as AsRef, even though we rely on that.

This changes the trait definition to drop the AsRef/AsMut requirement and instead use explicit data()/data_mut() methods. This allows us to drop the SliceBuffer helper and FdtMut::from_slice* constructors.

@m4tx
m4tx requested a review from qwandor November 27, 2026 12:55
@m4tx
m4tx added this pull request to stack #162 November 27, 2026 12:56
@m4tx
m4tx force-pushed the fdt-buffer-refactor branch from 80ddd01 to 7b5dbd7 Compare November 27, 2026 13:03
@codecov

codecov Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.01961% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.36%. Comparing base (873e862) to head (aa12a92).

Files with missing lines Patch % Lines
src/fdt_mut.rs 95.23% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #160      +/-   ##
==========================================
+ Coverage   95.15%   95.36%   +0.20%     
==========================================
  Files          27       27              
  Lines        3985     3991       +6     
==========================================
+ Hits         3792     3806      +14     
+ Misses        193      185       -8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@m4tx
m4tx force-pushed the fdt-buffer-refactor branch from 7b5dbd7 to b94f804 Compare November 27, 2026 13:34
FdtBuffer requiring AsRef/AsMut implementations might potentially give
us wrong semantics, as these traits do not have any requirements beyond
"it's cheap to perform the conversion". In case of slices, for instance,
it's wrong because AsRef returns the entire slice, whereas FdtBuffer's
contract is to only return the FDT blob part (so `totalsize` bytes),
creating the need for the `SliceBuffer` wrapper. Moreover, AsMut
doesn't require the implementations to return the same data as AsRef,
even though we rely on that.

This changes the trait definition to drop the AsRef/AsMut requirement
and instead use explicit `data()`/`data_mut()` methods. This allows us
to drop the `SliceBuffer` helper and `FdtMut::from_slice*` constructors.
@m4tx
m4tx force-pushed the fdt-buffer-refactor branch from b94f804 to aa12a92 Compare November 27, 2026 18:23
@m4tx
m4tx merged commit edbd0ad into main Nov 27, 2026
35 checks passed
@m4tx
m4tx deleted the fdt-buffer-refactor branch November 27, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants