Skip to content

Add type and getters for memory node.#17

Merged
m4tx merged 2 commits into
mainfrom
memory
Dec 17, 2025
Merged

Add type and getters for memory node.#17
m4tx merged 2 commits into
mainfrom
memory

Conversation

@qwandor

@qwandor qwandor commented Dec 15, 2025

Copy link
Copy Markdown
Collaborator

No description provided.

@qwandor qwandor requested a review from m4tx December 15, 2025 19:15
@qwandor qwandor force-pushed the memory branch 2 times, most recently from 4380a93 to 53e9692 Compare December 15, 2025 19:43
@qwandor qwandor force-pushed the memory branch 2 times, most recently from 5a1eb08 to 98cb828 Compare December 16, 2025 16:51
Base automatically changed from properties to main December 17, 2025 10:46

@m4tx m4tx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good overall, but please fix the minor issues I've pointed out.

Comment thread src/fdt/property.rs Outdated
Comment on lines +141 to +143
// `ref_from_bytes` shouldn't panic because each chunk will always be a multiple
// of 4 bytes because of `chunks_exact`.
#[allow(clippy::unwrap_used)]

@m4tx m4tx Dec 17, 2025

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If we have a specific reason anyway, can't we just use .expect() instead with the comment's content in the reason message? Or at least add reason = "..." to the attribute?

On the side, #[expect] should almost always be used instead of #[allow] so that we'll get a warning when the lint is not triggered (for instance when the code below changes and one forgets to remove the #[allow] attribute).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Comment thread src/standard/memory.rs Outdated
}

/// The value of an `initial-mapped-area` property.
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Hash)]

nitpick: there's some small chance someone will want to put this in a hash set.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Comment thread src/standard/memory.rs Outdated
///
/// Returns an error if a property's name or value cannot be read, or the
/// size of the value isn't a multiple of 5 cells.
#[allow(clippy::missing_panics_doc)]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please use #[expect] for this (and I believe this belongs right before the line that causes this.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Comment thread src/standard/memory.rs Outdated
Comment on lines +60 to +67
// try_into can't return an error, because we passed a chunk size matching what
// `InitialMappedArea::from_cells` expects.
#[allow(clippy::unwrap_used)]
Some(
property
.as_prop_encoded_array(5)?
.map(|chunk| InitialMappedArea::from_cells(chunk.try_into().unwrap())),
)

@m4tx m4tx Dec 17, 2025

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same as above: does it make sense to use .expect(<message>)/#[expect(clippy::unwrap_used, reason = "..."] for this?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@qwandor qwandor left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Comment thread src/fdt/property.rs Outdated
Comment on lines +141 to +143
// `ref_from_bytes` shouldn't panic because each chunk will always be a multiple
// of 4 bytes because of `chunks_exact`.
#[allow(clippy::unwrap_used)]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Comment thread src/standard/memory.rs Outdated
Comment on lines +60 to +67
// try_into can't return an error, because we passed a chunk size matching what
// `InitialMappedArea::from_cells` expects.
#[allow(clippy::unwrap_used)]
Some(
property
.as_prop_encoded_array(5)?
.map(|chunk| InitialMappedArea::from_cells(chunk.try_into().unwrap())),
)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Comment thread src/standard/memory.rs Outdated
///
/// Returns an error if a property's name or value cannot be read, or the
/// size of the value isn't a multiple of 5 cells.
#[allow(clippy::missing_panics_doc)]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Comment thread src/standard/memory.rs Outdated
}

/// The value of an `initial-mapped-area` property.
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@qwandor qwandor requested a review from m4tx December 17, 2025 14:42
@m4tx m4tx merged commit fd68a8f into main Dec 17, 2025
25 checks passed
@m4tx m4tx deleted the memory branch December 17, 2025 17:19
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