Skip to content

doc: improved documentation for boot allocation functions #1665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

phip1611
Copy link
Member

Leftover from #1606

Checklist

  • Sensible git history (for example, squash "typo" or "fix" commits). See the Rewriting History guide for help.
  • Update the changelog (if necessary)

///
/// UEFI OS loaders should allocate memory of the type `LoaderData`.
/// The caller is responsible to free the memory using [`free_pages`].
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// The caller is responsible to free the memory using [`free_pages`].
/// The caller is responsible for freeing the memory using [`free_pages`].

/// - `memory_type`: The [`MemoryType`] used to persist the allocation in the
/// UEFI memory map. Typically, UEFI OS loaders should allocate memory of
/// type [`MemoryType::LOADER_DATA`].
///- `size`: Amount of bytes to allocate.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
///- `size`: Amount of bytes to allocate.
///- `count: Number of pages to allocate.

///- `size`: Amount of bytes to allocate.
///
/// # Safety
/// Using this function is safe but reading on initialized memory is not.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Using this function is safe but reading on initialized memory is not.
/// Using this function is safe, but it returns a raw pointer to uninitialized memory. The memory must be initialized before creating a reference to it.

(Reference: https://doc.rust-lang.org/nomicon/unchecked-uninit.html "It is illegal to construct a reference to uninitialized data")

Copy link
Member Author

Choose a reason for hiding this comment

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

Yikes, typos/weird wording from my side.

Thanks

/// - `memory_type`: The [`MemoryType`] used to persist the allocation in the
/// UEFI memory map. Typically, UEFI OS loaders should allocate memory of
/// type [`MemoryType::LOADER_DATA`].
///- `size`: Amount of bytes to allocate.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
///- `size`: Amount of bytes to allocate.
///- `size`: Number of bytes to allocate.

(This is a nitpicky grammar thing, "number" should be used for countable things)

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