Clippy Tracking Issue: clippy::same_length_and_capacity (pedantic)

Open Beginner friendly
#1,736 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
64/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Quiet
Tech stack
rust
Domain
embedded-iot

Research direction

Start in sdk/patina/src/pi/hob/hob_list.rs at the manually_free_c_array function and inspect the temporary clippy::same_length_and_capacity allowance. Check current Clippy behavior, then remove the allowance when the lint no longer requires it. Run the relevant Rust checks or Clippy validation to confirm the file remains clean.

Written by the indexing model from the issue text.

Description

state:backlog

Documentation: clippy::same_length_and_capacity

Current Status: There is a temporary allowance in sdk/patina/src/pi/hob/hob_list.rs that needs follow up:

    // Implements a function to manually free a C array.
    //
    // # Arguments
    // * `c_array_ptr` - A pointer to the C array.
    // * `len` - The length of the C array.
    //
    // # Safety
    //
    // The caller must ensure that the pointer and length match a Vec originally created by to_c_array.
    pub fn manually_free_c_array(c_array_ptr: *const c_void, len: usize) {
        let ptr = c_array_ptr as *mut u8;
        // SAFETY: Caller is responsible for ensuring the pointer and length are valid per the function contract.
        unsafe {
            #[allow(clippy::same_length_and_capacity)]
            // TODO: Remove this once the clippy lint is fixed in the future.
            drop(Vec::from_raw_parts(ptr, len, len));
        }
    }
Dominant language
Rust
Stars
544
Forks
54
Avg merge
1d 8h
Merged PRs (30d)
30

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenDevicePartnership/patina

All issues in OpenDevicePartnership/patina

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.