Skip to content

Conversation

@jounathaen
Copy link

Summary of the PR

Currently, property_string_list only accepts Vec<String>, which requires me to copy all values I want to pass to a device tree node. With this change, property_string and property_string_list accept any parameter that is AsRef<str>, making it usable with both String and str.

This should be backwards compatible, except for cases where it could now be unambiguous (like the fdt.property_string_list("strlst", vec!["hi".into(), "bye".into()]) that was in a test.

Requirements

Before submitting your PR, please make sure you addressed the following
requirements:

  • All commits in this PR have Signed-Off-By trailers (with
    git commit -s), and the commit message has max 60 characters for the
    summary and max 75 characters for each description line.
  • All added/changed functionality has a corresponding unit/integration
    test.
  • All added/changed public-facing functionality has entries in the "Upcoming
    Release" section of CHANGELOG.md (if no such section exists, please create one).
  • Any newly added unsafe code is properly documented.

Copy link
Collaborator

@danielverkamp danielverkamp left a comment

Choose a reason for hiding this comment

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

Thanks, the change looks like a good idea overall to me.

I think AsRef<str> alone should be sufficient, which might make this a little more flexible - with that tweak, it should be good to go.

src/writer.rs Outdated
let expected_fdt = vec![
0xd0, 0x0d, 0xfe, 0xed, // 0000: magic (0xd00dfeed)
0x00, 0x00, 0x00, 0xee, // 0004: totalsize (0xEE)
0x00, 0x00, 0x01, 0x0C, // 0004: totalsize (0x10C)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: for consistency, it might be nice to keep the hex digits consistently lowercase - although I guess the ones in the comments are uppercase, so it's already not really very consistent :)

Copy link
Author

Choose a reason for hiding this comment

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

True. There are still some uppercases left, but these were not introduced by me 😉

This allows passing both, str and String.

Signed-off-by: Jonathan Klimt <jonathan.klimt@eonerc.rwth-aachen.de>
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